diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-02-13 15:58:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-13 15:58:12 +0100 |
commit | af460fc464562566dc1534c0f61f53c2976b9bd7 (patch) | |
tree | 74ac43e5574711f71d5ee90bbc020740e41bdf69 /op_crates/web/04_global_interfaces.js | |
parent | d2d7dc8d675d70f0061bdaf99ae4a08d84156aa9 (diff) |
fix: webidl utils and align `Event` to spec (#9470)
Diffstat (limited to 'op_crates/web/04_global_interfaces.js')
-rw-r--r-- | op_crates/web/04_global_interfaces.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/op_crates/web/04_global_interfaces.js b/op_crates/web/04_global_interfaces.js new file mode 100644 index 000000000..74697a42e --- /dev/null +++ b/op_crates/web/04_global_interfaces.js @@ -0,0 +1,70 @@ +"use strict"; +((window) => { + const { EventTarget } = window; + + const illegalConstructorKey = Symbol("illegalConstructorKey"); + + class Window extends EventTarget { + constructor(key = null) { + if (key !== illegalConstructorKey) { + throw new TypeError("Illegal constructor."); + } + super(); + } + + get [Symbol.toStringTag]() { + return "Window"; + } + } + + class WorkerGlobalScope extends EventTarget { + constructor(key = null) { + if (key != illegalConstructorKey) { + throw new TypeError("Illegal constructor."); + } + super(); + } + + get [Symbol.toStringTag]() { + return "WorkerGlobalScope"; + } + } + + class DedicatedWorkerGlobalScope extends WorkerGlobalScope { + constructor(key = null) { + if (key != illegalConstructorKey) { + throw new TypeError("Illegal constructor."); + } + super(); + } + + get [Symbol.toStringTag]() { + return "DedicatedWorkerGlobalScope"; + } + } + + window.__bootstrap = (window.__bootstrap || {}); + window.__bootstrap.globalInterfaces = { + DedicatedWorkerGlobalScope, + Window, + WorkerGlobalScope, + dedicatedWorkerGlobalScopeConstructorDescriptor: { + configurable: true, + enumerable: false, + value: DedicatedWorkerGlobalScope, + writable: true, + }, + windowConstructorDescriptor: { + configurable: true, + enumerable: false, + value: Window, + writable: true, + }, + workerGlobalScopeConstructorDescriptor: { + configurable: true, + enumerable: false, + value: WorkerGlobalScope, + writable: true, + }, + }; +})(this); |