iter-step-err-no-close.js (1505B)
1 // |reftest| async 2 // Copyright (C) 2019 Leo Balter, 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.any 7 description: > 8 Error when advancing the provided iterable (not closing iterator) 9 info: | 10 Promise.any ( iterable ) 11 12 5. Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability). 13 6. 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 17 Runtime Semantics: PerformPromiseAny 18 19 8. Repeat 20 a. Let next be IteratorStep(iteratorRecord). 21 b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. 22 c. ReturnIfAbrupt(next). 23 24 flags: [async] 25 features: [Promise.any, Symbol.iterator, computed-property-names, Symbol, arrow-function] 26 ---*/ 27 28 let returnCount = 0; 29 let poisonedDone = {}; 30 let error = new Test262Error(); 31 Object.defineProperties(poisonedDone, { 32 done: { 33 get() { 34 throw error; 35 } 36 }, 37 value: { 38 get() {} 39 } 40 }); 41 let iterStepThrows = { 42 [Symbol.iterator]() { 43 return { 44 next() { 45 return poisonedDone; 46 }, 47 return() { 48 returnCount += 1; 49 return {}; 50 } 51 }; 52 } 53 }; 54 55 Promise.any(iterStepThrows).then( 56 () => { 57 $DONE('The promise should be rejected.'); 58 }, (reason) => { 59 assert.sameValue(reason, error); 60 assert.sameValue(returnCount, 0); 61 }).then($DONE, $DONE);