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(errors-in-console): If exception info is not present use exception text #4191

Merged
merged 2 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 32 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,36 @@ 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);
// url is undefined
assert.strictEqual(auditResult.details.items[0][0].text, 'http://example.com/fancybox.js');
// text is undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure what these two comments are, isn't text defined here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes I did, it happens when a syntax error occurred on the page.

{
   "timestamp":1515451440948.461,
   "exceptionDetails":{
      "exceptionId":1,
      "text":"Uncaught SyntaxError: Unexpected token ,",
      "lineNumber":3180,
      "columnNumber":302,
      "scriptId":"56",
      "url":"https://enterprise.efax.com/",
      "stackTrace":{
         "callFrames":[
            {
               "functionName":"prop",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":22254
            },
            {
               "functionName":"access",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":6743
            },
            {
               "functionName":"prop",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":18120
            },
            {
               "functionName":"",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":88,
               "columnNumber":274
            },
            {
               "functionName":"each",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":5254
            },
            {
               "functionName":"each",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":2010
            },
            {
               "functionName":"b",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":88,
               "columnNumber":190
            },
            {
               "functionName":"",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":89,
               "columnNumber":472
            },
            {
               "functionName":"c",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":7854
            },
            {
               "functionName":"fireWith",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":8655
            },
            {
               "functionName":"ready",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":3263
            },
            {
               "functionName":"H",
               "scriptId":"32",
               "url":"https://d9jmv9u00p0mv.cloudfront.net/js/10015692-10015098.js",
               "lineNumber":8,
               "columnNumber":692
            }
         ]
      }
   }
}

assert.strictEqual(auditResult.details.items[0][1].text,
'TypeError: Cannot read property \'msie\' of undefined');
});
});