summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/stream/bug-1387503-1.js
blob: a12dc2ad1d1a7514347b9f6821dbc7e17807a184 (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
// |jit-test| skip-if: !this.hasOwnProperty("ReadableStream")
// Test uncatchable error when a stream source's pull() method is called.

// Make `debugger;` raise an uncatchable error.
let g = newGlobal({newCompartment: true});
g.parent = this;
g.hit = false;
g.eval(`
    new Debugger(parent).onDebuggerStatement = _frame => (hit = true, null);
`);

// Create a stream whose pull() method raises an uncatchable error,
// and try reading from it.
let readerCreated = false;
let fnFinished = false;
async function fn() {
    try {
        let stream = new ReadableStream({
            start(controller) {},
            pull(controller) {
                debugger;
            }
        });

        let reader = stream.getReader();
        let p = reader.read();
        readerCreated = true;
        await p;
    } finally {
        fnFinished = true;
    }
}

fn();
drainJobQueue();
assertEq(readerCreated, true);
assertEq(g.hit, true);
assertEq(fnFinished, false);