feat(GlobalErrors): Route unhandledrejections to onerror

Fixes #1777
This commit is contained in:
johnjbarton
2020-01-14 09:38:59 -08:00
parent 8a5216401f
commit 1545112744
2 changed files with 47 additions and 0 deletions

View File

@@ -63,8 +63,25 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
var originalHandler = global.onerror;
global.onerror = onerror;
var browserRejectionHandler = function browserRejectionHandler(event) {
onerror('Unhandled Rejection: ' + event.reason);
};
if (global.addEventListener) {
global.addEventListener(
'unhandledrejection',
browserRejectionHandler
);
}
this.uninstall = function uninstall() {
global.onerror = originalHandler;
if (global.removeEventListener) {
global.removeEventListener(
'unhandledrejection',
browserRejectionHandler
);
}
};
}
};