diff --git a/lighthouse-cli/run.ts b/lighthouse-cli/run.ts index f55c33c43f5f..bacee58fe6f8 100644 --- a/lighthouse-cli/run.ts +++ b/lighthouse-cli/run.ts @@ -40,7 +40,10 @@ export function parseChromeFlags(flags: string = '') { // Avoid '=true', then reintroduce quotes .map(key => { if (parsed[key] === true) return `--${key}`; - return `--${key}="${parsed[key]}"`; + // ChromeLauncher passes flags to Chrome as atomic arguments, so do not double quote + // i.e. `lighthouse --chrome-flags="--user-agent='My Agent'"` becomes `chrome "--user-agent=My Agent"` + // see https://github.com/GoogleChrome/lighthouse/issues/3744 + return `--${key}=${parsed[key]}`; }); } diff --git a/lighthouse-cli/test/cli/run-test.js b/lighthouse-cli/test/cli/run-test.js index 7e6176d85ac7..bca650a20d11 100644 --- a/lighthouse-cli/test/cli/run-test.js +++ b/lighthouse-cli/test/cli/run-test.js @@ -51,10 +51,10 @@ describe('Parsing --chrome-flags', () => { }); it('returns boolean flags that are false with value', () => { - assert.deepStrictEqual(parseChromeFlags('--debug=false'), ['--debug="false"']); + assert.deepStrictEqual(parseChromeFlags('--debug=false'), ['--debug=false']); }); - it('returns boolean flags that empty when passed undefined', () => { + it('returns empty when passed undefined', () => { assert.deepStrictEqual(parseChromeFlags(), []); }); @@ -63,25 +63,25 @@ describe('Parsing --chrome-flags', () => { }); it('handles numeric values', () => { - assert.deepStrictEqual(parseChromeFlags('--log-level=0'), ['--log-level="0"']); + assert.deepStrictEqual(parseChromeFlags('--log-level=0'), ['--log-level=0']); }); - it('quotes flag values with spaces in them (#2817)', () => { + it('handles flag values with spaces in them (#2817)', () => { assert.deepStrictEqual( parseChromeFlags('--user-agent="iPhone UA Test"'), - ['--user-agent="iPhone UA Test"'] + ['--user-agent=iPhone UA Test'] ); assert.deepStrictEqual( parseChromeFlags('--host-resolver-rules="MAP www.example.org:443 127.0.0.1:8443"'), - ['--host-resolver-rules="MAP www.example.org:443 127.0.0.1:8443"'] + ['--host-resolver-rules=MAP www.example.org:443 127.0.0.1:8443'] ); }); it('returns all flags as provided', () => { assert.deepStrictEqual( parseChromeFlags('--spaces="1 2 3 4" --debug=false --verbose --more-spaces="9 9 9"'), - ['--spaces="1 2 3 4"', '--debug="false"', '--verbose', '--more-spaces="9 9 9"'] + ['--spaces=1 2 3 4', '--debug=false', '--verbose', '--more-spaces=9 9 9'] ); }); });