diff options
Diffstat (limited to 'js/src/jit-test/tests/debug/Frame-older-generators-02.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Frame-older-generators-02.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Frame-older-generators-02.js b/js/src/jit-test/tests/debug/Frame-older-generators-02.js new file mode 100644 index 0000000000..f677bf64a8 --- /dev/null +++ b/js/src/jit-test/tests/debug/Frame-older-generators-02.js @@ -0,0 +1,50 @@ +// Like Frame-older-generators-01.js, but attach the debugger on the fly. +// +// (That is, check that it works even if the debugger never received +// onNewGenerator for the generator, because it wasn't attached at the time.) + +let g = newGlobal({newCompartment: true}); +g.eval(` + function f() { + attach(); + debugger; + } + function* gen() { + f(); + yield 1; + f(); + } + async function af() { + f(); + await 1; + f(); + } +`); + +function test(expected, code) { + let dbg; + let hits = 0; + let genFrame = null; + + g.attach = () => { + if (dbg === undefined) { + dbg = Debugger(g); + dbg.onDebuggerStatement = frame => { + hits++; + assertEq(frame.callee.name, "f"); + if (genFrame === null) { + genFrame = frame.older; + } else { + assertEq(frame.older, genFrame); + } + assertEq(genFrame.callee.name, expected); + }; + } + }; + g.eval(code); + assertEq(hits, 2); + dbg.removeDebuggee(g); +} + +test("gen", "for (var x of gen()) {}"); +test("af", "af(); drainJobQueue();"); |