Skip to content

Commit f7b2b53

Browse files
authored
Merge pull request #689 from dart-lang/merge-browser_launcher-package
Merge `package:browser_launcher`
2 parents 88087ae + 561291e commit f7b2b53

15 files changed

+719
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:browser_launcher"
3+
about: "Create a bug or file a feature request against package:browser_launcher."
4+
labels: "package:browser_launcher"
5+
---

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
- changed-files:
99
- any-glob-to-any-file: 'pkgs/boolean_selector/**'
1010

11+
'package:browser_launcher':
12+
- changed-files:
13+
- any-glob-to-any-file: 'pkgs/browser_launcher/**'
14+
1115
'package:cli_config':
1216
- changed-files:
1317
- any-glob-to-any-file: 'pkgs/cli_config/**'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: package:browser_launcher
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/browser_launcher.yml'
9+
- 'pkgs/browser_launcher/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/browser_launcher.yml'
14+
- 'pkgs/browser_launcher/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
18+
env:
19+
PUB_ENVIRONMENT: bot.github
20+
DISPLAY: ':99'
21+
22+
defaults:
23+
run:
24+
working-directory: pkgs/browser_launcher/
25+
26+
jobs:
27+
test:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
sdk: [3.4, dev]
32+
steps:
33+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
34+
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
35+
with:
36+
sdk: ${{ matrix.sdk }}
37+
38+
- run: dart pub get
39+
40+
- run: dart format --output=none --set-exit-if-changed .
41+
- run: dart analyze --fatal-infos
42+
43+
- name: Run Xvfb
44+
run: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
45+
46+
- run: dart test

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ don't naturally belong to other topic monorepos (like
1515
| Package | Description | Version |
1616
| --- | --- | --- |
1717
| [boolean_selector](pkgs/boolean_selector/) | A flexible syntax for boolean expressions, based on a simplified version of Dart's expression syntax. | [![pub package](https://img.shields.io/pub/v/boolean_selector.svg)](https://pub.dev/packages/boolean_selector) |
18+
| [browser_launcher](pkgs/browser_launcher/) | Provides a standardized way to launch web browsers for testing and tools. | [![pub package](https://img.shields.io/pub/v/browser_launcher.svg)](https://pub.dev/packages/browser_launcher) |
1819
| [cli_config](pkgs/cli_config/) | A library to take config values from configuration files, CLI arguments, and environment variables. | [![pub package](https://img.shields.io/pub/v/cli_config.svg)](https://pub.dev/packages/cli_config) |
1920
| [clock](pkgs/clock/) | A fakeable wrapper for dart:core clock APIs. | [![pub package](https://img.shields.io/pub/v/clock.svg)](https://pub.dev/packages/clock) |
2021
| [coverage](pkgs/coverage/) | Coverage data manipulation and formatting. | [![pub package](https://img.shields.io/pub/v/coverage.svg)](https://pub.dev/packages/coverage) |

pkgs/browser_launcher/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Don’t commit the following directories created by pub.
2+
.dart_tool/
3+
.packages
4+
pubspec.lock

pkgs/browser_launcher/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.

pkgs/browser_launcher/CHANGELOG.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
## 1.1.3
2+
3+
- Move to `dart-lang/tools` monorepo.
4+
5+
## 1.1.2
6+
7+
- Require Dart 3.4
8+
- Log errors from chrome
9+
- Allow tests to detect headless-only environment (for CI).
10+
- Add extra flags that may help disable additional throttling in background tabs
11+
- Add `--use-mock-keychain` flag to avoid blocking dialog on MacOS.
12+
13+
## 1.1.1
14+
15+
- Populate the pubspec `repository` field.
16+
17+
## 1.1.0
18+
19+
- Add optional `signIn` argument to `startWithDebugPort`.
20+
To be used together with `user-data-dir` to start a Chrome
21+
window signed in to the default profile with extensions enabled.
22+
- Enable the `avoid_dynamic_calls` lint.
23+
24+
## 1.0.0
25+
26+
- Migrate to null-safety.
27+
28+
## 0.1.10
29+
30+
- Support `webkit_inspection_protocol` version `^1.0.0`.
31+
32+
## 0.1.9
33+
34+
- Add support for Chrome executables in `CHROME_PATH`.
35+
36+
## 0.1.8
37+
38+
- Log `STDERR` on Chrome launch failure.
39+
40+
## 0.1.7
41+
42+
- Widen the dependency range on `package:webkit_inspection_protocol`.
43+
44+
## 0.1.6
45+
46+
- Update lower Dart SDK requirement to `2.2.0`.
47+
- Update the dependency range on `package:webkit_inspection_protocol`.
48+
49+
## 0.1.5
50+
51+
- Add a parameter to use a specified user-data-dir instead of a system temp.
52+
53+
## 0.1.4
54+
55+
- Start Chrome maximized.
56+
57+
## 0.1.3
58+
59+
- widen the version constraint on `package:webkit_inspection_protocol`
60+
61+
## 0.1.2
62+
63+
- lower min sdk version to match Flutter stable
64+
65+
## 0.1.1
66+
67+
- added example
68+
69+
## 0.1.0
70+
71+
- initial release

pkgs/browser_launcher/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2019, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/browser_launcher/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/browser_launcher.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/browser_launcher.yaml)
2+
[![pub package](https://img.shields.io/pub/v/browser_launcher.svg)](https://pub.dev/packages/browser_launcher)
3+
[![package publisher](https://img.shields.io/pub/publisher/browser_launcher.svg)](https://pub.dev/packages/browser_launcher/publisher)
4+
5+
Provides a standardized way to launch web browsers.
6+
7+
Currently, Chrome is the only supported browser; support for other browsers may
8+
be added in the future.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://dart.dev/guides/language/analysis-options
2+
include: package:dart_flutter_team_lints/analysis_options.yaml
3+
4+
analyzer:
5+
language:
6+
strict-casts: true
7+
strict-inference: true
8+
strict-raw-types: true
9+
10+
linter:
11+
rules:
12+
- avoid_bool_literals_in_conditional_expressions
13+
- avoid_classes_with_only_static_members
14+
- avoid_private_typedef_functions
15+
- avoid_redundant_argument_values
16+
- avoid_returning_this
17+
- avoid_unused_constructor_parameters
18+
- avoid_void_async
19+
- cancel_subscriptions
20+
- join_return_with_assignment
21+
- literal_only_boolean_expressions
22+
- missing_whitespace_between_adjacent_strings
23+
- no_adjacent_strings_in_list
24+
- no_runtimeType_toString
25+
- prefer_const_declarations
26+
- prefer_expression_function_bodies
27+
- prefer_final_locals
28+
- require_trailing_commas
29+
- unnecessary_raw_strings
30+
- use_if_null_to_convert_nulls_to_bools
31+
- use_raw_strings
32+
- use_string_buffers
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:browser_launcher/browser_launcher.dart';
6+
7+
const _googleUrl = 'https://www.google.com/';
8+
const _googleImagesUrl = 'https://www.google.com/imghp?hl=en';
9+
10+
Future<void> main() async {
11+
// Launches a chrome browser with two tabs open to [_googleUrl] and
12+
// [_googleImagesUrl].
13+
await Chrome.start([_googleUrl, _googleImagesUrl]);
14+
print('launched Chrome');
15+
16+
// Pause briefly before opening Chrome with a debug port.
17+
await Future<void>.delayed(const Duration(seconds: 3));
18+
19+
// Launches a chrome browser open to [_googleUrl]. Since we are launching with
20+
// a debug port, we will use a variety of different launch configurations,
21+
// such as launching in a new browser.
22+
final chrome = await Chrome.startWithDebugPort([_googleUrl], debugPort: 8888);
23+
print('launched Chrome with a debug port');
24+
25+
// When running this dart code, observe that the browser stays open for 3
26+
// seconds before we close it.
27+
await Future<void>.delayed(const Duration(seconds: 3));
28+
29+
await chrome.close();
30+
print('closed Chrome');
31+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
export 'src/chrome.dart';

0 commit comments

Comments
 (0)