Skip to content

Commit

Permalink
properly throw debug error when page does not include manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Aug 23, 2016
1 parent 5c72d72 commit 6d2ae74
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lighthouse-core/gather/gatherers/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ class Manifest extends Gatherer {
return driver.sendCommand('Page.getAppManifest')
.then(response => {
if (response.errors.length) {
this.artifact = Manifest._errorManifest(response.errors.join(', '));
let errorString;
if (response.url) {
errorString = `Unable to retrieve manifest at ${response.url}: `;
}
this.artifact = Manifest._errorManifest(errorString + response.errors.join(', '));
return;
}

// The driver will return an empty string for url and the data if the
// page has no manifest.
if (!response.data.length && !response.data.url) {
this.artifact = Manifest._errorManifest('No manifest found.');
return;
}

Expand Down
24 changes: 22 additions & 2 deletions lighthouse-core/test/gather/gatherers/manifest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ describe('Manifest gatherer', () => {
return manifestGather.afterPass({
driver: {
sendCommand() {
return Promise.resolve({data: '', errors: [], url: 'https://example.com/manifest.json'});
return Promise.resolve({
data: '{}',
errors: [],
url: 'https://example.com/manifest.json'
});
}
}
}).then(_ => {
Expand Down Expand Up @@ -68,7 +72,23 @@ describe('Manifest gatherer', () => {
}
}
}).then(_ => {
assert.ok(manifestGather.artifact.debugString === error);
assert.notStrictEqual(manifestGather.artifact.debugString.indexOf(error), -1);
});
});

it('emits an error when there was no manifest', () => {
return manifestGather.afterPass({
driver: {
sendCommand() {
return Promise.resolve({
data: '',
errors: [],
url: ''
});
}
}
}).then(_ => {
assert.ok(manifestGather.artifact.debugString);
});
});

Expand Down

0 comments on commit 6d2ae74

Please sign in to comment.