invoke-resolve-error-reject.js (1145B)
1 // |reftest| async 2 // Copyright (C) 2016 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: Promise rejection 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 flags: [async] 24 ---*/ 25 26 var err = new Test262Error(); 27 var CustomPromise = function(executor) { 28 return new Promise(executor); 29 }; 30 31 CustomPromise.resolve = function() { 32 throw err; 33 }; 34 35 Promise.race.call(CustomPromise, [1]) 36 .then(function() { 37 throw new Test262Error('The promise should be rejected.'); 38 }, function(reason) { 39 assert.sameValue(reason, err); 40 $DONE(); 41 });