diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/debug/onEnterFrame-async-resumption-07.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/debug/onEnterFrame-async-resumption-07.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/onEnterFrame-async-resumption-07.js b/js/src/jit-test/tests/debug/onEnterFrame-async-resumption-07.js new file mode 100644 index 0000000000..578d93ff99 --- /dev/null +++ b/js/src/jit-test/tests/debug/onEnterFrame-async-resumption-07.js @@ -0,0 +1,62 @@ +// A Debugger can't force-return from the first onEnterFrame for an async generator. + +ignoreUnhandledRejections(); + +let g = newGlobal({newCompartment: true}); +g.eval(`async function* f(x) { await x; return "ponies"; }`); + +let dbg = new Debugger; +dbg.uncaughtExceptionHook = exc => {}; // ignore errors +let gw = dbg.addDebuggee(g); +let hits = 0; +let resumption = undefined; + +dbg.onEnterFrame = frame => { + dbg.onEnterFrame = undefined; + assertEq(frame.type, "call"); + assertEq(frame.callee.name, "f"); + frame.onPop = completion => { + hits++; + }; + + // Try to force-return. It's too early. This results in a call to the + // uncaughtExceptionHook but is otherwise ignored. + return {return: "rainbows"}; +}; +let it = g.f(0); // onPop #1: the initial yield +assertEq(hits, 1); +let p = it.next(); // onPop #2: await x +assertEq(hits, 2); +drainJobQueue(); // onPop #3: return "ponies", #4: the final yield +assertEq(hits, 4); + +let pw = gw.makeDebuggeeValue(p); +assertEq(pw.isPromise, true); +assertEq(pw.promiseState, "fulfilled"); +assertEq(pw.promiseValue.getProperty("value").return, "ponies"); +assertEq(pw.promiseValue.getProperty("done").return, true); + +// ---- + +g.eval(`async function* f2(x) { await x; return "moar ponies"; }`); + +let savedAsyncGen = undefined; +dbg.onEnterFrame = frame => { + dbg.onEnterFrame = undefined; + assertEq(frame.type, "call"); + assertEq(frame.callee.name, "f2"); + frame.onPop = completion => { + if (savedAsyncGen === undefined) { + savedAsyncGen = completion.return; + } + }; +}; +let it2 = g.f2(123); +let p2 = it2.next(); +drainJobQueue(); + +let pw2 = gw.makeDebuggeeValue(p2); +assertEq(pw2.isPromise, true); +assertEq(pw2.promiseState, "fulfilled"); +assertEq(pw2.promiseValue.getProperty("value").return, "moar ponies"); +assertEq(pw2.promiseValue.getProperty("done").return, true); |