tor-browser

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

reject-immed.js (1224B)


      1 // |reftest| async
      2 // Copyright (C) 2016 the V8 project authors. 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 immediate invocation of the provided resolving function
      7 info: |
      8    ...
      9    Let promiseCapability be NewPromiseCapability(C).
     10    ...
     11    Let result be PerformPromiseAny(iteratorRecord, promiseCapability, C).
     12    ...
     13 
     14    Runtime Semantics: PerformPromiseAny
     15    ...
     16    8. Repeat
     17       ...
     18       r. Perform ? Invoke(nextPromise, "then",
     19          « resultCapability.[[Resolve]], rejectElement »).
     20 
     21 
     22    Promise.any Reject Element Functions
     23    ...
     24    6. Return RejectPromise(promise, reason).
     25 flags: [async]
     26 features: [Promise.any, arrow-function]
     27 ---*/
     28 
     29 let callCount = 0;
     30 let thenable = {
     31  then(_, reject) {
     32    callCount++;
     33    reject('reason');
     34  }
     35 };
     36 
     37 Promise.any([thenable])
     38  .then(() => {
     39    $DONE('The promise should not be fulfilled.');
     40  }, (error) => {
     41    assert.sameValue(callCount, 1, "callCount === 1");
     42    assert(error instanceof AggregateError, "error instanceof AggregateError");
     43    assert.sameValue(error.errors[0], "reason", "error.errors[0] === 'reason'");
     44    $DONE();
     45  });