mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
fix(permissions): fix panics when revoking net permission (#21388)
fix #21385
This commit is contained in:
parent
eae82b34d4
commit
fc8f060ee3
4 changed files with 15 additions and 1 deletions
|
@ -2703,6 +2703,11 @@ mod permissions {
|
||||||
output: "run/064_permissions_revoke_global.ts.out",
|
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]
|
#[test]
|
||||||
fn _066_prompt() {
|
fn _066_prompt() {
|
||||||
TestContext::default()
|
TestContext::default()
|
||||||
|
|
6
cli/tests/testdata/run/065_permissions_revoke_net.ts
vendored
Normal file
6
cli/tests/testdata/run/065_permissions_revoke_net.ts
vendored
Normal 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);
|
3
cli/tests/testdata/run/065_permissions_revoke_net.ts.out
vendored
Normal file
3
cli/tests/testdata/run/065_permissions_revoke_net.ts.out
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
PermissionStatus { state: "granted", onchange: null }
|
||||||
|
PermissionStatus { state: "prompt", onchange: null }
|
||||||
|
PermissionStatus { state: "prompt", onchange: null }
|
|
@ -856,7 +856,7 @@ impl UnaryPermission<NetDescriptor> {
|
||||||
&mut self,
|
&mut self,
|
||||||
host: Option<&(T, Option<u16>)>,
|
host: Option<&(T, Option<u16>)>,
|
||||||
) -> PermissionState {
|
) -> PermissionState {
|
||||||
self.revoke_desc(&Some(NetDescriptor::new(&host.unwrap())))
|
self.revoke_desc(&host.map(|h| NetDescriptor::new(&h)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check<T: AsRef<str>>(
|
pub fn check<T: AsRef<str>>(
|
||||||
|
|
Loading…
Reference in a new issue