diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/flags.rs | 38 | ||||
-rw-r--r-- | cli/msg.fbs | 2 | ||||
-rw-r--r-- | cli/ops.rs | 6 | ||||
-rw-r--r-- | cli/permissions.rs | 14 |
4 files changed, 27 insertions, 33 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 95aa341d6..14ec7cd51 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -23,7 +23,7 @@ pub struct DenoFlags { pub net_whitelist: Vec<String>, pub allow_env: bool, pub allow_run: bool, - pub allow_high_precision: bool, + pub allow_hrtime: bool, pub no_prompts: bool, pub no_fetch: bool, pub v8_flags: Option<Vec<String>>, @@ -230,9 +230,9 @@ ability to spawn subprocesses. .long("allow-run") .help("Allow running subprocesses"), ).arg( - Arg::with_name("allow-high-precision") - .long("allow-high-precision") - .help("Allow high precision time measurement"), + Arg::with_name("allow-hrtime") + .long("allow-hrtime") + .help("Allow high resolution time measurement"), ).arg( Arg::with_name("allow-all") .short("A") @@ -377,8 +377,8 @@ pub fn parse_flags(matches: ArgMatches) -> DenoFlags { if run_matches.is_present("allow-run") { flags.allow_run = true; } - if run_matches.is_present("allow-high-precision") { - flags.allow_high_precision = true; + if run_matches.is_present("allow-hrtime") { + flags.allow_hrtime = true; } if run_matches.is_present("allow-all") { flags.allow_read = true; @@ -387,7 +387,7 @@ pub fn parse_flags(matches: ArgMatches) -> DenoFlags { flags.allow_run = true; flags.allow_read = true; flags.allow_write = true; - flags.allow_high_precision = true; + flags.allow_hrtime = true; } if run_matches.is_present("no-prompt") { flags.no_prompts = true; @@ -429,7 +429,7 @@ pub fn flags_from_vec( flags.allow_run = true; flags.allow_read = true; flags.allow_write = true; - flags.allow_high_precision = true; + flags.allow_hrtime = true; let code: &str = eval_match.value_of("code").unwrap(); argv.extend(vec![code.to_string()]); DenoSubcommand::Eval @@ -487,7 +487,7 @@ pub fn flags_from_vec( flags.allow_run = true; flags.allow_read = true; flags.allow_write = true; - flags.allow_high_precision = true; + flags.allow_hrtime = true; let code: &str = eval_match.value_of("code").unwrap(); flags.xeval_replvar = Some(eval_match.value_of("replvar").unwrap_or("$").to_owned()); @@ -505,7 +505,7 @@ pub fn flags_from_vec( flags.allow_run = true; flags.allow_read = true; flags.allow_write = true; - flags.allow_high_precision = true; + flags.allow_hrtime = true; DenoSubcommand::Repl } }; @@ -651,7 +651,7 @@ mod tests { allow_run: true, allow_read: true, allow_write: true, - allow_high_precision: true, + allow_hrtime: true, ..DenoFlags::default() } ); @@ -676,16 +676,12 @@ mod tests { #[test] fn test_flags_from_vec_9() { - let (flags, subcommand, argv) = flags_from_vec(svec![ - "deno", - "run", - "--allow-high-precision", - "script.ts" - ]); + let (flags, subcommand, argv) = + flags_from_vec(svec!["deno", "run", "--allow-hrtime", "script.ts"]); assert_eq!( flags, DenoFlags { - allow_high_precision: true, + allow_hrtime: true, ..DenoFlags::default() } ); @@ -795,7 +791,7 @@ mod tests { allow_run: true, allow_read: true, allow_write: true, - allow_high_precision: true, + allow_hrtime: true, ..DenoFlags::default() } ); @@ -814,7 +810,7 @@ mod tests { allow_run: true, allow_read: true, allow_write: true, - allow_high_precision: true, + allow_hrtime: true, ..DenoFlags::default() } ); @@ -841,7 +837,7 @@ mod tests { allow_run: true, allow_read: true, allow_write: true, - allow_high_precision: true, + allow_hrtime: true, xeval_replvar: Some("val".to_owned()), xeval_delim: Some(" ".to_owned()), ..DenoFlags::default() diff --git a/cli/msg.fbs b/cli/msg.fbs index 9e4bf658e..08e58351c 100644 --- a/cli/msg.fbs +++ b/cli/msg.fbs @@ -298,7 +298,7 @@ table PermissionsRes { write: bool; net: bool; env: bool; - high_precision: bool; + hrtime: bool; } // Note this represents The WHOLE header of an http message, not just the key diff --git a/cli/ops.rs b/cli/ops.rs index 9b5bc0079..bd1132fa3 100644 --- a/cli/ops.rs +++ b/cli/ops.rs @@ -261,7 +261,7 @@ fn op_now( // If the permission is not enabled // Round the nano result on 2 milliseconds // see: https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#Reduced_time_precision - if !state.permissions.allows_high_precision() { + if !state.permissions.allows_hrtime() { subsec_nanos -= subsec_nanos % reduced_time_precision } @@ -640,7 +640,7 @@ fn op_permissions( write: state.permissions.allows_write(), net: state.permissions.allows_net(), env: state.permissions.allows_env(), - high_precision: state.permissions.allows_high_precision(), + hrtime: state.permissions.allows_hrtime(), }, ); ok_future(serialize_response( @@ -668,7 +668,7 @@ fn op_revoke_permission( "write" => state.permissions.revoke_write(), "net" => state.permissions.revoke_net(), "env" => state.permissions.revoke_env(), - "highPrecision" => state.permissions.revoke_high_precision(), + "hrtime" => state.permissions.revoke_hrtime(), _ => Ok(()), }; if let Err(e) = result { diff --git a/cli/permissions.rs b/cli/permissions.rs index a02c6bb07..e2e3e22a4 100644 --- a/cli/permissions.rs +++ b/cli/permissions.rs @@ -135,7 +135,7 @@ pub struct DenoPermissions { pub net_whitelist: Arc<HashSet<String>>, pub allow_env: PermissionAccessor, pub allow_run: PermissionAccessor, - pub allow_high_precision: PermissionAccessor, + pub allow_hrtime: PermissionAccessor, pub no_prompts: AtomicBool, } @@ -152,9 +152,7 @@ impl DenoPermissions { net_whitelist: Arc::new(flags.net_whitelist.iter().cloned().collect()), allow_env: PermissionAccessor::from(flags.allow_env), allow_run: PermissionAccessor::from(flags.allow_run), - allow_high_precision: PermissionAccessor::from( - flags.allow_high_precision, - ), + allow_hrtime: PermissionAccessor::from(flags.allow_hrtime), no_prompts: AtomicBool::new(flags.no_prompts), } } @@ -350,8 +348,8 @@ impl DenoPermissions { self.allow_env.is_allow() } - pub fn allows_high_precision(&self) -> bool { - self.allow_high_precision.is_allow() + pub fn allows_hrtime(&self) -> bool { + self.allow_hrtime.is_allow() } pub fn revoke_run(&self) -> DenoResult<()> { @@ -378,8 +376,8 @@ impl DenoPermissions { self.allow_env.revoke(); Ok(()) } - pub fn revoke_high_precision(&self) -> DenoResult<()> { - self.allow_high_precision.revoke(); + pub fn revoke_hrtime(&self) -> DenoResult<()> { + self.allow_hrtime.revoke(); Ok(()) } } |