Debian Codegraph @

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

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