resolve-poisoned-then-immed.js (1191B)
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: > 6 Resolving with an object with a "poisoned" `then` property from within the 7 executor function 8 es6id: 25.4.3.1 9 info: | 10 [...] 11 8. Let resolvingFunctions be CreateResolvingFunctions(promise). 12 9. Let completion be Call(executor, undefined, 13 «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»). 14 15 25.4.1.3.2 Promise Resolve Functions 16 7. If Type(resolution) is not Object, then 17 a. Return FulfillPromise(promise, resolution). 18 flags: [async] 19 ---*/ 20 21 var returnValue = null; 22 var value = {}; 23 var poisonedThen = Object.defineProperty({}, 'then', { 24 get: function() { 25 throw value; 26 } 27 }); 28 var promise = new Promise(function(resolve) { 29 returnValue = resolve(poisonedThen); 30 }); 31 32 assert.sameValue(returnValue, undefined, '"resolve" return value'); 33 34 promise.then(function() { 35 $DONE('The promise should not be fulfilled.'); 36 }, function(val) { 37 if (val !== value) { 38 $DONE('The promise should be fulfilled with the provided value.'); 39 return; 40 } 41 42 $DONE(); 43 });