diff --git a/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap b/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap index b20bd2435ba1..84bd43bec717 100644 --- a/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap +++ b/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap @@ -1455,6 +1455,9 @@ Object { Object { "path": "inspector-issues", }, + Object { + "path": "service-worker", + }, Object { "path": "source-maps", }, @@ -1470,23 +1473,6 @@ Object { "recordTrace": true, "useThrottling": true, }, - Object { - "blankPage": "about:blank", - "blockedUrlPatterns": Array [], - "cpuQuietThresholdMs": 0, - "gatherers": Array [ - Object { - "path": "service-worker", - }, - ], - "loadFailureMode": "ignore", - "networkQuietThresholdMs": 0, - "passName": "offlinePass", - "pauseAfterFcpMs": 0, - "pauseAfterLoadMs": 0, - "recordTrace": false, - "useThrottling": false, - }, ], "settings": Object { "additionalTraceCategories": null, diff --git a/lighthouse-core/config/default-config.js b/lighthouse-core/config/default-config.js index a15a946c81bf..4ee10f0a6344 100644 --- a/lighthouse-core/config/default-config.js +++ b/lighthouse-core/config/default-config.js @@ -160,16 +160,10 @@ const defaultConfig = { 'accessibility', 'trace-elements', 'inspector-issues', + 'service-worker', 'source-maps', 'full-page-screenshot', ], - }, - { - passName: 'offlinePass', - loadFailureMode: 'ignore', - gatherers: [ - 'service-worker', - ], }], audits: [ 'is-on-https', diff --git a/lighthouse-core/gather/gatherers/service-worker.js b/lighthouse-core/gather/gatherers/service-worker.js index 211381024d04..091f0c74ec38 100644 --- a/lighthouse-core/gather/gatherers/service-worker.js +++ b/lighthouse-core/gather/gatherers/service-worker.js @@ -14,18 +14,6 @@ class ServiceWorker extends FRGatherer { supportedModes: ['navigation'], }; - /** - * @param {LH.Gatherer.PassContext} passContext - * @return {Promise} - */ - async beforePass(passContext) { - return this.getArtifact({...passContext, dependencies: {}}); - } - - // This gatherer is run in a separate pass for legacy mode. - // Legacy compat code is in `beforePass`. - async afterPass() { } - /** * @param {LH.Gatherer.FRTransitionalContext} context * @return {Promise} diff --git a/lighthouse-core/test/chromium-web-tests/README.md b/lighthouse-core/test/chromium-web-tests/README.md index 6b83e5b564db..9b24185c3eea 100644 --- a/lighthouse-core/test/chromium-web-tests/README.md +++ b/lighthouse-core/test/chromium-web-tests/README.md @@ -29,7 +29,7 @@ SKIP_DOWNLOADS=1 yarn test-devtools ```sh curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py python get-pip.py - pip -m pip install requests + python -m pip install requests ``` diff --git a/lighthouse-core/test/config/config-test.js b/lighthouse-core/test/config/config-test.js index 8b3ae3c5ad82..b9c5cdf15fe0 100644 --- a/lighthouse-core/test/config/config-test.js +++ b/lighthouse-core/test/config/config-test.js @@ -757,6 +757,14 @@ describe('Config', () => { settings: { throttlingMethod: 'devtools', }, + // Add a second pass. + passes: [{ + passName: 'offlinePass', + loadFailureMode: 'ignore', + gatherers: [ + 'service-worker', + ], + }], }); assert.equal(config.settings.throttlingMethod, 'devtools'); @@ -894,6 +902,14 @@ describe('Config', () => { settings: { onlyCategories: ['pwa'], }, + // Add a second pass. + passes: [{ + passName: 'offlinePass', + loadFailureMode: 'ignore', + gatherers: [ + 'service-worker', + ], + }], }; const config = new Config(extendedJson); assert.equal(config.passes.length, 2, 'did not filter config'); @@ -1103,12 +1119,22 @@ describe('Config', () => { describe('filterConfigIfNeeded', () => { it('should not mutate the original config', () => { - const configCopy = JSON.parse(JSON.stringify(origConfig)); + const originalConfigPlusSecondPass = JSON.parse(JSON.stringify(origConfig)); + originalConfigPlusSecondPass.passes.push({ + passName: 'offlinePass', + loadFailureMode: 'ignore', + gatherers: [ + 'service-worker', + ], + }); + assert.equal(originalConfigPlusSecondPass.passes.length, 2); + const configCopy = JSON.parse(JSON.stringify(originalConfigPlusSecondPass)); configCopy.settings.onlyCategories = ['performance']; + const config = new Config(configCopy); configCopy.settings.onlyCategories = null; assert.equal(config.passes.length, 1, 'did not filter config'); - assert.deepStrictEqual(configCopy, origConfig, 'had mutations'); + assert.deepStrictEqual(configCopy, originalConfigPlusSecondPass, 'had mutations'); }); it('should generate the same filtered config, extended or original', () => { @@ -1204,6 +1230,14 @@ describe('Config', () => { settings: { onlyAudits: ['service-worker'], // something from non-defaultPass }, + // Add a second pass. + passes: [{ + passName: 'offlinePass', + loadFailureMode: 'ignore', + gatherers: [ + 'service-worker', + ], + }], }; const config = new Config(extended); assert.equal(config.passes.length, 2, 'incorrect # of passes'); @@ -1217,6 +1251,14 @@ describe('Config', () => { onlyCategories: ['performance'], onlyAudits: ['service-worker'], // something from non-defaultPass }, + // Add a second pass. + passes: [{ + passName: 'offlinePass', + loadFailureMode: 'ignore', + gatherers: [ + 'service-worker', + ], + }], }; const config = new Config(extended); const selectedCategory = origConfig.categories.performance; @@ -1235,7 +1277,16 @@ describe('Config', () => { onlyCategories: ['pwa'], onlyAudits: ['apple-touch-icon'], }, + // Add a second pass. + passes: [{ + passName: 'offlinePass', + loadFailureMode: 'ignore', + gatherers: [ + 'service-worker', + ], + }], }; + const config = new Config(extended); const selectedCategory = origConfig.categories.pwa; // +1 for `full-page-screenshot`. diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt index 721f73c6508c..c9207df0867b 100644 --- a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt +++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt @@ -59,6 +59,7 @@ Gathering setup: TapTargets Gathering setup: Accessibility Gathering setup: TraceElements Gathering setup: InspectorIssues +Gathering setup: ServiceWorker Gathering setup: SourceMaps Gathering setup: FullPageScreenshot Beginning devtoolsLog and trace @@ -90,6 +91,7 @@ Gathering in-page: TapTargets Gathering in-page: Accessibility Gathering in-page: TraceElements Gathering in-page: InspectorIssues +Gathering in-page: ServiceWorker Gathering in-page: SourceMaps Gathering in-page: FullPageScreenshot Gathering trace @@ -124,27 +126,12 @@ Gathering: TraceElements Computing artifact: ProcessedTrace$f Computing artifact: ProcessedNavigation$7 Gathering: InspectorIssues +Gathering: ServiceWorker Gathering: SourceMaps Gathering: FullPageScreenshot Populate base artifacts Get webapp manifest Collect stacks -Running offlinePass pass -Resetting state with about:blank -Navigating to about:blank -Preparing target for navigation -Preparing network conditions -Running beforePass methods -Gathering setup: ServiceWorker -Beginning devtoolsLog and trace -Loading page & waiting for onload -Navigating to http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-basic.html -Running pass methods -Gathering in-page: ServiceWorker -Gathering devtoolsLog & network records -Computing artifact: NetworkRecords$M -Running afterPass methods -Gathering: ServiceWorker Disconnecting from browser... Cleaning origin data Audit phase