summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/onEnterFrame-async-resumption-01.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/debug/onEnterFrame-async-resumption-01.js')
-rw-r--r--js/src/jit-test/tests/debug/onEnterFrame-async-resumption-01.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/onEnterFrame-async-resumption-01.js b/js/src/jit-test/tests/debug/onEnterFrame-async-resumption-01.js
new file mode 100644
index 0000000000..1f4612147a
--- /dev/null
+++ b/js/src/jit-test/tests/debug/onEnterFrame-async-resumption-01.js
@@ -0,0 +1,35 @@
+// A Debugger can {return:} from the first onEnterFrame for an async function.
+// (The exact behavior is undocumented; we're testing that it doesn't crash.)
+
+ignoreUnhandledRejections();
+
+let g = newGlobal({newCompartment: true});
+g.hit2 = false;
+g.eval(`async function f(x) { await x; return "ponies"; }`);
+
+let dbg = new Debugger;
+let gw = dbg.addDebuggee(g);
+let hits = 0;
+let resumption = undefined;
+dbg.onEnterFrame = frame => {
+ if (frame.type == "call" && frame.callee.name === "f") {
+ frame.onPop = completion => {
+ assertEq(completion.return.isPromise, true);
+ hits++;
+ };
+
+ // If we force-return a generator object here, the caller will receive
+ // a promise object resolved with that generator.
+ resumption = frame.eval(`(function* f2() { hit2 = true; })()`);
+ assertEq(resumption.return.class, "Generator");
+ return resumption;
+ }
+};
+
+let p = g.f(0);
+assertEq(hits, 1);
+assertEq(g.hit2, false);
+let pw = gw.makeDebuggeeValue(p);
+assertEq(pw.isPromise, true);
+assertEq(pw.promiseState, "fulfilled");
+assertEq(pw.promiseValue, resumption.return);