resolved-sequence-extra-ticks.js (1306B)
1 // |reftest| async 2 // Copyright (C) 2020 Rick Waldron. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-promise.race 7 description: Resolution ticks are set in a predictable sequence with extra then calls 8 info: | 9 PerformPromiseRace 10 11 Repeat, 12 Let next be IteratorStep(iteratorRecord). 13 If next is an abrupt completion, set iteratorRecord.[[Done]] to true. 14 ReturnIfAbrupt(next). 15 If next is false, then 16 Set iteratorRecord.[[Done]] to true. 17 Return resultCapability.[[Promise]]. 18 Let nextValue be IteratorValue(next). 19 If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to true. 20 ReturnIfAbrupt(nextValue). 21 Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »). 22 Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], resultCapability.[[Reject]] »). 23 24 flags: [async] 25 includes: [promiseHelper.js] 26 ---*/ 27 28 let a = new Promise(resolve => resolve({})); 29 let sequence = [1]; 30 Promise.all([ 31 Promise.race([a]).then(resolved => { 32 sequence.push(4); 33 }), 34 a.then(() => { 35 sequence.push(3); 36 }).then(() => { 37 sequence.push(5); 38 }), 39 ]).then(() => { 40 assert.sameValue(sequence.length, 5); 41 checkSequence(sequence); 42 }).then($DONE, $DONE); 43 sequence.push(2);