diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-10-11 23:04:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 09:04:43 +1100 |
commit | 5f3028af13c25fb3af8f36d3d5913ef0688e5ce7 (patch) | |
tree | d997dc40bb558345fa490eaa04730c629c5275f8 /cli/tests | |
parent | 265a9fb9323a11067b4b826acc7624f2e62f1102 (diff) |
fix(cli/rt/main): Add global interface objects (#7875)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/subdir/worker_globals.ts | 10 | ||||
-rw-r--r-- | cli/tests/unit/globals_test.ts | 8 | ||||
-rw-r--r-- | cli/tests/workers_test.ts | 18 |
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(); |