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

core(service-worker): move to defaultPass, delete second pass #13711

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 3 additions & 17 deletions lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,9 @@ Object {
Object {
"path": "inspector-issues",
},
Object {
"path": "service-worker",
},
Object {
"path": "source-maps",
},
Expand All @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 0 additions & 12 deletions lighthouse-core/gather/gatherers/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ class ServiceWorker extends FRGatherer {
supportedModes: ['navigation'],
};

/**
* @param {LH.Gatherer.PassContext} passContext
* @return {Promise<LH.Artifacts['ServiceWorker']>}
*/
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<LH.Artifacts['ServiceWorker']>}
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/chromium-web-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive by fix

```

</details>
Expand Down
55 changes: 53 additions & 2 deletions lighthouse-core/test/config/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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');
Expand All @@ -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;
Expand All @@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down