summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/lib/stepping.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/lib/stepping.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/lib/stepping.js')
-rw-r--r--js/src/jit-test/lib/stepping.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/src/jit-test/lib/stepping.js b/js/src/jit-test/lib/stepping.js
new file mode 100644
index 0000000000..e9a47cd4f3
--- /dev/null
+++ b/js/src/jit-test/lib/stepping.js
@@ -0,0 +1,32 @@
+// Test that stepping through a function stops at the expected lines.
+// `script` is a string, some JS code that evaluates to a function.
+// `expected` is the array of line numbers where stepping is expected to stop
+// when we call the function.
+function testStepping(script, expected) {
+ let g = newGlobal({newCompartment: true});
+ let f = g.eval(script);
+
+ let log = [];
+ function maybePause(frame) {
+ let previousLine = log[log.length - 1]; // note: may be undefined
+ let line = frame.script.getOffsetLocation(frame.offset).lineNumber;
+ if (line !== previousLine)
+ log.push(line);
+ }
+
+ let dbg = new Debugger(g);
+ dbg.onEnterFrame = frame => {
+ // Log this pause (before the first instruction of the function).
+ maybePause(frame);
+
+ // Log future pauses in the same stack frame.
+ frame.onStep = function() { maybePause(this); };
+
+ // Now disable this hook so that we step over function calls, not into them.
+ dbg.onEnterFrame = undefined;
+ };
+
+ f();
+
+ assertEq(log.join(","), expected.join(","));
+}