diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/debug/Object-getPromiseReactions-05.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/Object-getPromiseReactions-05.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Object-getPromiseReactions-05.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Object-getPromiseReactions-05.js b/js/src/jit-test/tests/debug/Object-getPromiseReactions-05.js new file mode 100644 index 0000000000..89fc1fe70b --- /dev/null +++ b/js/src/jit-test/tests/debug/Object-getPromiseReactions-05.js @@ -0,0 +1,48 @@ +// Debugger.Object.prototype.getPromiseReactions reports reaction records +// created by `await` expressions in async generators. + +const g = newGlobal({ newCompartment: true }); +const dbg = new Debugger; +const DOg = dbg.addDebuggee(g); + +g.eval(` + var pResolve, pReject; + var p0 = new Promise((resolve, reject) => { pResolve = resolve; pReject = reject }); + + // In this case, promiseReactions encounters a Debugger.Frame we had already + // associated with the generator, when we hit the debugger statement. + async function* f1() { debugger; await p0; } + + // In this case, promiseReactions must construct the Debugger.Frame itself, + // since it is the first to encounter the generator. + async function* f2() { await p0; debugger; } +`); + +let DFf1, DFf2; +dbg.onDebuggerStatement = (frame) => { + DFf1 = frame; + dbg.onDebuggerStatement = (frame) => { + DFf2 = frame; + dbg.onDebuggerStatement = () => { throw "Shouldn't fire twice"; }; + }; +}; + +g.eval(`var p1 = f1().next();`); +assertEq(DFf1.callee.name, "f1"); + +g.eval(`var p2 = f2().next();`); +assertEq(DFf2, undefined); + +const [DOp0, DOp1, DOp2] = + [g.p0, g.p1, g.p2].map(p => DOg.makeDebuggeeValue(p)); + +const reactions = DOp0.getPromiseReactions(); +assertEq(reactions.length, 2); +assertEq(reactions[0], DFf1); +assertEq(true, reactions[1] instanceof Debugger.Frame); + +// Let f2 run until it hits its debugger statement. +g.pResolve(42); +drainJobQueue(); +assertEq(DFf2.terminated, true); +assertEq(reactions[1], DFf2); |