Debian Codegraph @

js/src/jit-test/tests/debug/Frame-asyncPromise-03.js

raw
1 // Test the promise property on generator function frames.
2
3 load(libdir + 'asserts.js');
4
5 var g = newGlobal({ newCompartment: true });
6 var dbg = Debugger(g);
7 g.eval(`
8 function* f() {
9 debugger;
10 yield;
11 debugger;
12 }
13 `);
14
15 let frame;
16 const promises = [];
17 dbg.onDebuggerStatement = function(f) {
18 frame = f;
19 promises.push(frame.asyncPromise);
20 };
21
22 const it = g.f();
23
24 assertEq(promises.length, 0);
25
26 it.next();
27
28 assertEq(frame.asyncPromise, undefined);
29
30 assertEq(promises.length, 1);
31 assertEq(promises[0], undefined);
32
33 it.next();
34
35 // Frame has terminated, so accessing the property throws.
36 assertThrowsInstanceOf(() => frame.asyncPromise, Error);
37
38 assertEq(promises.length, 2);
39 assertEq(promises[1], undefined);