diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 4ac18cd509..2e950a0f8d 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -2703,6 +2703,11 @@ mod permissions { output: "run/064_permissions_revoke_global.ts.out", }); + itest!(_065_permissions_revoke_net { + args: "run --allow-net run/065_permissions_revoke_net.ts", + output: "run/065_permissions_revoke_net.ts.out", + }); + #[test] fn _066_prompt() { TestContext::default() diff --git a/cli/tests/testdata/run/065_permissions_revoke_net.ts b/cli/tests/testdata/run/065_permissions_revoke_net.ts new file mode 100644 index 0000000000..40c9d413ab --- /dev/null +++ b/cli/tests/testdata/run/065_permissions_revoke_net.ts @@ -0,0 +1,6 @@ +const status1 = await Deno.permissions.query({ name: "net" }); +console.log(status1); +const status2 = await Deno.permissions.revoke({ name: "net" }); +console.log(status2); +const status3 = await Deno.permissions.query({ name: "net" }); +console.log(status3); diff --git a/cli/tests/testdata/run/065_permissions_revoke_net.ts.out b/cli/tests/testdata/run/065_permissions_revoke_net.ts.out new file mode 100644 index 0000000000..a9c941ecd5 --- /dev/null +++ b/cli/tests/testdata/run/065_permissions_revoke_net.ts.out @@ -0,0 +1,3 @@ +PermissionStatus { state: "granted", onchange: null } +PermissionStatus { state: "prompt", onchange: null } +PermissionStatus { state: "prompt", onchange: null } diff --git a/runtime/permissions/mod.rs b/runtime/permissions/mod.rs index 34d7f0a1b2..cb1af76196 100644 --- a/runtime/permissions/mod.rs +++ b/runtime/permissions/mod.rs @@ -856,7 +856,7 @@ impl UnaryPermission { &mut self, host: Option<&(T, Option)>, ) -> PermissionState { - self.revoke_desc(&Some(NetDescriptor::new(&host.unwrap()))) + self.revoke_desc(&host.map(|h| NetDescriptor::new(&h))) } pub fn check>(