1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-15 03:48:02 -05:00
denoland-deno/cli/tests/testdata/run/unstable_worker_options.js

20 lines
486 B
JavaScript
Raw Normal View History

const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main";
new Worker(`data:application/javascript;base64,${btoa(`postMessage("ok");`)}`, {
type: "module",
deno: {
permissions: {
read: true,
},
},
}).onmessage = ({ data }) => {
console.log(scope, data);
if (scope === "main") {
const worker = new Worker(`${import.meta.url}#worker`, { type: "module" });
worker.onmessage = () => Deno.exit(0);
} else {
postMessage("done");
}
};