tor-browser

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

invoke-resolve-on-promises-every-iteration-of-promise.js (894B)


      1 // |reftest| async
      2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 description: >
      7  Invocation of the constructor's `resolve` method for iterable with promise values
      8 esid: sec-promise.all
      9 info: |
     10  Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
     11 
     12  Runtime Semantics: PerformPromiseAll
     13 
     14  Repeat
     15    ...
     16    i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
     17 
     18 flags: [async]
     19 features: [arrow-function]
     20 ---*/
     21 
     22 let values = [1,1,1];
     23 let callCount = 0;
     24 let boundPromiseResolve = Promise.resolve.bind(Promise);
     25 
     26 Promise.resolve = function(...args) {
     27  callCount += 1;
     28  return boundPromiseResolve(...args);
     29 };
     30 
     31 Promise.all(values)
     32  .then(() => {
     33      assert.sameValue(callCount, 3, '`then` invoked once for every iterated promise');
     34    }).then($DONE, $DONE);