2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2021-07-06 08:38:12 -04:00
|
|
|
|
|
|
|
// @ts-check
|
|
|
|
/// <reference path="../../core/internal.d.ts" />
|
|
|
|
|
2023-03-08 06:44:54 -05:00
|
|
|
import { EventTarget } from "ext:deno_web/02_event.js";
|
2023-02-07 14:22:46 -05:00
|
|
|
const primordials = globalThis.__bootstrap.primordials;
|
|
|
|
const {
|
|
|
|
Symbol,
|
|
|
|
SymbolToStringTag,
|
|
|
|
TypeError,
|
|
|
|
} = primordials;
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
const illegalConstructorKey = Symbol("illegalConstructorKey");
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class Window extends EventTarget {
|
|
|
|
constructor(key = null) {
|
|
|
|
if (key !== illegalConstructorKey) {
|
|
|
|
throw new TypeError("Illegal constructor.");
|
2020-10-20 00:05:42 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
super();
|
|
|
|
}
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
get [SymbolToStringTag]() {
|
|
|
|
return "Window";
|
2020-10-20 00:05:42 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class WorkerGlobalScope extends EventTarget {
|
|
|
|
constructor(key = null) {
|
|
|
|
if (key != illegalConstructorKey) {
|
|
|
|
throw new TypeError("Illegal constructor.");
|
2020-10-20 00:05:42 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
super();
|
|
|
|
}
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
get [SymbolToStringTag]() {
|
|
|
|
return "WorkerGlobalScope";
|
2020-10-20 00:05:42 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
|
constructor(key = null) {
|
|
|
|
if (key != illegalConstructorKey) {
|
|
|
|
throw new TypeError("Illegal constructor.");
|
2020-10-20 00:05:42 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
super();
|
|
|
|
}
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
get [SymbolToStringTag]() {
|
|
|
|
return "DedicatedWorkerGlobalScope";
|
2020-10-20 00:05:42 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const dedicatedWorkerGlobalScopeConstructorDescriptor = {
|
|
|
|
configurable: true,
|
|
|
|
enumerable: false,
|
|
|
|
value: DedicatedWorkerGlobalScope,
|
|
|
|
writable: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const windowConstructorDescriptor = {
|
|
|
|
configurable: true,
|
|
|
|
enumerable: false,
|
|
|
|
value: Window,
|
|
|
|
writable: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const workerGlobalScopeConstructorDescriptor = {
|
|
|
|
configurable: true,
|
|
|
|
enumerable: false,
|
|
|
|
value: WorkerGlobalScope,
|
|
|
|
writable: true,
|
|
|
|
};
|
2020-10-20 00:05:42 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
export {
|
|
|
|
DedicatedWorkerGlobalScope,
|
|
|
|
dedicatedWorkerGlobalScopeConstructorDescriptor,
|
|
|
|
Window,
|
|
|
|
windowConstructorDescriptor,
|
|
|
|
WorkerGlobalScope,
|
|
|
|
workerGlobalScopeConstructorDescriptor,
|
|
|
|
};
|