2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2023-11-10 16:29:09 -05:00
|
|
|
import { assertEquals } from "./test_util.ts";
|
2021-09-30 15:50:59 -04:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(
|
2021-09-30 15:50:59 -04:00
|
|
|
{ permissions: { env: true, read: true } },
|
|
|
|
async function workerEnvArrayPermissions() {
|
2023-11-10 16:29:09 -05:00
|
|
|
const { promise, resolve } = Promise.withResolvers<boolean[]>();
|
2021-09-30 15:50:59 -04:00
|
|
|
|
|
|
|
const worker = new Worker(
|
2022-07-20 10:56:53 -04:00
|
|
|
import.meta.resolve(
|
2021-09-30 15:50:59 -04:00
|
|
|
"../testdata/workers/env_read_check_worker.js",
|
2022-07-20 10:56:53 -04:00
|
|
|
),
|
2022-05-17 16:27:17 -04:00
|
|
|
{ type: "module", deno: { permissions: { env: ["test", "OTHER"] } } },
|
2021-09-30 15:50:59 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
worker.onmessage = ({ data }) => {
|
2023-11-10 16:29:09 -05:00
|
|
|
resolve(data.permissions);
|
2021-09-30 15:50:59 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|