tor-browser

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

invoke-then-error-reject.js (1052B)


      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  Error thrown when invoking the instance's `then` method (rejecting Promise)
      8 esid: sec-promise.any
      9 info: |
     10  5. Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
     11  6. If result is an abrupt completion, then
     12    a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
     13    b. IfAbruptRejectPromise(result, promiseCapability).
     14 
     15  Runtime Semantics: PerformPromiseAny
     16 
     17  r. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], rejectElement »).
     18 
     19 flags: [async]
     20 features: [Promise.any, arrow-function]
     21 ---*/
     22 let error = new Test262Error();
     23 let promise = Promise.resolve();
     24 
     25 promise.then = function() {
     26  throw error;
     27 };
     28 
     29 Promise.any([promise]).then(() => {
     30  $DONE('The promise should be rejected, but was resolved');
     31 }, (reason) => {
     32  assert.sameValue(reason, error);
     33 }).then($DONE, $DONE);