invoke-resolve-error-close.js (1196B)
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 Explicit iterator closing in response to error from `Promise.resolve` 7 esid: sec-promise.race 8 info: | 9 [...] 10 11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C). 11 12. If result is an abrupt completion, then 12 a. If iteratorRecord.[[done]] is false, let result be 13 IteratorClose(iterator,result). 14 b. IfAbruptRejectPromise(result, promiseCapability). 15 16 17 25.4.4.3.1 Runtime Semantics: PerformPromiseRace 18 19 1. Repeat 20 [...] 21 h. Let nextPromise be Invoke(C, "resolve", «nextValue»). 22 i. ReturnIfAbrupt(nextPromise). 23 features: [Symbol.iterator] 24 ---*/ 25 26 var iterDoneSpy = {}; 27 var returnCount = 0; 28 iterDoneSpy[Symbol.iterator] = function() { 29 return { 30 next: function() { 31 return { 32 value: null, 33 done: false 34 }; 35 }, 36 return: function() { 37 returnCount += 1; 38 return {}; 39 } 40 }; 41 }; 42 43 Promise.resolve = function() { 44 throw err; 45 }; 46 47 Promise.race(iterDoneSpy); 48 49 assert.sameValue(returnCount, 1); 50 51 reportCompare(0, 0);