resolve-thenable.js (682B)
1 // |reftest| async 2 // Copyright (C) 2019 Leo Balter. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 description: Resolving with a thenable object value 6 esid: sec-promise.allsettled 7 info: | 8 Let promiseCapability be NewPromiseCapability(C). 9 flags: [async] 10 features: [Promise.allSettled] 11 ---*/ 12 13 var value = {}; 14 var promise; 15 16 try { 17 Array.prototype.then = function(resolve) { 18 resolve(value); 19 }; 20 21 promise = Promise.allSettled([]); 22 } finally { 23 delete Array.prototype.then; 24 } 25 26 promise.then(function(val) { 27 assert.sameValue(val, value); 28 }, function() { 29 $DONE('The promise should not be rejected.'); 30 }).then($DONE, $DONE);