1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-04 17:18:23 -05:00
denoland-deno/tests/specs/bench/allow_all/allow_all.ts
Luca Casonato 5cf97f539b
BREAKING(permissions): remove --allow-hrtime (#25367)
Remove `--allow-hrtime` and `--deny-hrtime`. We are doing this because
it is already possible to get access to high resolution timers through
workers and SharedArrayBuffer.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-09-03 11:24:25 +02:00

42 lines
858 B
TypeScript

import { assertEquals } from "jsr:@std/assert";
const permissions: Deno.PermissionName[] = [
"read",
"write",
"net",
"env",
"run",
"ffi",
];
for (const name of permissions) {
Deno.bench({
name: `${name} false`,
permissions: {
[name]: false,
},
async fn() {
for await (const n of permissions) {
const status = await Deno.permissions.query({ name: n });
assertEquals(status.state, "prompt");
}
},
});
Deno.bench({
name: `${name} true`,
permissions: {
[name]: true,
},
async fn() {
for await (const n of permissions) {
const status = await Deno.permissions.query({ name: n });
if (n === name) {
assertEquals(status.state, "granted");
} else {
assertEquals(status.state, "prompt");
}
}
},
});
}