iter-next-val-err-no-close.js (1360B)
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 /*--- 5 description: > 6 Error when accessing an iterator result's `value` property (not closing 7 iterator) 8 esid: sec-promise.race 9 info: | 10 11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability). 11 12. If result is an abrupt completion, 12 a. If iteratorRecord.[[done]] is false, let result be 13 IteratorClose(iterator, result). 14 b. IfAbruptRejectPromise(result, promiseCapability). 15 16 [...] 17 18 25.4.4.3.1 Runtime Semantics: PerformPromiseRace 19 20 1. Repeat 21 [...] 22 e. Let nextValue be IteratorValue(next). 23 f. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to 24 true. 25 g. ReturnIfAbrupt(nextValue). 26 features: [Symbol.iterator] 27 ---*/ 28 29 var iterNextValThrows = {}; 30 var returnCount = 0; 31 var poisonedVal = { 32 done: false 33 }; 34 var error = new Test262Error(); 35 Object.defineProperty(poisonedVal, 'value', { 36 get: function() { 37 throw error; 38 } 39 }); 40 iterNextValThrows[Symbol.iterator] = function() { 41 return { 42 next: function() { 43 return poisonedVal; 44 }, 45 return: function() { 46 returnCount += 1; 47 } 48 }; 49 }; 50 51 Promise.race(iterNextValThrows); 52 53 assert.sameValue(returnCount, 0); 54 55 reportCompare(0, 0);