Debian Codegraph @

js/src/jit-test/tests/debug/Frame-onPop-23.js

raw
1 // Check that the line number reported at an onPop stop makes sense,
2 // even when it happens on an "artificial" instruction.
3
4 var g = newGlobal({newCompartment: true});
5
6 // This bit of code arranges for the line number of the "artificial"
7 // instruction to be something nonsensical -- the middle of a loop
8 // which cannot be entered.
9 g.eval(`function f() {
10 debugger; // +0
11 if(false) { // +1
12 for(var b=0; b<0; b++) { // +2
13 c = 2; // +3
14 } // +4
15 } // +5
16 } // +6
17 `);
18
19 var dbg = Debugger(g);
20
21 let debugLine;
22 let foundLine;
23
24 dbg.onDebuggerStatement = function(frame) {
25 debugLine = frame.script.getOffsetLocation(frame.offset).lineNumber;
26 frame.onPop = function(c) {
27 foundLine = this.script.getOffsetLocation(this.offset).lineNumber;
28 };
29 };
30
31 g.eval("f();\n");
32
33 // The stop should happen on the closing brace of the function.
34 assertEq(foundLine == debugLine + 6, true);