Debian Codegraph @

js/src/jit-test/tests/promise/settle-now-breaks-all-invariants-3.js

raw
1 // Test we don't assert when the promise is settled and the SpeciesConstructor
2 // call in Promise.prototype.then throws an exception.
3
4 function newPromiseCapability() {
5 var resolve, reject, promise = new Promise(function(r1, r2) {
6 resolve = r1;
7 reject = r2;
8 });
9 return {promise, resolve, reject};
10 }
11
12
13 var {promise, resolve} = newPromiseCapability();
14
15 var p = Promise.resolve(0);
16
17 p.constructor = {
18 [Symbol.species]: function() {
19 // Settle the promise in the SpeciesConstructor call.
20 settlePromiseNow(promise);
21
22 throw new Error();
23 }
24 };
25
26 // Enqueue a PromiseResolveThenableJob.
27 resolve(p);