iter-step-err-no-close.js (1452B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 description: > 5 Error when advancing the provided iterable (not closing iterator) 6 esid: sec-promise.race 7 info: | 8 [...] 9 11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C). 10 12. If result is an abrupt completion, then 11 a. If iteratorRecord.[[done]] is false, let result be 12 IteratorClose(iterator,result). 13 b. IfAbruptRejectPromise(result, promiseCapability). 14 15 25.4.4.3.1 Runtime Semantics: PerformPromiseRace 16 1. Repeat 17 a. Let next be IteratorStep(iteratorRecord.[[iterator]]). 18 b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. 19 c. ReturnIfAbrupt(next). 20 features: [Symbol.iterator] 21 ---*/ 22 23 var iterStepThrows = {}; 24 var poisonedDone = {}; 25 var returnCount = 0; 26 var error = new Test262Error(); 27 Object.defineProperty(poisonedDone, 'done', { 28 get: function() { 29 throw error; 30 } 31 }); 32 Object.defineProperty(poisonedDone, 'value', { 33 get: function() { 34 throw new Test262Error('The `value` property should not be accessed.'); 35 } 36 }); 37 38 iterStepThrows[Symbol.iterator] = function() { 39 return { 40 next: function() { 41 return poisonedDone; 42 }, 43 return: function() { 44 returnCount += 1; 45 } 46 }; 47 }; 48 49 Promise.race(iterStepThrows); 50 51 assert.sameValue(returnCount, 0); 52 53 reportCompare(0, 0);