Commit 3b073c15 authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Login screen: Fix JS exception in window.onerror

Fix the window.onerror handler, added by the Login Screen cr_ui.js code,
to avoid throwing a new exception on its own.

Before this CL, the onerror handler was written to assume that the
|error| parameter is non-null and has the |stack| property. But in some
cases this doesn't hold - there are some standard-defined cases when the
|error| is passed as null, and the only passed information is
|message|=="Script error." (for example, this happens when the error
occured in a script loaded from a different origin). In this case the
old onerror handler was itself throwing this new exception:

  Uncaught TypeError: Cannot read property 'stack' of null
    at window.onerror (oobe.js:7771)

This CL fixes this by adding a check into the onerror handler. We can't
log any additional information in this case anyway, so we'll just
silently exit from onerror in this case.

Bug: none
Change-Id: I535f378332af5484a2b6b490db554105861e30a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1623086Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov <antrim@chromium.org>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662131}
parent 085bbd1a
...@@ -428,6 +428,7 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -428,6 +428,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Install a global error handler so stack traces are included in logs. // Install a global error handler so stack traces are included in logs.
window.onerror = function(message, file, line, column, error) { window.onerror = function(message, file, line, column, error) {
console.error(error.stack); if (error && error.stack)
console.error(error.stack);
}; };
})(); })();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment