1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(permissions): fix panics when revoking net permission (#21388)

fix #21385
This commit is contained in:
liruifengv 2023-12-02 01:45:51 +08:00 committed by GitHub
parent eae82b34d4
commit fc8f060ee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View file

@ -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()

View file

@ -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);

View file

@ -0,0 +1,3 @@
PermissionStatus { state: "granted", onchange: null }
PermissionStatus { state: "prompt", onchange: null }
PermissionStatus { state: "prompt", onchange: null }

View file

@ -856,7 +856,7 @@ impl UnaryPermission<NetDescriptor> {
&mut self,
host: Option<&(T, Option<u16>)>,
) -> PermissionState {
self.revoke_desc(&Some(NetDescriptor::new(&host.unwrap())))
self.revoke_desc(&host.map(|h| NetDescriptor::new(&h)))
}
pub fn check<T: AsRef<str>>(