-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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: special case AppManifest as baseArtifact #6957
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d36304d
core: special case AppManifest as baseArtifact
patrickhulce 6073f99
just feedback
patrickhulce 09869b0
fix tests
patrickhulce 633829e
todo
patrickhulce 5cca8a9
cleanup start url
patrickhulce 78ba22d
feedback
patrickhulce 213bd36
Merge branch 'master' into manifest_base_artifacts
patrickhulce bc6dfd5
merge fixes
patrickhulce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
'use strict'; | ||
|
||
const Gatherer = require('./gatherer'); | ||
const manifestParser = require('../../lib/manifest-parser'); | ||
|
||
/** @typedef {import('../driver.js')} Driver */ | ||
|
||
|
@@ -16,27 +15,21 @@ class StartUrl extends Gatherer { | |
* @param {LH.Gatherer.PassContext} passContext | ||
* @return {Promise<LH.Artifacts['StartUrl']>} | ||
*/ | ||
afterPass(passContext) { | ||
const driver = passContext.driver; | ||
return driver.goOnline(passContext) | ||
.then(() => driver.getAppManifest()) | ||
.then(response => driver.goOffline().then(() => response)) | ||
.then(response => response && manifestParser(response.data, response.url, passContext.url)) | ||
.then(manifest => { | ||
const startUrlInfo = this._readManifestStartUrl(manifest); | ||
if (startUrlInfo.isReadFailure) { | ||
return {statusCode: -1, explanation: startUrlInfo.reason}; | ||
} | ||
async afterPass(passContext) { | ||
const manifest = passContext.baseArtifacts.WebAppManifest; | ||
const startUrlInfo = this._readManifestStartUrl(manifest); | ||
if (startUrlInfo.isReadFailure) { | ||
return {statusCode: -1, explanation: startUrlInfo.reason}; | ||
} | ||
|
||
return this._attemptManifestFetch(passContext.driver, startUrlInfo.startUrl); | ||
}).catch(() => { | ||
return {statusCode: -1, explanation: 'Unable to fetch start URL via service worker.'}; | ||
}); | ||
return this._attemptStartURLFetch(passContext.driver, startUrlInfo.startUrl).catch(() => { | ||
return {statusCode: -1, explanation: 'Unable to fetch start URL via service worker.'}; | ||
}); | ||
} | ||
|
||
/** | ||
* Read the parsed manifest and return failure reasons or the startUrl | ||
* @param {?{value?: {start_url: {value: string, warning?: string}}, warning?: string}} manifest | ||
* @param {LH.Artifacts.Manifest|null} manifest | ||
* @return {{isReadFailure: true, reason: string}|{isReadFailure: false, startUrl: string}} | ||
*/ | ||
_readManifestStartUrl(manifest) { | ||
|
@@ -61,7 +54,8 @@ class StartUrl extends Gatherer { | |
* @param {string} startUrl | ||
* @return {Promise<{statusCode: number, explanation: string}>} | ||
*/ | ||
_attemptManifestFetch(driver, startUrl) { | ||
_attemptStartURLFetch(driver, startUrl) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ha, whoops |
||
// TODO(phulce): clean up this setTimeout once the response has happened | ||
// Wait up to 3s to get a matched network request from the fetch() to work | ||
const timeoutPromise = new Promise(resolve => | ||
setTimeout( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to keep this? TODO for followup to split up the changes nicely? Or is it worth keeping for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meh, I'll just do it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boy am I regretting that 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I'm gonna make this a TODO