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(installable-manifest): expose app manifest url #11330

Merged
merged 5 commits into from Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -116,7 +116,7 @@ module.exports = [
},
'installable-manifest': {
score: 1,
details: {items: [pwaDetailsExpectations]},
details: {items: [{...pwaDetailsExpectations, manifestUrl: 'https://caltrainschedule.io/manifest.json'}]},
},
'splash-screen': {
score: 1,
Expand Down
5 changes: 4 additions & 1 deletion lighthouse-core/audits/installable-manifest.js
Expand Up @@ -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 | null}>}
*/
static async audit_(artifacts, context) {
const manifestValues = await ManifestValues.request(artifacts, context);
const manifestFailures = InstallableManifest.assessManifest(manifestValues);

const manifestUrl = artifacts.WebAppManifest ? artifacts.WebAppManifest.url : null;

return {
Copy link
Member

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

Copy link
Collaborator

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

Copy link
Member

Choose a reason for hiding this comment

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

OHHHH MultiCheckAudit. of course.

failures: [
...manifestFailures,
],
manifestValues,
manifestUrl,
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions lighthouse-core/lib/manifest-parser.js
Expand Up @@ -472,6 +472,7 @@ function parse(string, manifestUrl, documentUrl) {
raw: string,
value: undefined,
warning: 'ERROR: file isn\'t valid JSON: ' + e,
url: manifestUrl,
};
}

Expand Down Expand Up @@ -505,6 +506,7 @@ function parse(string, manifestUrl, documentUrl) {
raw: string,
value: manifest,
warning: manifestUrlWarning,
url: manifestUrl,
};
}

Expand Down
10 changes: 10 additions & 0 deletions lighthouse-core/test/audits/installable-manifest-test.js
Expand Up @@ -44,6 +44,16 @@ describe('PWA: webapp install banner audit', () => {
});
});

it('passes when manifest url matches', () => {
const artifacts = generateMockArtifacts();
const context = generateMockAuditContext();

return InstallableManifestAudit.audit(artifacts, context).then(result => {
assert.strictEqual(artifacts.WebAppManifest.url, EXAMPLE_MANIFEST_URL);
assert.strictEqual(result.details.items[0].manifestUrl, EXAMPLE_MANIFEST_URL);
});
});

it('fails with a non-parsable manifest', () => {
const artifacts = generateMockArtifacts('{,:}');
const context = generateMockAuditContext();
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/test/gather/gather-runner-test.js
Expand Up @@ -1803,6 +1803,7 @@ describe('GatherRunner', function() {
name: {value: 'App', raw: 'App'},
start_url: {value: passContext.url, raw: undefined},
});
expect(result && result.url).toMatch(MANIFEST_URL);
});
});
});
1 change: 1 addition & 0 deletions lighthouse-core/test/results/sample_v2.json
Expand Up @@ -509,6 +509,7 @@
"failures": [
"No manifest was fetched"
],
"manifestUrl": null,
"isParseFailure": true,
"parseFailureReason": "No manifest was fetched"
}
Expand Down