summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/promise/settle-now-breaks-all-invariants-1.js
blob: 940adf660d3b053d037bcd06eb4074593eda16b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Test we don't assert when the promise is settled after enqueuing a PromiseReactionJob.

function newPromiseCapability() {
    var resolve, reject, promise = new Promise(function(r1, r2) {
        resolve = r1;
        reject = r2;
    });
    return {promise, resolve, reject};
}


var {promise, resolve} = newPromiseCapability();

var p = Promise.resolve(0);

// Enqueue a PromiseResolveThenableJob followed by a PromiseReactionJob.
resolve(p);

// The PromiseReactionJob expects a pending promise, but this settlePromiseNow
// call will already have settled the promise.
settlePromiseNow(promise);