Truly independent web browser
Utilities/js: Add debugger stepping commands
Sam Atkinsdcda444d0b37
diff --git a/Libraries/LibJS/Rust/src/utilities/js.rs b/Libraries/LibJS/Rust/src/utilities/js.rsindex 60d8293e2ef..fe7e33d2b10 100644--- a/Libraries/LibJS/Rust/src/utilities/js.rs+++ b/Libraries/LibJS/Rust/src/utilities/js.rs@@ -793,6 +793,9 @@ fn print_debugger_help() {standard_output::outln(b" print (p) <expression>");standard_output::outln(b" set pause-on-exceptions <none|unhandled|all>");standard_output::outln(b" show pause-on-exceptions");+ standard_output::outln(b" step-into (step, s)");+ standard_output::outln(b" step-out (finish, fin)");+ standard_output::outln(b" step-over (next, n)");}/// warnln() of bytes that need not be UTF-8.@@ -888,6 +891,19 @@ fn run_debugger_prompt(return;}+ if command.is_eof() {+ let resume_mode = match command_name {+ b"step-into" | b"step" | b"s" => Some(ResumeMode::StepInto),+ b"step-out" | b"finish" | b"fin" => Some(ResumeMode::StepOut),+ b"step-over" | b"next" | b"n" => Some(ResumeMode::StepOver),+ _ => None,+ };+ if let Some(resume_mode) = resume_mode {+ debugger.continue_execution(resume_mode);+ return;+ }+ }+if command_name == b"help" && command.is_eof() {print_debugger_help();continue;diff --git a/Tests/LibJS/Debugger/expected/basic.txt b/Tests/LibJS/Debugger/expected/basic.txtindex 69832b4564f..3b11185e3bd 100644--- a/Tests/LibJS/Debugger/expected/basic.txt+++ b/Tests/LibJS/Debugger/expected/basic.txt@@ -9,6 +9,9 @@ Debugger commands:print (p) <expression>set pause-on-exceptions <none|unhandled|all>show pause-on-exceptions+ step-into (step, s)+ step-out (finish, fin)+ step-over (next, n)pause-on-exceptions: nonepause-on-exceptions: unhandledpause-on-exceptions: alldiff --git a/Tests/LibJS/Debugger/expected/stepping.txt b/Tests/LibJS/Debugger/expected/stepping.txtnew file mode 100644index 00000000000..3407c7c51d9--- /dev/null+++ b/Tests/LibJS/Debugger/expected/stepping.txt@@ -0,0 +1,10 @@+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:7:1 (entry)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:2:5 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:4:18 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:8:1 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:2:5 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:4:18 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:9:1 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:2:5 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:4:18 (step)+Paused at <ladybird>/Tests/LibJS/Debugger/input/stepping.js:10:1 (step)diff --git a/Tests/LibJS/Debugger/input/stepping.commands b/Tests/LibJS/Debugger/input/stepping.commandsnew file mode 100644index 00000000000..4b8e722873d--- /dev/null+++ b/Tests/LibJS/Debugger/input/stepping.commands@@ -0,0 +1,10 @@+step-into+step-over+step-out+step+next+finish+s+n+fin+continuediff --git a/Tests/LibJS/Debugger/input/stepping.js b/Tests/LibJS/Debugger/input/stepping.jsnew file mode 100644index 00000000000..2b81dac9d3c--- /dev/null+++ b/Tests/LibJS/Debugger/input/stepping.js@@ -0,0 +1,10 @@+function calculate() {+ let first = 20;+ let second = 22;+ return first + second;+}++calculate();+calculate();+calculate();+calculate();