1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-15 11:58:42 -05:00
denoland-deno/cli/tests/testdata/compat/worker/worker_test.mjs
Nayeem Rahman 330c820ae8
BREAKING(unstable): Enable Deno namespace in workers by default (#14581)
This commit removes "WorkerOptions.deno" option as a boolean,
as well as "WorkerOptions.deno.namespace" settings. Starting
with this commit all workers have access to "Deno" namespace
by default.
2022-05-17 22:27:17 +02:00

18 lines
501 B
JavaScript

import { deferred } from "../../../../../test_util/std/async/deferred.ts";
const promise = deferred();
const url = new URL("./worker.mjs", import.meta.url);
const worker = new Worker(url.href, { type: "module" });
worker.onmessage = (e) => {
const pid = e.data.pid;
if (typeof pid != "number") {
throw new Error("pid is not a number");
}
console.log("process.pid from worker:", pid);
promise.resolve();
};
worker.postMessage("hello");
await promise;
worker.terminate();