-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
*/ | ||
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; |
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 than 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.
yea null
is preferable for "missing", especially when the object may be JSON serialized (properties set to undefined
are dropped in JSON)
*/ | ||
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 comment
The 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 comment
The 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 installable-manifest
*/ | ||
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 comment
The 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 score
.. so confused
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.
extends MultiCheckAudit
and that audit_
life, def confusing though
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.
OHHHH MultiCheckAudit. of course.
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.
+1 to Paul's comment, it seems you two worked out that just changing the return value of the manifest parser is enough to get installable-manifest
the url. No need for any of the gather-runner changes afaict
An end-to-end to would be good here, can you add to the expectations file for one of our smoke tests? pwa1
and pwa2
both load pages that have a manifest, so you could add an assertion there for installable-manifest
.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think url
would be a better name here, considering the natural way to name a variable holding this object is manifest
(gather-runner actually uses parsedManifest
which is also cool), and manifest.manifestUrl
is redundant.
I think manifest.url
would not lead to any confusion about what the url is referring to.
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
url
would be great there too
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.
There is some pretty good self documenting value for keeping it manifestUrl
when it's deep in installableManifest.details.items[0]
, though, since we don't publish docs for specific audit's details.
Note also it's a term from the spec, to differentiate from "document URL" and start_url
(which are both also needed for parsing the manifest).
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
(oh, but it does seem like we can revert these few lines?)
*/ | ||
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 comment
The 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 installable-manifest
*/ | ||
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; |
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 to undefined
are dropped in JSON)
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 comment
The reason will be displayed to describe this comment to others. Learn more.
this can be reverted to after you revert the changes in gather-runner
, but I think an assertion here for result.url
would be good.
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.
LGTM, nice job!
fyi if you put "fixed by #blah" in the first post, when the PR merges it auto-closes the associated issue |
for #9683
exposes the app manifest url in the installable manifest audit