diff --git a/pkgs/browser_launcher/CHANGELOG.md b/pkgs/browser_launcher/CHANGELOG.md index 07db10eb4..b25e7d93c 100644 --- a/pkgs/browser_launcher/CHANGELOG.md +++ b/pkgs/browser_launcher/CHANGELOG.md @@ -3,6 +3,7 @@ - Add `--test-type` and `--disable-session-crashed-bubble` flags when launching chrome to prevent some warnings. - Allow passing arbitrary command line arguments when starting Chrome. +- Separate CLI arguments from URLs with a `--` when launching Chrome. ## 1.1.3 diff --git a/pkgs/browser_launcher/lib/src/chrome.dart b/pkgs/browser_launcher/lib/src/chrome.dart index 2a3cdf8fe..74752aa2e 100644 --- a/pkgs/browser_launcher/lib/src/chrome.dart +++ b/pkgs/browser_launcher/lib/src/chrome.dart @@ -129,12 +129,10 @@ class Chrome { // another, don't announce when the previous session crashed. '--disable-session-crashed-bubble', ...additionalArguments, + if (headless) '--headless', ]; - if (headless) { - args.add('--headless'); - } - final process = await _startProcess(urls, args: args); + final process = await start(urls, args: args); // Wait until the DevTools are listening before trying to connect. final errorLines = []; @@ -177,15 +175,10 @@ class Chrome { static Future start( List urls, { List args = const [], - }) async => - await _startProcess(urls, args: args); - - static Future _startProcess( - List urls, { - List args = const [], - }) async { - final processArgs = args.toList()..addAll(urls); - return await Process.start(_executable, processArgs); + }) { + assert(!args.contains('--')); + assert(!urls.contains('--')); + return Process.start(_executable, [...args, '--', ...urls]); } static Future _connect(Chrome chrome) async {