summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/ReadableStream/closed-is-handled.js
blob: 276cfbbaff64532a489e20f3960974ee934d8e20 (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
// |reftest| skip-if(!this.ReadableStream||!this.drainJobQueue)

// 3.5.6. ReadableStreamError ( stream, e ) nothrow
//
// 9. Reject reader.[[closedPromise]] with e.
// 10. Set reader.[[closedPromise]].[[PromiseIsHandled]] to true.
//
// Rejection for [[closedPromise]] shouldn't be reported as unhandled.

const rs = new ReadableStream({
  start() {
    return Promise.reject(new Error("test"));
  }
});

let rejected = false;
rs.getReader().read().then(() => {}, () => { rejected = true; });

drainJobQueue();

assertEq(rejected, true);

if (typeof reportCompare === 'function') {
  reportCompare(0, 0);
}

// Shell itself reports unhandled rejection if there's any.