invoke-resolve-error-close.js (1093B)
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 /*--- 5 description: > 6 Explicit iterator closing in response to error 7 esid: sec-promise.allsettled 8 info: | 9 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability). 10 7. If result is an abrupt completion, then 11 a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result). 12 b. IfAbruptRejectPromise(result, promiseCapability). 13 14 Runtime Semantics: PerformPromiseAllSettled 15 16 6. Repeat 17 ... 18 i. Let nextPromise be ? Invoke(constructor, "resolve", « nextValue »). 19 features: [Promise.allSettled, Symbol.iterator] 20 ---*/ 21 22 var iterDoneSpy = {}; 23 var callCount = 0; 24 iterDoneSpy[Symbol.iterator] = function() { 25 return { 26 next() { 27 return { 28 value: null, 29 done: false 30 }; 31 }, 32 return() { 33 callCount += 1; 34 } 35 }; 36 }; 37 38 Promise.resolve = function() { 39 throw new Error(); 40 }; 41 42 Promise.allSettled(iterDoneSpy); 43 44 assert.sameValue(callCount, 1); 45 46 reportCompare(0, 0);