invoke-then-get-error-close.js (1185B)
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 description: > 5 Error thrown when accesing the instance's `then` method (closing iterator) 6 esid: sec-promise.allsettled 7 info: | 8 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability). 9 7. If result is an abrupt completion, then 10 a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result). 11 b. IfAbruptRejectPromise(result, promiseCapability). 12 13 Runtime Semantics: PerformPromiseAllSettled 14 15 z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »). 16 features: [Promise.allSettled, Symbol.iterator] 17 ---*/ 18 19 var promise = new Promise(function() {}); 20 var returnCount = 0; 21 var iter = {}; 22 iter[Symbol.iterator] = function() { 23 return { 24 next() { 25 return { 26 done: false, 27 value: promise 28 }; 29 }, 30 return() { 31 returnCount += 1; 32 return {}; 33 } 34 }; 35 }; 36 37 Object.defineProperty(promise, 'then', { 38 get() { 39 throw new Test262Error(); 40 } 41 }); 42 43 Promise.allSettled(iter); 44 45 assert.sameValue(returnCount, 1); 46 47 reportCompare(0, 0);