blob: f79f485fafddc81a321a1e4912ab78e82ea71916 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Generator/async frames can be created by following .older.
//
// The goal here is to get some test coverage creating generator Frame objects
// at some time other than when firing onEnterFrame. Here they're created after
// the initial yield.
let g = newGlobal({newCompartment: true});
g.eval(`
function f() {
debugger;
}
function* gen() {
f();
yield 1;
f();
}
function* genDefaults(x=f()) {
f();
}
async function af() {
f();
await 1;
f();
}
async function afDefaults(x=f()) {
await 1;
f();
}
`);
function test(expected, code) {
let dbg = Debugger(g);
let hits = 0;
let genFrame = null;
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("genDefaults", "for (var x of genDefaults()) {}");
test("af", "af(); drainJobQueue();");
test("afDefaults", "afDefaults(); drainJobQueue();")
|