diff --git a/lighthouse-cli/bin.js b/lighthouse-cli/bin.js index 36611d124be2..d2542fb6d338 100644 --- a/lighthouse-cli/bin.js +++ b/lighthouse-cli/bin.js @@ -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'); @@ -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 diff --git a/lighthouse-cli/cli-flags.js b/lighthouse-cli/cli-flags.js index e17dcd4452e3..be79b17bad86 100644 --- a/lighthouse-cli/cli-flags.js +++ b/lighthouse-cli/cli-flags.js @@ -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({ @@ -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.`, @@ -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 diff --git a/lighthouse-cli/run.js b/lighthouse-cli/run.js index 3c965675fc96..abd70966138c 100644 --- a/lighthouse-cli/run.js +++ b/lighthouse-cli/run.js @@ -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) diff --git a/lighthouse-core/index.js b/lighthouse-core/index.js index dc0a85284a2e..b832fe7671cb 100644 --- a/lighthouse-core/index.js +++ b/lighthouse-core/index.js @@ -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 diff --git a/typings/externs.d.ts b/typings/externs.d.ts index 407254da23fd..90a8ee3ffe10 100644 --- a/typings/externs.d.ts +++ b/typings/externs.d.ts @@ -26,6 +26,7 @@ export interface Flags { gatherMode: boolean; configPath?: string; perf: boolean; + mixedContent: boolean; verbose: boolean; quiet: boolean; }