tor-browser

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

resolve-ignores-late-rejection-deferred.js (1044B)


      1 // |reftest| async
      2 // Copyright (C) 2019 Leo Balter, 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  Resolved promises ignore rejections through deferred invocation of the
      8    provided resolving function
      9 esid: sec-promise.any
     10 info: |
     11  Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
     12 
     13  Runtime Semantics: PerformPromiseAll
     14 
     15  Repeat
     16    ...
     17    r. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], rejectElement »).
     18 
     19 flags: [async]
     20 features: [arrow-function]
     21 ---*/
     22 
     23 var resolver = {
     24  then(resolve) {
     25    new Promise((resolve) => resolve())
     26      .then(() => resolve(42));
     27  }
     28 };
     29 var lateRejector = {
     30  then(resolve, reject) {
     31    new Promise((resolve) => resolve())
     32      .then(() => {
     33        resolve(9);
     34        reject();
     35      });
     36  }
     37 };
     38 
     39 Promise.all([resolver, lateRejector])
     40  .then(resolution => {
     41    assert.sameValue(resolution[0], 42);
     42    assert.sameValue(resolution[1], 9);
     43  }).then($DONE, $DONE);