Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: do not double quote chromeFlags #3775

Merged
merged 2 commits into from
Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lighthouse-cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]}`;
});
}

Expand Down
10 changes: 5 additions & 5 deletions lighthouse-cli/test/cli/run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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']
);
});
});