new-resolve-function.js (1407B)
1 // Copyright (C) 2015 André Bargull. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es6id: 25.4.4.1.1 6 description: > 7 Each Promise.all element is called with a new Promise.all Resolve Element function. 8 info: | 9 Runtime Semantics: PerformPromiseAll( iteratorRecord, constructor, resultCapability) 10 11 ... 12 k. Let resolveElement be a new built-in function object as defined in Promise.all Resolve Element Functions. 13 ... 14 r. Let result be Invoke(nextPromise, "then", «resolveElement, resultCapability.[[Reject]]»). 15 ... 16 ---*/ 17 18 function resolveFunction() {} 19 20 function Constructor(executor) { 21 executor(resolveFunction, Test262Error.thrower); 22 } 23 Constructor.resolve = function(v) { 24 return v; 25 }; 26 27 var callCount1 = 0, 28 callCount2 = 0; 29 var p1OnFulfilled; 30 31 var p1 = { 32 then: function(onFulfilled, onRejected) { 33 callCount1 += 1; 34 p1OnFulfilled = onFulfilled; 35 assert.notSameValue(onFulfilled, resolveFunction, "p1.then"); 36 } 37 }; 38 var p2 = { 39 then: function(onFulfilled, onRejected) { 40 callCount2 += 1; 41 assert.notSameValue(onFulfilled, resolveFunction, "p2.then"); 42 assert.notSameValue(onFulfilled, p1OnFulfilled, "p1.onFulfilled != p2.onFulfilled"); 43 } 44 }; 45 46 Promise.all.call(Constructor, [p1, p2]); 47 48 assert.sameValue(callCount1, 1, "p1.then call count"); 49 assert.sameValue(callCount2, 1, "p2.then call count"); 50 51 reportCompare(0, 0);