tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

same-reject-function.js (1119B)


      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 the same reject function.
      8 info: |
      9  Runtime Semantics: PerformPromiseAll( iteratorRecord, constructor, resultCapability)
     10 
     11  ...
     12  r. Let result be Invoke(nextPromise, "then", «resolveElement, resultCapability.[[Reject]]»).
     13  ...
     14 ---*/
     15 
     16 function rejectFunction() {}
     17 
     18 function Constructor(executor) {
     19  executor(Test262Error.thrower, rejectFunction);
     20 }
     21 Constructor.resolve = function(v) {
     22  return v;
     23 };
     24 
     25 var callCount1 = 0,
     26  callCount2 = 0;
     27 
     28 var p1 = {
     29  then: function(onFulfilled, onRejected) {
     30    callCount1 += 1;
     31    assert.sameValue(onRejected, rejectFunction, "p1.then");
     32  }
     33 };
     34 var p2 = {
     35  then: function(onFulfilled, onRejected) {
     36    callCount2 += 1;
     37    assert.sameValue(onRejected, rejectFunction, "p2.then");
     38  }
     39 };
     40 
     41 Promise.all.call(Constructor, [p1, p2]);
     42 
     43 assert.sameValue(callCount1, 1, "p1.then call count");
     44 assert.sameValue(callCount2, 1, "p2.then call count");
     45 
     46 reportCompare(0, 0);