You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error and promise rejection events must be fired on the global object (#82)
As decided in the March 6th meeting, this PR specifies that the
`error`, `unhandledrejection` and `rejectionhandled` events are fired
on the global object. It also adds the `ErrorEvent` and
`PromiseRejectionEvent` interfaces, and the `onerror`,
`onunhandledrejection` and `onrejectionhandled` event handler
properties, to the minimum common API list.
This PR also has a note covering the likely case that Node.js will
not support this due to legacy.
* globalThis.onerror (on {{GlobalEventHandlers/onerror|Window}} and {{WorkerGlobalScope/onerror|WorkerGlobalScope}})
101
+
* globalThis.onunhandledrejection (on {{WindowEventHandlers/onunhandledrejection|Window}} and {{WorkerGlobalScope/onunhandledrejection|WorkerGlobalScope}})
102
+
* globalThis.onrejectionhandled (on {{WindowEventHandlers/onrejectionhandled|Window}} and {{WorkerGlobalScope/onrejectionhandled|WorkerGlobalScope}})
@@ -114,6 +119,12 @@ The exact type of the global scope (`globalThis`) can vary across runtimes. Most
114
119
115
120
With many runtimes, adding a new global-scoped property can introduce breaking changes when the new global conflicts with existing application code. Many Web Platform APIs define global properties using the `readonly` attribute. To avoid introducing breaking changes, runtimes conforming to this specification MAY choose to ignore the `readonly` attribute for properties being added to the global scope.
116
121
122
+
The global object on {{Window}}-like and worker environments must always be an instance of {{EventTarget}}. Web-interoperable runtimes must follow the <a>report an exception</a> algorithm, and the JavaScript <a href="https://tc39.es/ecma262/#sec-host-promise-rejection-tracker">HostPromiseRejectionTracker</a> host hook, as defined in [[HTML]]. This includes firing the {{Window/error}}, {{Window/unhandledrejection}} and {{Window/rejectionhandled}} events on the global object.
123
+
124
+
Note: Some runtimes might not support firing those events following the HTML specification exactly due to legacy reasons.
125
+
For example, in Node.js the global object does not implement {{EventTarget}}, and the relevant events are fired on the `process` object with the names `uncaughtException`, `unhandledRejection` and `rejectionHandled`, respectively.
126
+
Such runtimes should not support the {{GlobalEventHandlers/onerror}}, {{WindowEventHandlers/onunhandledrejection}} and {{WindowEventHandlers/onrejectionhandled}} global properties, but they might implement the {{ErrorEvent}} and {{PromiseRejectionEvent}} interfaces.
127
+
117
128
Requirements for navigator.userAgent {#navigator-useragent-requirements}
0 commit comments