iter-step-err-reject.js (1491B)
1 // |reftest| async 2 // Copyright (C) 2016 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 advancing the provided iterable (rejecting promise) 8 esid: sec-promise.race 9 info: | 10 [...] 11 11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C). 12 12. If result is an abrupt completion, then 13 a. If iteratorRecord.[[done]] is false, let result be 14 IteratorClose(iterator,result). 15 b. IfAbruptRejectPromise(result, promiseCapability). 16 17 25.4.4.3.1 Runtime Semantics: PerformPromiseRace 18 1. Repeat 19 a. Let next be IteratorStep(iteratorRecord.[[iterator]]). 20 b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. 21 c. ReturnIfAbrupt(next). 22 features: [Symbol.iterator] 23 flags: [async] 24 ---*/ 25 26 var iterStepThrows = {}; 27 var poisonedDone = {}; 28 var error = new Test262Error(); 29 Object.defineProperty(poisonedDone, 'done', { 30 get: function() { 31 throw error; 32 } 33 }); 34 Object.defineProperty(poisonedDone, 'value', { 35 get: function() { 36 throw new Test262Error('The `value` property should not be accessed.'); 37 } 38 }); 39 40 iterStepThrows[Symbol.iterator] = function() { 41 return { 42 next: function() { 43 return poisonedDone; 44 } 45 }; 46 }; 47 48 Promise.race(iterStepThrows).then(function() { 49 $DONE('The promise should be rejected.'); 50 }, function(reason) { 51 assert.sameValue(reason, error); 52 }).then($DONE, $DONE);