tor-browser

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

reject-deferred.js (883B)


      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 esid: sec-promise.any
      6 description: Rejecting through deferred invocation of the provided resolving function
      7 info: |
      8  ...
      9  5. Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
     10  ...
     11 
     12 
     13 flags: [async]
     14 features: [AggregateError, Promise.any, arrow-function]
     15 ---*/
     16 
     17 var rejection = {};
     18 var thenable = {
     19  then(_, reject) {
     20    new Promise((resolve) => resolve())
     21      .then(() => reject(rejection));
     22  }
     23 };
     24 
     25 Promise.any([thenable])
     26  .then(() => {
     27    $DONE('The promise should be rejected.');
     28  }, (aggregate) => {
     29    assert(aggregate instanceof AggregateError);
     30    assert.sameValue(aggregate.errors.length, 1);
     31    assert.sameValue(aggregate.errors[0], rejection);
     32  }).then($DONE, $DONE);