From 6aa741b3b8f8c4bb35f980ceaeff2aca1e52a526 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Tue, 7 Nov 2017 13:56:44 -0800 Subject: [PATCH 1/2] cli: do not double quote chromeFlags --- lighthouse-cli/run.ts | 5 ++++- lighthouse-cli/test/cli/run-test.js | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) 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..82d618cc74b0 100644 --- a/lighthouse-cli/test/cli/run-test.js +++ b/lighthouse-cli/test/cli/run-test.js @@ -51,7 +51,7 @@ 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', () => { @@ -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)', () => { 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'] ); }); }); From fcc4a5cccbaeff0d19d580977e4f4b5fdb86ba07 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Fri, 10 Nov 2017 08:55:48 -0800 Subject: [PATCH 2/2] update test strings --- lighthouse-cli/test/cli/run-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lighthouse-cli/test/cli/run-test.js b/lighthouse-cli/test/cli/run-test.js index 82d618cc74b0..bca650a20d11 100644 --- a/lighthouse-cli/test/cli/run-test.js +++ b/lighthouse-cli/test/cli/run-test.js @@ -54,7 +54,7 @@ describe('Parsing --chrome-flags', () => { 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(), []); }); @@ -66,7 +66,7 @@ describe('Parsing --chrome-flags', () => { 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']