summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/subdir/worker_globals.ts10
-rw-r--r--cli/tests/unit/globals_test.ts8
-rw-r--r--cli/tests/workers_test.ts18
3 files changed, 36 insertions, 0 deletions
diff --git a/cli/tests/subdir/worker_globals.ts b/cli/tests/subdir/worker_globals.ts
new file mode 100644
index 000000000..a9e7efd85
--- /dev/null
+++ b/cli/tests/subdir/worker_globals.ts
@@ -0,0 +1,10 @@
+onmessage = function (): void {
+ postMessage(
+ [
+ self instanceof DedicatedWorkerGlobalScope,
+ self instanceof WorkerGlobalScope,
+ self instanceof EventTarget,
+ ].join(", "),
+ );
+ close();
+};
diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts
index 6c83b1b44..53fafc5b6 100644
--- a/cli/tests/unit/globals_test.ts
+++ b/cli/tests/unit/globals_test.ts
@@ -36,6 +36,14 @@ unitTest(function globalThisEqualsSelf(): void {
assert(globalThis === self);
});
+unitTest(function globalThisInstanceofWindow(): void {
+ assert(globalThis instanceof Window);
+});
+
+unitTest(function globalThisInstanceofEventTarget(): void {
+ assert(globalThis instanceof EventTarget);
+});
+
unitTest(function DenoNamespaceExists(): void {
assert(Deno != null);
});
diff --git a/cli/tests/workers_test.ts b/cli/tests/workers_test.ts
index 395b1da24..06349efa0 100644
--- a/cli/tests/workers_test.ts
+++ b/cli/tests/workers_test.ts
@@ -106,6 +106,24 @@ Deno.test({
});
Deno.test({
+ name: "worker globals",
+ fn: async function (): Promise<void> {
+ const promise = createResolvable();
+ const w = new Worker(
+ new URL("subdir/worker_globals.ts", import.meta.url).href,
+ { type: "module" },
+ );
+ w.onmessage = (e): void => {
+ assertEquals(e.data, "true, true, true");
+ promise.resolve();
+ };
+ w.postMessage("Hello, world!");
+ await promise;
+ w.terminate();
+ },
+});
+
+Deno.test({
name: "worker fetch API",
fn: async function (): Promise<void> {
const promise = createResolvable();