summaryrefslogtreecommitdiff
path: root/runtime/permissions
diff options
context:
space:
mode:
authorSimon Lecoq <22963968+lowlighter@users.noreply.github.com>2024-10-03 08:28:38 -0400
committerGitHub <noreply@github.com>2024-10-03 12:28:38 +0000
commitda7edf1c0c92dc8b0b746b015da911d5820c64ba (patch)
tree373c51cc7dad6859f9814bb852cd0a58419cb062 /runtime/permissions
parent19a9990f60a7d38137af6239cfa3a7573b883d7d (diff)
fix: don't prompt when using `Deno.permissions.request` with `--no-prompt` (#25811)
Diffstat (limited to 'runtime/permissions')
-rw-r--r--runtime/permissions/lib.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/permissions/lib.rs b/runtime/permissions/lib.rs
index 77038ff2f..efabd0b17 100644
--- a/runtime/permissions/lib.rs
+++ b/runtime/permissions/lib.rs
@@ -476,6 +476,9 @@ impl<TQuery: QueryDescriptor> UnaryPermission<TQuery> {
if state != PermissionState::Prompt {
return state;
}
+ if !self.prompt {
+ return PermissionState::Denied;
+ }
let mut message = String::with_capacity(40);
message.push_str(&format!("{} access", TQuery::flag_name()));
if let Some(desc) = desc {
@@ -3906,7 +3909,8 @@ mod tests {
fn test_request() {
set_prompter(Box::new(TestPrompter));
let parser = TestPermissionDescriptorParser;
- let mut perms: Permissions = Permissions::none_without_prompt();
+ let mut perms: Permissions = Permissions::none_with_prompt();
+ let mut perms_no_prompt: Permissions = Permissions::none_without_prompt();
let read_query =
|path: &str| parser.parse_path_query(path).unwrap().into_read();
let write_query =
@@ -3955,6 +3959,7 @@ mod tests {
assert_eq!(perms.run.query(None), PermissionState::Prompt);
prompt_value.set(false);
assert_eq!(perms.run.request(Some(&run_query)), PermissionState::Granted);
+ assert_eq!(perms_no_prompt.read.request(Some(&read_query("/foo"))), PermissionState::Denied);
};
}