iter-next-val-err-reject.js (1398B)
1 // |reftest| async 2 // Copyright (C) 2015 the V8 project authors. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 description: > 7 Error when accessing an iterator result's `value` property (rejecting 8 promise) 9 esid: sec-promise.race 10 info: | 11 11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability). 12 12. If result is an abrupt completion, 13 a. If iteratorRecord.[[done]] is false, let result be 14 IteratorClose(iterator, result). 15 b. IfAbruptRejectPromise(result, promiseCapability). 16 17 [...] 18 19 25.4.4.3.1 Runtime Semantics: PerformPromiseRace 20 21 1. Repeat 22 [...] 23 e. Let nextValue be IteratorValue(next). 24 f. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to 25 true. 26 g. ReturnIfAbrupt(nextValue). 27 features: [Symbol.iterator] 28 flags: [async] 29 ---*/ 30 31 var iterNextValThrows = {}; 32 var poisonedVal = { 33 done: false 34 }; 35 var error = new Test262Error(); 36 Object.defineProperty(poisonedVal, 'value', { 37 get: function() { 38 throw error; 39 } 40 }); 41 iterNextValThrows[Symbol.iterator] = function() { 42 return { 43 next: function() { 44 return poisonedVal; 45 } 46 }; 47 }; 48 49 Promise.race(iterNextValThrows).then(function() { 50 $DONE('The promise should be rejected.'); 51 }, function(reason) { 52 assert.sameValue(reason, error); 53 }).then($DONE, $DONE);