feat(ext/web): add globalThis.reportError() (#13799)

This commit is contained in:
Nayeem Rahman 2022-04-19 09:59:51 +01:00 committed by GitHub
parent a64e63c361
commit c30d95f2e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 93 additions and 17 deletions

View file

@ -1367,6 +1367,20 @@
reportExceptionStackedCalls--;
}
function checkThis(thisArg) {
if (thisArg !== null && thisArg !== undefined && thisArg !== globalThis) {
throw new TypeError("Illegal invocation");
}
}
// https://html.spec.whatwg.org/#dom-reporterror
function reportError(error) {
checkThis(this);
const prefix = "Failed to call 'reportError'";
webidl.requiredArguments(arguments.length, 1, { prefix });
reportException(error);
}
window.Event = Event;
window.EventTarget = EventTarget;
window.ErrorEvent = ErrorEvent;
@ -1377,6 +1391,7 @@
window.dispatchEvent = EventTarget.prototype.dispatchEvent;
window.addEventListener = EventTarget.prototype.addEventListener;
window.removeEventListener = EventTarget.prototype.removeEventListener;
window.reportError = reportError;
window.__bootstrap.eventTarget = {
EventTarget,
setEventTargetData,