diff options
| author | Yoshiya Hinosawa <stibium121@gmail.com> | 2021-10-01 00:25:58 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-01 00:25:58 +0900 |
| commit | f602d63f48067851716d46184746ce26b2e674ba (patch) | |
| tree | 053939263671e61a1147065afb6ed08ffecab93e /cli | |
| parent | 0d7a417f332a57fb3e89250a1ce250b929d0b2f7 (diff) | |
fix(repl): avoid panic when assigned to globalThis (#12273)
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/tests/integration/repl_tests.rs | 11 | ||||
| -rw-r--r-- | cli/tools/repl.rs | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index a8f354598..3dd5699c6 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -135,6 +135,17 @@ fn pty_ignore_symbols() { } #[test] +fn pty_assign_global_this() { + util::with_pty(&["repl"], |mut console| { + console.write_line("globalThis = 42;"); + console.write_line("close();"); + + let output = console.read_all_output(); + assert!(!output.contains("panicked")); + }); +} + +#[test] fn console_log() { let (out, err) = util::run_and_collect_output( true, diff --git a/cli/tools/repl.rs b/cli/tools/repl.rs index 219ee3502..0144db660 100644 --- a/cli/tools/repl.rs +++ b/cli/tools/repl.rs @@ -485,7 +485,7 @@ impl ReplSession { pub async fn is_closing(&mut self) -> Result<bool, AnyError> { let closed = self - .evaluate_expression("(globalThis.closed)") + .evaluate_expression("(this.closed)") .await? .get("result") .unwrap() |
