Skip to content

Commit 5a76796

Browse files
Refactor onerror and similar properties for windows and workers (#102)
`onerror`, `onunhandledrejection`, `onrejectionhandled` and `self` are all properties in the global scope that live in both `Window` and `WorkerGlobalScope`. However, unlike other properties that apply to both windows and workers, these properties are defined separately for windows and for workers. The current spec text deals with them by listing the property name and linking in parenthesis to both definitions in the HTML spec. However, in this edition of the Minimum Common API specification, we don't talk a lot about workers, and we don't require runtimes to implement them. This patch clarifies this by linking to the `Window` definitions in the main list of properties, and adding a paragraph after that that links to the `WorkerGlobalScope` defintions and specifies that runtimes with workers should also support them. Additionally, we remove an issue about exposing `self` on the `ShadowRealmGlobalScope` in the future when whatwg/html#9893 lands, since the ShadowRealm proposal seems to have lost a lot of steam lately. We can always add a similar paragraph to the workers one if it ever picks up pace again.
1 parent cca1cbc commit 5a76796

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

index.bs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,13 @@ All of the following methods and properties MUST be exposed on the global object
107107
* `globalThis.`{{crypto}} [[!WEBCRYPTO]]
108108
* `globalThis.`{{fetch()}} [[!FETCH]]
109109
* `globalThis.`{{navigator}}.{{userAgent}} [[!HTML]]
110-
* `globalThis.onerror` (on {{GlobalEventHandlers/onerror|Window}} and {{WorkerGlobalScope/onerror|WorkerGlobalScope}}) [[!HTML]]
111-
* `globalThis.onunhandledrejection` (on {{WindowEventHandlers/onunhandledrejection|Window}} and {{WorkerGlobalScope/onunhandledrejection|WorkerGlobalScope}}) [[!HTML]]
112-
* `globalThis.onrejectionhandled` (on {{WindowEventHandlers/onrejectionhandled|Window}} and {{WorkerGlobalScope/onrejectionhandled|WorkerGlobalScope}}) [[!HTML]]
110+
* `globalThis.`{{GlobalEventHandlers/onerror}} [[!HTML]]
111+
* `globalThis.`{{WindowEventHandlers/onunhandledrejection}} [[!HTML]]
112+
* `globalThis.`{{WindowEventHandlers/onrejectionhandled}} [[!HTML]]
113113
* `globalThis.`{{performance}} [[!HR-TIME]]
114114
* `globalThis.`{{queueMicrotask()}} [[!HTML]]
115115
* `globalThis.`{{reportError()}} [[!HTML]]
116-
* `globalThis.`self (on {{Window/self|Window}} and {{WorkerGlobalScope/self|WorkerGlobalScope}}) [[!HTML]]
117-
118-
Issue: When the <a href="https://github.com/whatwg/html/pull/9893">ShadowRealm integration PR</a>
119-
is merged into the HTML spec,
120-
`self` will also need to be exposed on `ShadowRealmGlobalScope`.
121-
116+
* `globalThis.`{{Window/self}} [[!HTML]]
122117
* `globalThis.`{{setTimeout()}} [[!HTML]]
123118
* `globalThis.`{{setInterval()}} [[!HTML]]
124119
* `globalThis.`{{structuredClone()}} [[!HTML]]
@@ -129,6 +124,11 @@ All of the following methods and properties MUST be exposed on the global object
129124
* `globalThis.`{{WebAssembly}}.{{WebAssembly/JSTag}} [[!WASM-JS-API-2]]
130125
* `globalThis.`{{WebAssembly}}.{{WebAssembly/validate()}} [[!WASM-JS-API-2]]
131126

127+
Web-interoperable runtimes that support workers MUST also expose {{WorkerGlobalScope/onerror}},
128+
{{WorkerGlobalScope/onunhandledrejection}}, {{WorkerGlobalScope/onrejectionhandled}} and
129+
{{WorkerGlobalScope/self}} on the worker's `globalThis`,
130+
unless otherwise specified in this specification. [[!HTML]]
131+
132132
The Global Scope {#global-scope}
133133
================================
134134

0 commit comments

Comments
 (0)