invoke-then-error-reject.js (1163B)
1 // |reftest| async 2 // Copyright (C) 2015 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 thrown when invoking the instance's `then` method (rejecting promise) 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 j. Let result be Invoke(nextPromise, "then", 23 «promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»). 24 k. ReturnIfAbrupt(result). 25 flags: [async] 26 ---*/ 27 28 var promise = new Promise(function() {}); 29 var error = new Test262Error(); 30 31 promise.then = function() { 32 throw error; 33 }; 34 35 Promise.race([promise]).then(function() { 36 throw new Test262Error('The promise should be rejected'); 37 }, function(reason) { 38 assert.sameValue(reason, error); 39 }).then($DONE, $DONE);