From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/debug/Frame-onStep-04.js | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/src/jit-test/tests/debug/Frame-onStep-04.js (limited to 'js/src/jit-test/tests/debug/Frame-onStep-04.js') diff --git a/js/src/jit-test/tests/debug/Frame-onStep-04.js b/js/src/jit-test/tests/debug/Frame-onStep-04.js new file mode 100644 index 0000000000..fb2d6f49e4 --- /dev/null +++ b/js/src/jit-test/tests/debug/Frame-onStep-04.js @@ -0,0 +1,34 @@ +// When a recursive function has many frames on the stack, onStep may be set or +// not independently on each frame. + +var g = newGlobal({newCompartment: true}); +g.eval("function f(x) {\n" + + " if (x > 0)\n" + + " f(x - 1);\n" + + " else\n" + + " debugger;\n" + + " return x;\n" + + "}"); + +var dbg = Debugger(g); +var seen = [0, 0, 0, 0, 0, 0, 0, 0]; +function step() { + seen[this.arguments[0]] = 1; +} +dbg.onEnterFrame = function (frame) { + // Turn on stepping for even-numbered frames. + var x = frame.arguments[0]; + if (x % 2 === 0) + frame.onStep = step; +}; +dbg.onDebuggerStatement = function (frame) { + // This is called with 8 call frames on the stack, 7 down to 0. + // At this point we should have seen all the even-numbered frames. + assertEq(seen.join(""), "10101010"); + + // Now reset seen to see which frames fire onStep on the way out. + seen = [0, 0, 0, 0, 0, 0, 0, 0]; +}; + +g.f(7); +assertEq(seen.join(""), "10101010"); -- cgit v1.2.3