Skip to content

Commit

Permalink
Merge pull request #689 from dart-lang/merge-browser_launcher-package
Browse files Browse the repository at this point in the history
Merge `package:browser_launcher`
  • Loading branch information
mosuem authored Oct 28, 2024
2 parents 88087ae + 561291e commit f7b2b53
Show file tree
Hide file tree
Showing 15 changed files with 719 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/browser_launcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:browser_launcher"
about: "Create a bug or file a feature request against package:browser_launcher."
labels: "package:browser_launcher"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/boolean_selector/**'

'package:browser_launcher':
- changed-files:
- any-glob-to-any-file: 'pkgs/browser_launcher/**'

'package:cli_config':
- changed-files:
- any-glob-to-any-file: 'pkgs/cli_config/**'
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/browser_launcher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: package:browser_launcher

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/browser_launcher.yml'
- 'pkgs/browser_launcher/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/browser_launcher.yml'
- 'pkgs/browser_launcher/**'
schedule:
- cron: "0 0 * * 0"

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

defaults:
run:
working-directory: pkgs/browser_launcher/

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

- 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ don't naturally belong to other topic monorepos (like
| Package | Description | Version |
| --- | --- | --- |
| [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) |
| [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) |
| [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) |
| [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) |
| [coverage](pkgs/coverage/) | Coverage data manipulation and formatting. | [![pub package](https://img.shields.io/pub/v/coverage.svg)](https://pub.dev/packages/coverage) |
Expand Down
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.
71 changes: 71 additions & 0 deletions pkgs/browser_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
## 1.1.3

- Move to `dart-lang/tools` monorepo.

## 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 @@
[![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)
[![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.
32 changes: 32 additions & 0 deletions pkgs/browser_launcher/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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
- 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
31 changes: 31 additions & 0 deletions pkgs/browser_launcher/example/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2024, 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.

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 f7b2b53

Please sign in to comment.