Skip to content

Commit

Permalink
core(errors-in-console): If exception info is not present use excepti…
Browse files Browse the repository at this point in the history
…on text (#4191)
  • Loading branch information
wardpeet authored and paulirish committed Jan 8, 2018
1 parent b583a31 commit 0ea37de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lighthouse-core/audits/errors-in-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ class ErrorLogs extends Audit {
const runtimeExRows =
runtimeExceptions.filter(entry => entry.exceptionDetails !== undefined)
.map(entry => {
const description = entry.exceptionDetails.exception ?
entry.exceptionDetails.exception.description : entry.exceptionDetails.text;

return {
source: 'Runtime.exception',
description: entry.exceptionDetails.exception.description,
description,
url: entry.exceptionDetails.url,
};
});
Expand Down
30 changes: 30 additions & 0 deletions lighthouse-core/test/audits/errors-in-console-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,34 @@ describe('Console error logs audit', () => {
// text is undefined
assert.strictEqual(auditResult.details.items[0][1].text, undefined);
});

// Checks bug #4188
it('handle the case when exception info is not present', () => {
const auditResult = ErrorLogsAudit.audit({
ChromeConsoleMessages: [],
RuntimeExceptions: [{
'timestamp': 1506535813608.003,
'exceptionDetails': {
'url': 'http://example.com/fancybox.js',
'text': 'TypeError: Cannot read property \'msie\' of undefined',
'stackTrace': {
'callFrames': [
{
'url': 'http://example.com/fancybox.js',
'lineNumber': 28,
'columnNumber': 20,
},
],
},
'executionContextId': 3,
},
}],
});
assert.equal(auditResult.rawValue, 1);
assert.equal(auditResult.score, false);
assert.equal(auditResult.details.items.length, 1);
assert.strictEqual(auditResult.details.items[0][0].text, 'http://example.com/fancybox.js');
assert.strictEqual(auditResult.details.items[0][1].text,
'TypeError: Cannot read property \'msie\' of undefined');
});
});

0 comments on commit 0ea37de

Please sign in to comment.