Truly independent web browser
LibJS: Treat exceptions caught after a `finally` block as handled
Tim Ledbetter8d8cb48fa9b4
diff --git a/Libraries/LibJS/Rust/src/interpreter/run.rs b/Libraries/LibJS/Rust/src/interpreter/run.rsindex 18f41d9c2ee..5931dab08cf 100644--- a/Libraries/LibJS/Rust/src/interpreter/run.rs+++ b/Libraries/LibJS/Rust/src/interpreter/run.rs@@ -616,10 +616,16 @@ impl Vm {previous_context = Some((context.caller_frame.get(), context.caller_return_pc.get()));let executable = Executable::from_head(executable);- let handler = executable.exception_handlers_for_offset(context_program_counter);- if handler.is_some_and(|handler| handler.catches_exception) {- exception_will_be_caught = true;- return ControlFlow::Break(());+ let mut offset = context_program_counter;+ for _ in 0..executable.exception_handlers().len() {+ let Some(handler) = executable.exception_handlers_for_offset(offset) else {+ break;+ };+ if handler.catches_exception {+ exception_will_be_caught = true;+ return ControlFlow::Break(());+ }+ offset = handler.handler_offset;}ControlFlow::Continue(())});diff --git a/Tests/LibJS/Debugger/expected/pause-on-unhandled-exceptions.txt b/Tests/LibJS/Debugger/expected/pause-on-unhandled-exceptions.txtnew file mode 100644index 00000000000..a71efb2aeeb--- /dev/null+++ b/Tests/LibJS/Debugger/expected/pause-on-unhandled-exceptions.txt@@ -0,0 +1,2 @@+Paused at <ladybird>/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.js:1:1 (entry)+Paused at <ladybird>/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.js:11:1 (debugger statement)diff --git a/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.args b/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.argsnew file mode 100644index 00000000000..f956f0dda46--- /dev/null+++ b/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.args@@ -0,0 +1 @@+--pause-on-exceptions unhandleddiff --git a/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.commands b/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.commandsnew file mode 100644index 00000000000..153508010ce--- /dev/null+++ b/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.commands@@ -0,0 +1,2 @@+continue+continuediff --git a/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.js b/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.jsnew file mode 100644index 00000000000..6a015e05af8--- /dev/null+++ b/Tests/LibJS/Debugger/input/pause-on-unhandled-exceptions.js@@ -0,0 +1,11 @@+try {+ try {+ try {+ throw new Error("handled");+ } finally {+ }+ } finally {+ }+} catch {}++debugger;