iter-next-val-err-reject.js (1380B)
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: > 8 Error when accessing an iterator result's `value` property (rejecting promise) 9 info: | 10 Promise.allSettled ( iterable ) 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 17 Runtime Semantics: PerformPromiseAllSettled 18 19 ... 20 6. Repeat 21 ... 22 e. Let nextValue be IteratorValue(next). 23 f. If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to true. 24 g. ReturnIfAbrupt(nextValue). 25 features: [Promise.allSettled, Symbol.iterator] 26 flags: [async] 27 ---*/ 28 29 var iterNextValThrows = {}; 30 var poisonedVal = { 31 done: false 32 }; 33 var error = new Test262Error(); 34 Object.defineProperty(poisonedVal, 'value', { 35 get() { 36 throw error; 37 } 38 }); 39 iterNextValThrows[Symbol.iterator] = function() { 40 return { 41 next() { 42 return poisonedVal; 43 } 44 }; 45 }; 46 47 Promise.allSettled(iterNextValThrows).then(function() { 48 $DONE('The promise should be rejected.'); 49 }, function(reason) { 50 assert.sameValue(reason, error); 51 }).then($DONE, $DONE);