mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 07:44:48 -05:00
330c820ae8
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.
35 lines
958 B
TypeScript
35 lines
958 B
TypeScript
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
import { assertEquals, deferred } from "./test_util.ts";
|
|
|
|
Deno.test(
|
|
{ permissions: { env: true, read: true } },
|
|
async function workerEnvArrayPermissions() {
|
|
const promise = deferred<boolean[]>();
|
|
|
|
const worker = new Worker(
|
|
new URL(
|
|
"../testdata/workers/env_read_check_worker.js",
|
|
import.meta.url,
|
|
).href,
|
|
{ type: "module", deno: { permissions: { env: ["test", "OTHER"] } } },
|
|
);
|
|
|
|
worker.onmessage = ({ data }) => {
|
|
promise.resolve(data.permissions);
|
|
};
|
|
|
|
worker.postMessage({
|
|
names: ["test", "TEST", "asdf", "OTHER"],
|
|
});
|
|
|
|
const permissions = await promise;
|
|
worker.terminate();
|
|
|
|
if (Deno.build.os === "windows") {
|
|
// windows ignores case
|
|
assertEquals(permissions, [true, true, false, true]);
|
|
} else {
|
|
assertEquals(permissions, [true, false, false, true]);
|
|
}
|
|
},
|
|
);
|