Debian Codegraph @

js/src/jit-test/tests/debug/Frame-script-05.js

raw
1 // Frame.prototype.script for async function frames.
2
3 load(libdir + "asserts.js");
4
5 var g = newGlobal({ newCompartment: true });
6 var dbg = new Debugger(g);
7 g.eval(`
8 async function f() {
9 await Promise.resolve()
10 }
11 `);
12
13 let frame;
14 let script;
15 dbg.onEnterFrame = function(f) {
16 frame = f;
17 script = frame.script;
18 };
19
20 const promise = g.f();
21
22 assertEq(frame instanceof Debugger.Frame, true);
23 assertEq(script instanceof Debugger.Script, true);
24 assertEq(frame.script, script);
25
26 const lastFrame = frame;
27 const lastScript = script;
28 frame = null;
29 script = null;
30
31 promise.then(() => {
32 assertEq(frame, lastFrame);
33 assertEq(script, lastScript);
34
35 // The frame has finished evaluating, so the script is no longer accessible.
36 assertThrowsInstanceOf(() => frame.script, Error);
37 });