blob: 4992ced2aa73acfbe3030039f5141594b6b5a28c (
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
54
55
56
57
58
59
60
61
62
63
|
// Resume execution of async generator when initially yielding.
let g = newGlobal({newCompartment: true});
let dbg = new Debugger();
let gw = dbg.addDebuggee(g);
g.eval(`
async function* f() {
await 123;
return "ponies";
}
`);
let counter = 0;
let thenCalled = false;
dbg.onEnterFrame = frame => {
frame.onPop = completion => {
if (counter++ === 0) {
let genObj = completion.return.unsafeDereference();
// The following call enqueues the request before it becomes
// suspendedStart, that breaks the assumption in the spec,
// and there's no correct interpretation.
genObj.next().then(() => {
thenCalled = true;
});
}
};
};
let it = g.f();
assertEq(counter, 1);
let caught = false;
try {
// The async generator is already in the invalid state, and the following
// call fails.
it.next();
} catch (e) {
caught = true;
}
assertEq(caught, true);
caught = false;
try {
it.throw();
} catch (e) {
caught = true;
}
assertEq(caught, true);
caught = false;
try {
it.return();
} catch (e) {
caught = true;
}
assertEq(caught, true);
drainJobQueue();
assertEq(thenCalled, false);
|