summaryrefslogtreecommitdiff
path: root/cli/tests/workers_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/workers_test.ts')
-rw-r--r--cli/tests/workers_test.ts38
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();
+ },
+});