Debian Codegraph @

js/src/jit-test/tests/debug/Frame-olderSavedFrame-01.js

raw
1 // An explicit async stack should be available via olderSavedFrame.
2 // This test makes sure that "main" shows up as an async saved frame
3 // instead of "older", even though "drainJobQueue()" is running inside of
4 // "main()" directly.
5
6 var g = newGlobal({ newCompartment: true });
7 var dbg = new Debugger(g);
8 let done = false;
9 dbg.onDebuggerStatement = function (frame) {
10 // This frame has an "olderSavedFrame" because "run()" is an async function
11 // and those have explicit async stacks attached to them.
12 const parent = frame.olderSavedFrame;
13 assertEq(typeof parent.source, "string");
14 assertEq(parent.line, 12);
15 assertEq(parent.column, 3);
16 assertEq(parent.asyncCause, "async");
17 assertEq(parent.functionDisplayName, "main");
18 done = true;
19 };
20
21 g.eval(`
22 let draining = false;
23 async function run() {
24 await Promise.resolve();
25
26 // Make sure that the test is running within "drainJobQueue()".
27 assertEq(draining, true);
28 debugger;
29 }
30
31 (function main() {
32 run();
33
34 // Force resumption of the "run" function.
35 draining = true;
36 drainJobQueue();
37 draining = false;
38 })();
39 `);
40 assertEq(done, true);