tor-browser

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

invoke-resolve-get-error-reject.js (1055B)


      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 retrieving the constructor's `resolve` 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  8. Repeat
     18    ...
     19    i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
     20 
     21 flags: [async]
     22 features: [Promise.any, arrow-function]
     23 ---*/
     24 
     25 let error = new Test262Error();
     26 Object.defineProperty(Promise, 'resolve', {
     27  get() {
     28    throw error;
     29  }
     30 });
     31 
     32 Promise.any([1]).then(() => {
     33    $DONE('The promise should be rejected, but was resolved');
     34  }, (reason) => {
     35    assert.sameValue(reason, error);
     36  }).then($DONE, $DONE);