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(installable-manifest): expose app manifest url #11330
Changes from 1 commit
8232811
7d35259
aff9f37
1323a39
fb31832
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,17 +89,20 @@ class InstallableManifest extends MultiCheckAudit { | |
/** | ||
* @param {LH.Artifacts} artifacts | ||
* @param {LH.Audit.Context} context | ||
* @return {Promise<{failures: Array<string>, manifestValues: LH.Artifacts.ManifestValues}>} | ||
* @return {Promise<{failures: Array<string>, manifestValues: LH.Artifacts.ManifestValues, manifestUrl: string | undefined}>} | ||
*/ | ||
static async audit_(artifacts, context) { | ||
const manifestValues = await ManifestValues.request(artifacts, context); | ||
const manifestFailures = InstallableManifest.assessManifest(manifestValues); | ||
|
||
const manifestUrl = artifacts.WebAppManifest ? artifacts.WebAppManifest.manifestUrl : undefined; | ||
|
||
return { | ||
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. side note how do we have an audit that doesn't have a 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.
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. OHHHH MultiCheckAudit. of course. |
||
failures: [ | ||
...manifestFailures, | ||
], | ||
manifestValues, | ||
manifestUrl, | ||
}; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -584,7 +584,9 @@ class GatherRunner { | |
} | ||
|
||
// Fetch the manifest, if it exists. | ||
baseArtifacts.WebAppManifest = await GatherRunner.getWebAppManifest(passContext); | ||
const manifestResult = await GatherRunner.getWebAppManifest(passContext); | ||
// manifestResult could be null | ||
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. nit: we follow this comment style guide: // Start with capital letter. End with punctuation. 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. (oh, but it does seem like we can revert these few lines?) |
||
baseArtifacts.WebAppManifest = manifestResult ? manifestResult.parsedManifest : null; | ||
|
||
if (baseArtifacts.WebAppManifest) { | ||
baseArtifacts.InstallabilityErrors = await GatherRunner.getInstallabilityErrors(passContext); | ||
|
@@ -626,12 +628,15 @@ class GatherRunner { | |
* will have the reason. See manifest-parser.js for more information. | ||
* | ||
* @param {LH.Gatherer.PassContext} passContext | ||
* @return {Promise<LH.Artifacts.Manifest|null>} | ||
* @return {Promise<{parsedManifest: LH.Artifacts.Manifest|null, manifestUrl: string|null} | null>} | ||
*/ | ||
static async getWebAppManifest(passContext) { | ||
const response = await passContext.driver.getAppManifest(); | ||
if (!response) return null; | ||
return manifestParser(response.data, response.url, passContext.url); | ||
const parsedManifest = manifestParser(response.data, response.url, passContext.url); | ||
const manifestUrl = response.url; | ||
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. we talked in voice about this.. should manifestUrl be part of the parser's return value? I said no, but... let's reconsider. ... it could. and it kinda makes sense. just spoke with @brendankenny and we both feel fairly ambivalent about it. It keeps things a tad cleaner to put it in the manifestParser return, so let's do that. (well, as it turns out... you already did) that actually means you can revert allllll the changes in gather-runner anddddddddddd i think everything will just still end up working fine. 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. yea it seems like this whole file could be reverted and the url from the parser lib will be consumable in |
||
const manifestResult = {parsedManifest, manifestUrl}; | ||
return manifestResult; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,6 +505,7 @@ function parse(string, manifestUrl, documentUrl) { | |
raw: string, | ||
value: manifest, | ||
warning: manifestUrlWarning, | ||
manifestUrl: manifestUrl, | ||
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. I think I think 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. Do you think we should do this for the audit items value too? details.items[0].url vs details.items[0].manifestUrl. manifestUrl does add some clarity, although not sure if its necessary given that the audit refers to the manifest. 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.
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. There is some pretty good self documenting value for keeping it Note also it's a term from the spec, to differentiate from "document URL" and |
||
}; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1798,8 +1798,9 @@ describe('GatherRunner', function() { | |
.mockResponse('Page.getInstallabilityErrors', {installabilityErrors: []}); | ||
|
||
const result = await GatherRunner.getWebAppManifest(passContext); | ||
expect(result).toHaveProperty('raw', JSON.stringify(manifest)); | ||
expect(result && result.value).toMatchObject({ | ||
const parsedManifest = result ? result.parsedManifest : null; | ||
expect(parsedManifest).toHaveProperty('raw', JSON.stringify(manifest)); | ||
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. this can be reverted to after you revert the changes in |
||
expect(parsedManifest && parsedManifest.value).toMatchObject({ | ||
name: {value: 'App', raw: 'App'}, | ||
start_url: {value: passContext.url, raw: undefined}, | ||
}); | ||
|
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.
connor will know better but i think we want
null
rather thanundefined
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.
yea
null
is preferable for "missing", especially when the object may be JSON serialized (properties set toundefined
are dropped in JSON)