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