diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-01-07 18:06:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 19:06:08 +0100 |
commit | e61e81eb57351782862aa50775ce4348f10b1856 (patch) | |
tree | 6099aa60857f586774a195034f18ac1fb10ca519 /cli/tests/workers_test.ts | |
parent | c347dfcd565c3a396ae84dff46e7374851913462 (diff) |
feat: add --location=<href> and globalThis.location (#7369)
Diffstat (limited to 'cli/tests/workers_test.ts')
-rw-r--r-- | cli/tests/workers_test.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cli/tests/workers_test.ts b/cli/tests/workers_test.ts index c35ea72f5..9cbc864bd 100644 --- a/cli/tests/workers_test.ts +++ b/cli/tests/workers_test.ts @@ -614,3 +614,41 @@ Deno.test("Worker with disabled permissions", async function () { await promise; worker.terminate(); }); + +Deno.test({ + name: "worker location", + fn: async function (): Promise<void> { + const promise = deferred(); + const workerModuleHref = + new URL("subdir/worker_location.ts", import.meta.url).href; + const w = new Worker(workerModuleHref, { type: "module" }); + w.onmessage = (e): void => { + assertEquals(e.data, workerModuleHref); + promise.resolve(); + }; + w.postMessage("Hello, world!"); + await promise; + w.terminate(); + }, +}); + +Deno.test({ + name: "worker with relative specifier", + fn: async function (): Promise<void> { + // TODO(nayeemrmn): Add `Location` and `location` to `dlint`'s globals. + // deno-lint-ignore no-undef + assertEquals(location.href, "http://127.0.0.1:4545/cli/tests/"); + const promise = deferred(); + const w = new Worker( + "./workers/test_worker.ts", + { type: "module", name: "tsWorker" }, + ); + w.onmessage = (e): void => { + assertEquals(e.data, "Hello, world!"); + promise.resolve(); + }; + w.postMessage("Hello, world!"); + await promise; + w.terminate(); + }, +}); |