tor-browser

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

reject-ignored-deferred.js (1463B)


      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 deferred 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    new Promise(function(resolve) {
     34        resolve();
     35      })
     36      .then(function() {
     37        resolve();
     38      });
     39  }
     40 };
     41 var rejector = {
     42  then: function(_, reject) {
     43    new Promise(function(resolve) {
     44        resolve();
     45      })
     46      .then(function() {
     47        reject();
     48      });
     49  }
     50 };
     51 
     52 Promise.race([fulfiller, rejector])
     53  .then(function() {
     54    $DONE();
     55  }, function() {
     56    $DONE('The promise should not be rejected.');
     57  });