Debian Codegraph @

js/src/jit-test/tests/debug/Frame-onStep-16.js

raw
1 // Stepping through a function with a return statement should pause on
2 // the closing brace of the function.
3
4 var g = newGlobal({newCompartment: true});
5 var dbg = Debugger(g);
6 var log;
7
8 function test(fnStr) {
9 log = '';
10 g.eval(fnStr);
11
12 dbg.onDebuggerStatement = function(frame) {
13 frame.onStep = function() {
14 let {lineNumber, isEntryPoint} = frame.script.getOffsetLocation(frame.offset);
15 if (isEntryPoint) {
16 log += lineNumber + ' ';
17 }
18 };
19 };
20
21 g.eval("f(23);");
22 }
23
24 test("function f(x) {\n" + // 1
25 " debugger;\n" + // 2
26 " return 23 + x;\n" + // 3
27 "}\n"); // 4
28 assertEq(log, '3 3 4 ');
29
30 test("function f(x) {\n" + // 1
31 " debugger;\n" + // 2
32 " return;\n" + // 3
33 "}\n"); // 4
34 assertEq(log, '3 4 ');