resolved-sequence-extra-ticks.js (1468B)
1 // |reftest| async 2 // Copyright (C) 2019 Leo Balter. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-promise.allsettled 7 description: Resolution ticks are set in a predictable sequence with extra then calls 8 info: | 9 Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability ) 10 11 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }. 12 ... 13 6.d ... 14 ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1. 15 iii. If remainingElementsCount.[[value]] is 0, then 16 1. Let valuesArray be CreateArrayFromList(values). 17 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »). 18 ... 19 flags: [async] 20 includes: [promiseHelper.js] 21 features: [Promise.allSettled] 22 ---*/ 23 24 var sequence = []; 25 26 var p1 = new Promise(function(resolve) { 27 resolve({}); 28 }); 29 30 sequence.push(1); 31 32 Promise.allSettled([p1]).then(function(resolved) { 33 sequence.push(4); 34 assert.sameValue(sequence.length, 4); 35 checkSequence(sequence, 'Expected Promise.allSettled().then to queue second'); 36 }).catch($DONE); 37 38 p1.then(function() { 39 sequence.push(3); 40 assert.sameValue(sequence.length, 3); 41 checkSequence(sequence, 'Expected p1.then to queue first'); 42 }).then(function() { 43 sequence.push(5); 44 assert.sameValue(sequence.length, 5); 45 checkSequence(sequence, 'Expected final then to queue last'); 46 }).then($DONE, $DONE); 47 48 sequence.push(2);