summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-onPop-generators-05.js
blob: 09d66d7c84a3d85ac4268774c44f393c2ff736da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// In .onPop for the "initial yield" of a generator, while the generator frame
// is on the stack, the generator object's .next() method throws.

let g = newGlobal({newCompartment: true});
g.eval(`
    function* f() {
        return "ok";
    }
`);

let hits = 0;
let dbg = new Debugger;
let gw = dbg.addDebuggee(g);
dbg.onEnterFrame = frame => {
    dbg.onEnterFrame = undefined;  // Trigger only once.
    frame.onPop = completion => {
        // Initial yield.
        let genObj = completion.return;
        assertEq(genObj.class, "Generator");
        let result = frame.evalWithBindings("genObj.next()", {genObj});
        assertEq(result.throw.class, "TypeError");
        assertEq(result.throw.getProperty("message").return,
                 "already executing generator");
        hits++;
    };
};

g.f();
assertEq(hits, 1);