diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2022-04-19 09:59:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-19 10:59:51 +0200 |
commit | c30d95f2e36cb3519e1e23c0934b388ebba6bc2c (patch) | |
tree | f34db42cce4803e76affb12ccb95ad59a77354ad /ext/web/02_event.js | |
parent | a64e63c3614b98aa2b51fb6b7ef4e30251e03111 (diff) |
feat(ext/web): add globalThis.reportError() (#13799)
Diffstat (limited to 'ext/web/02_event.js')
-rw-r--r-- | ext/web/02_event.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/web/02_event.js b/ext/web/02_event.js index 677768ac9..06df6429c 100644 --- a/ext/web/02_event.js +++ b/ext/web/02_event.js @@ -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, |