Skip to content

Commit

Permalink
cli: Add --mixed-content flag for triggering the mixed content audit (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
christhompson authored and paulirish committed Feb 8, 2018
1 parent 0f8b1a3 commit 278d1e7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions lighthouse-cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const log = require('lighthouse-logger');
// @ts-ignore
const perfOnlyConfig = require('../lighthouse-core/config/perf.json');
// @ts-ignore
const mixedContentConfig = require('../lighthouse-core/config/mixed-content.js');
// @ts-ignore
const pkg = require('../package.json');
const Sentry = require('../lighthouse-core/lib/sentry');

Expand Down Expand Up @@ -56,6 +58,10 @@ if (cliFlags.configPath) {
config = /** @type {!LH.Config} */ (require(cliFlags.configPath));
} else if (cliFlags.perf) {
config = /** @type {!LH.Config} */ (perfOnlyConfig);
} else if (cliFlags.mixedContent) {
config = /** @type {!LH.Config} */ (mixedContentConfig);
// The mixed-content audits require headless Chrome (https://crbug.com/764505).
cliFlags.chromeFlags = `${cliFlags.chromeFlags} --headless`;
}

// set logging preferences
Expand Down
9 changes: 5 additions & 4 deletions lighthouse-cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ function getFlags(manualArgv) {

.group(
[
'save-assets', 'list-all-audits', 'list-trace-categories',
'additional-trace-categories', 'config-path', 'chrome-flags', 'perf', 'port',
'hostname', 'max-wait-for-load', 'enable-error-reporting', 'gather-mode', 'audit-mode',
'save-assets', 'list-all-audits', 'list-trace-categories', 'additional-trace-categories',
'config-path', 'chrome-flags', 'perf', 'mixed-content', 'port', 'hostname',
'max-wait-for-load', 'enable-error-reporting', 'gather-mode', 'audit-mode',
],
'Configuration:')
.describe({
Expand All @@ -81,6 +81,7 @@ function getFlags(manualArgv) {
'additional-trace-categories':
'Additional categories to capture with the trace (comma-delimited).',
'config-path': 'The path to the config JSON.',
'mixed-content': 'Use the mixed-content auditing configuration.',
'chrome-flags':
`Custom flags to pass to Chrome (space-delimited). For a full list of flags, see http://bit.ly/chrome-flags
Additionally, use the CHROME_PATH environment variable to use a specific Chrome binary. Requires Chromium version 54.0 or later. If omitted, any detected Chrome Canary or Chrome stable will be used.`,
Expand Down Expand Up @@ -110,7 +111,7 @@ function getFlags(manualArgv) {
'disable-storage-reset', 'disable-device-emulation', 'disable-cpu-throttling',
'disable-network-throttling', 'save-assets', 'list-all-audits',
'list-trace-categories', 'perf', 'view', 'verbose', 'quiet', 'help',
'gather-mode', 'audit-mode',
'gather-mode', 'audit-mode', 'mixed-content',
])
.choices('output', printer.getValidOutputOptions())
// force as an array
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const _PROTOCOL_TIMEOUT_EXIT_CODE = 67;
*/
function parseChromeFlags(flags = '') {
const parsed = yargsParser(
flags, {configuration: {'camel-case-expansion': false, 'boolean-negation': false}});
flags.trim(), {configuration: {'camel-case-expansion': false, 'boolean-negation': false}});

return Object
.keys(parsed)
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function lighthouse(url, flags = {}, configJSON) {

// Use ConfigParser to generate a valid config file
const config = new Config(configJSON, flags.configPath);

const connection = new ChromeProtocol(flags.port, flags.hostname);

// kick off a lighthouse run
Expand Down
1 change: 1 addition & 0 deletions typings/externs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Flags {
gatherMode: boolean;
configPath?: string;
perf: boolean;
mixedContent: boolean;
verbose: boolean;
quiet: boolean;
}
Expand Down

0 comments on commit 278d1e7

Please sign in to comment.