diff --git a/cli/tests/unit/permissions_test.ts b/cli/tests/unit/permissions_test.ts index 458ef2f28e..551e9bdcd8 100644 --- a/cli/tests/unit/permissions_test.ts +++ b/cli/tests/unit/permissions_test.ts @@ -86,3 +86,11 @@ Deno.test(async function permissionDescriptorValidation() { } } }); + +// Regression test for https://github.com/denoland/deno/issues/15894. +Deno.test(async function permissionStatusObjectsNotEqual() { + assert( + await Deno.permissions.query({ name: "env", variable: "A" }) != + await Deno.permissions.query({ name: "env", variable: "B" }), + ); +}); diff --git a/runtime/js/10_permissions.js b/runtime/js/10_permissions.js index af66c9d2e9..2573816dfb 100644 --- a/runtime/js/10_permissions.js +++ b/runtime/js/10_permissions.js @@ -122,12 +122,18 @@ function cache(desc, state) { let { name: key } = desc; if ( - (desc.name === "read" || desc.name === "write") && + (desc.name === "read" || desc.name === "write" || desc.name === "ffi") && ReflectHas(desc, "path") ) { - key += `-${desc.path}`; + key += `-${desc.path}&`; } else if (desc.name === "net" && desc.host) { - key += `-${desc.host}`; + key += `-${desc.host}&`; + } else if (desc.name === "run" && desc.command) { + key += `-${desc.command}&`; + } else if (desc.name === "env" && desc.variable) { + key += `-${desc.variable}&`; + } else { + key += "$"; } if (MapPrototypeHas(statusCache, key)) { const status = MapPrototypeGet(statusCache, key);