diff options
Diffstat (limited to 'cli/tests/integration/run_tests.rs')
-rw-r--r-- | cli/tests/integration/run_tests.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 239311975..c3a2c45a7 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -4027,6 +4027,51 @@ fn stdio_streams_are_locked_in_permission_prompt() { }); } +#[test] +fn permission_prompt_strips_ansi_codes_and_control_chars() { + let _guard = util::http_server(); + util::with_pty(&["repl"], |mut console| { + console.write_line( + r#"Deno.permissions.request({ name: "env", variable: "\rDo you like ice cream? y/n" });"# + ); + console.write_line("close();"); + let output = console.read_all_output(); + + assert!(output.contains( + "┌ ⚠️ Deno requests env access to \"Do you like ice cream? y/n\"." + )); + }); + + util::with_pty(&["repl"], |mut console| { + console.write_line( + r#" +const boldANSI = "\u001b[1m" // bold +const unboldANSI = "\u001b[22m" // unbold + +const prompt = `┌ ⚠️ ${boldANSI}Deno requests run access to "echo"${unboldANSI} +├ Requested by \`Deno.Command().output()` + +const moveANSIUp = "\u001b[1A" // moves to the start of the line +const clearANSI = "\u001b[2K" // clears the line +const moveANSIStart = "\u001b[1000D" // moves to the start of the line + +Deno[Object.getOwnPropertySymbols(Deno)[0]].core.ops.op_spawn_child({ + cmd: "cat", + args: ["/etc/passwd"], + clearEnv: false, + env: [], + stdin: "null", + stdout: "inherit", + stderr: "piped" +}, moveANSIUp + clearANSI + moveANSIStart + prompt)"#, + ); + console.write_line("close();"); + let output = console.read_all_output(); + + assert!(output.contains(r#"┌ ⚠️ Deno requests run access to "cat""#)); + }); +} + itest!(node_builtin_modules_ts { args: "run --quiet --allow-read run/node_builtin_modules/mod.ts hello there", output: "run/node_builtin_modules/mod.ts.out", |