reject-via-fn-immed.js (1058B)
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 description: Rejecting through immediate invocation of the provided resolving function 6 es6id: 25.4.3.1 7 info: | 8 [...] 9 9. Let completion be Call(executor, undefined, 10 «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»). 11 10. If completion is an abrupt completion, then 12 [...] 13 11. Return promise. 14 15 25.4.1.3.1 Promise Reject Functions 16 [...] 17 6. Return RejectPromise(promise, reason). 18 flags: [async] 19 ---*/ 20 21 var thenable = new Promise(function() {}); 22 var returnValue = null; 23 var p = new Promise(function(_, reject) { 24 returnValue = reject(thenable); 25 }); 26 27 assert.sameValue(returnValue, undefined, '"reject" function return value'); 28 29 p.then(function() { 30 $DONE('The promise should not be fulfilled.'); 31 }, function(x) { 32 if (x !== thenable) { 33 $DONE('The promise should be rejected with the resolution value.'); 34 return; 35 } 36 37 $DONE(); 38 });