tor-browser

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

reject-ignored-immed.js (1258B)


      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 description: >
      6    Resolved promises ignore rejections through immediate invocation of the
      7    provided resolving function
      8 es6id: 25.4.4.3
      9 info: |
     10    [...]
     11    6. Let promiseCapability be NewPromiseCapability(C).
     12    [...]
     13    11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
     14    [...]
     15 
     16    25.4.4.3.1 Runtime Semantics: PerformPromiseRace
     17    1. Repeat
     18       [...]
     19       j. Let result be Invoke(nextPromise, "then",
     20          «promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
     21 
     22    25.4.1.3.1 Promise Reject Functions
     23    [...]
     24    2. Let promise be the value of F's [[Promise]] internal slot.
     25    3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
     26       slot.
     27    4. If alreadyResolved.[[value]] is true, return undefined.
     28 flags: [async]
     29 ---*/
     30 
     31 var fulfiller = {
     32  then: function(resolve) {
     33    resolve();
     34  }
     35 };
     36 var rejector = {
     37  then: function(_, reject) {
     38    reject();
     39  }
     40 };
     41 
     42 Promise.race([fulfiller, rejector])
     43  .then(function() {
     44    $DONE();
     45  }, function() {
     46    $DONE('The promise should not be rejected.');
     47  });