tor-browser

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

reject-via-fn-deferred.js (1089B)


      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: Rejecting through deferred invocation of the provided resolving function
      6 es6id: 25.4.3.1
      7 info: |
      8    [...]
      9    9. Let completion be Call(executor, undefined,
     10       «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
     11    10. If completion is an abrupt completion, then
     12        [...]
     13    11. Return promise.
     14 
     15    25.4.1.3.1 Promise Reject Functions
     16    [...]
     17    6. Return RejectPromise(promise, reason).
     18 flags: [async]
     19 ---*/
     20 
     21 var thenable = new Promise(function() {});
     22 var returnValue = null;
     23 var reject;
     24 var p = new Promise(function(_, _reject) {
     25  reject = _reject;
     26 });
     27 
     28 p.then(function() {
     29  $DONE('The promise should not be fulfilled.');
     30 }, function(x) {
     31  if (x !== thenable) {
     32    $DONE('The promise should be rejected with the resolution value.');
     33    return;
     34  }
     35 
     36  $DONE();
     37 });
     38 
     39 returnValue = reject(thenable);
     40 
     41 assert.sameValue(returnValue, undefined, '"reject" function return value');