From c1eba16b84c5bba4f7fdf05beb6ccf5e0fd1da16 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 15 Mar 2023 21:41:13 -0400 Subject: fix(repl): do not panic deleting `Deno` or deleting all its properties (#18211) Closes #18194 Closes #12092 --- cli/tests/integration/repl_tests.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'cli/tests/integration/repl_tests.rs') diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index efbde55c3..aafb3bb48 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -222,6 +222,36 @@ fn pty_assign_global_this() { }); } +#[test] +fn pty_assign_deno_keys_and_deno() { + util::with_pty(&["repl"], |mut console| { + console.write_line( + "Object.keys(Deno).forEach((key)=>{try{Deno[key] = undefined} catch {}})", + ); + console.write_line("delete globalThis.Deno"); + console.write_line("console.log('testing ' + 'this out')"); + console.write_line("close();"); + + let output = console.read_all_output(); + assert_not_contains!(output, "panicked"); + assert_contains!(output, "testing this out"); + }); +} + +#[test] +fn pty_internal_repl() { + util::with_pty(&["repl"], |mut console| { + console.write_line("globalThis"); + console.write_line("__\t\t"); + console.write_line("close();"); + let output = console.read_all_output(); + assert_contains!(output, "__defineGetter__"); + // should not contain the internal repl variable + // in the `globalThis` or completions output + assert_not_contains!(output, "__DENO_"); + }); +} + #[test] fn pty_emoji() { // windows was having issues displaying this -- cgit v1.2.3