Skip to content

Commit

Permalink
Merge package:browser_launcher into the tools monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Oct 25, 2024
2 parents b1312b1 + dd6f222 commit 9df6358
Show file tree
Hide file tree
Showing 13 changed files with 708 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkgs/browser_launcher/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Set update schedule for GitHub Actions

version: 2
updates:

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
labels:
- autosubmit
groups:
github-actions:
patterns:
- "*"
37 changes: 37 additions & 0 deletions pkgs/browser_launcher/.github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Dart

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github
DISPLAY: ':99'

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
sdk: [3.4, dev]
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}

- run: dart pub get
id: install

- run: dart format --output=none --set-exit-if-changed .
- run: dart analyze --fatal-infos

- name: Run Xvfb
run: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &

- run: dart test
4 changes: 4 additions & 0 deletions pkgs/browser_launcher/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Don’t commit the following directories created by pub.
.dart_tool/
.packages
pubspec.lock
6 changes: 6 additions & 0 deletions pkgs/browser_launcher/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
67 changes: 67 additions & 0 deletions pkgs/browser_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
## 1.1.2

- Require Dart 3.4
- Log errors from chrome
- Allow tests to detect headless-only environment (for CI).
- Add extra flags that may help disable additional throttling in background tabs
- Add `--use-mock-keychain` flag to avoid blocking dialog on MacOS.

## 1.1.1

- Populate the pubspec `repository` field.

## 1.1.0

- Add optional `signIn` argument to `startWithDebugPort`.
To be used together with `user-data-dir` to start a Chrome
window signed in to the default profile with extensions enabled.
- Enable the `avoid_dynamic_calls` lint.

## 1.0.0

- Migrate to null-safety.

## 0.1.10

- Support `webkit_inspection_protocol` version `^1.0.0`.

## 0.1.9

- Add support for Chrome executables in `CHROME_PATH`.

## 0.1.8

- Log `STDERR` on Chrome launch failure.

## 0.1.7

- Widen the dependency range on `package:webkit_inspection_protocol`.

## 0.1.6

- Update lower Dart SDK requirement to `2.2.0`.
- Update the dependency range on `package:webkit_inspection_protocol`.

## 0.1.5

- Add a parameter to use a specified user-data-dir instead of a system temp.

## 0.1.4

- Start Chrome maximized.

## 0.1.3

- widen the version constraint on `package:webkit_inspection_protocol`

## 0.1.2

- lower min sdk version to match Flutter stable

## 0.1.1

- added example

## 0.1.0

- initial release
27 changes: 27 additions & 0 deletions pkgs/browser_launcher/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2019, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 8 additions & 0 deletions pkgs/browser_launcher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[![Dart](https://github.com/dart-lang/browser_launcher/workflows/Dart/badge.svg)](https://github.com/dart-lang/browser_launcher/actions?query=workflow%3ADart+branch%3Amaster)
[![pub package](https://img.shields.io/pub/v/browser_launcher.svg)](https://pub.dev/packages/browser_launcher)
[![package publisher](https://img.shields.io/pub/publisher/browser_launcher.svg)](https://pub.dev/packages/browser_launcher/publisher)

Provides a standardized way to launch web browsers.

Currently, Chrome is the only supported browser; support for other browsers may
be added in the future.
33 changes: 33 additions & 0 deletions pkgs/browser_launcher/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://dart.dev/guides/language/analysis-options
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_this
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- join_return_with_assignment
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- package_api_docs
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- require_trailing_commas
- unnecessary_raw_strings
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
- use_string_buffers
27 changes: 27 additions & 0 deletions pkgs/browser_launcher/example/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:browser_launcher/browser_launcher.dart';

const _googleUrl = 'https://www.google.com/';
const _googleImagesUrl = 'https://www.google.com/imghp?hl=en';

Future<void> main() async {
// Launches a chrome browser with two tabs open to [_googleUrl] and
// [_googleImagesUrl].
await Chrome.start([_googleUrl, _googleImagesUrl]);
print('launched Chrome');

// Pause briefly before opening Chrome with a debug port.
await Future<void>.delayed(const Duration(seconds: 3));

// Launches a chrome browser open to [_googleUrl]. Since we are launching with
// a debug port, we will use a variety of different launch configurations,
// such as launching in a new browser.
final chrome = await Chrome.startWithDebugPort([_googleUrl], debugPort: 8888);
print('launched Chrome with a debug port');

// When running this dart code, observe that the browser stays open for 3
// seconds before we close it.
await Future<void>.delayed(const Duration(seconds: 3));

await chrome.close();
print('closed Chrome');
}
5 changes: 5 additions & 0 deletions pkgs/browser_launcher/lib/browser_launcher.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

export 'src/chrome.dart';
Loading

0 comments on commit 9df6358

Please sign in to comment.