tor-browser

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

resolve-ignores-late-rejection.js (884B)


      1 // |reftest| async
      2 // Copyright (C) 2020 Rick Waldron, 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 immediate invocation of the
      8    provided resolving function
      9 esid: sec-promise.race
     10 info: |
     11  Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability, promiseResolve).
     12 
     13  PerformPromiseRace
     14 
     15  Repeat
     16    ...
     17    Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], resultCapability.[[Reject]] »).
     18 
     19 flags: [async]
     20 features: [arrow-function]
     21 ---*/
     22 
     23 let resolver = {
     24  then(resolve) {
     25    resolve(42);
     26  }
     27 };
     28 let lateRejector = {
     29  then(resolve, reject) {
     30    resolve(33);
     31    reject();
     32  }
     33 };
     34 
     35 Promise.race([resolver, lateRejector])
     36  .then(resolution => {
     37    assert.sameValue(resolution, 42);
     38  }).then($DONE, $DONE);