capability-resolve-throws-no-close.js (1621B)
1 // Copyright (C) 2019 Leo Balter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-promise.allsettled 5 description: > 6 Iterator is not closed when the "resolve" capability returns an abrupt 7 completion. 8 info: | 9 ... 10 3. Let promiseCapability be ? NewPromiseCapability(C). 11 ... 12 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability). 13 7. If result is an abrupt completion, then 14 a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result). 15 b. IfAbruptRejectPromise(result, promiseCapability). 16 8. Return Completion(result). 17 18 Runtime Semantics: PerformPromiseAllSettled 19 20 ... 21 6. Repeat 22 ... 23 d. If next is false, then 24 ... 25 iii. If remainingElementsCount.[[Value]] is 0, then 26 1. Let valuesArray be CreateArrayFromList(values). 27 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »). 28 29 IfAbruptRejectPromise 30 31 1. IfAbruptRejectPromise(value, capability). 32 features: [Promise.allSettled, Symbol.iterator] 33 ---*/ 34 35 var returnCount = 0; 36 var iter = {}; 37 iter[Symbol.iterator] = function() { 38 return { 39 next() { 40 return { 41 done: true 42 }; 43 }, 44 return() { 45 returnCount += 1; 46 return {}; 47 } 48 }; 49 }; 50 var P = function(executor) { 51 return new Promise(function(_, reject) { 52 executor(function() { 53 throw new Test262Error(); 54 }, reject); 55 }); 56 }; 57 58 P.resolve = function() { 59 throw new Test262Error(); 60 }; 61 62 Promise.allSettled.call(P, iter); 63 64 assert.sameValue(returnCount, 0); 65 66 reportCompare(0, 0);