call-resolve-element.js (1245B)
1 // Copyright (C) 2019 Leo Balter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-promise.allsettled-resolve-element-functions 6 description: > 7 Cannot change result value of resolved Promise.allSettled element. 8 info: | 9 Promise.allSettled Resolve Element Functions 10 11 1. Let F be the active function object. 12 2. Let alreadyCalled be F.[[AlreadyCalled]]. 13 3. If alreadyCalled.[[Value]] is true, return undefined. 14 4. Set alreadyCalled.[[Value]] to true. 15 ... 16 includes: [promiseHelper.js] 17 features: [Promise.allSettled] 18 ---*/ 19 20 var callCount = 0; 21 22 function Constructor(executor) { 23 function resolve(values) { 24 callCount += 1; 25 checkSettledPromises(values, [ 26 { 27 status: 'fulfilled', 28 value: 'expectedValue' 29 } 30 ], 'values'); 31 } 32 executor(resolve, Test262Error.thrower); 33 } 34 Constructor.resolve = function(v) { 35 return v; 36 }; 37 38 var p1 = { 39 then(onFulfilled, onRejected) { 40 onFulfilled('expectedValue'); 41 onFulfilled('unexpectedValue'); 42 } 43 }; 44 45 assert.sameValue(callCount, 0, 'callCount before call to all()'); 46 47 Promise.allSettled.call(Constructor, [p1]); 48 49 assert.sameValue(callCount, 1, 'callCount after call to all()'); 50 51 reportCompare(0, 0);