tor-browser

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

resolve-non-thenable-deferred.js (1299B)


      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    Resolving with a non-thenable object value after invocation of the executor function
      7 es6id: 25.4.3.1
      8 info: |
      9    [...]
     10    8. Let resolvingFunctions be CreateResolvingFunctions(promise).
     11    9. Let completion be Call(executor, undefined,
     12       «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
     13 
     14    25.4.1.3.2 Promise Resolve Functions
     15    [...]
     16    8. Let then be Get(resolution, "then").
     17    9. If then is an abrupt completion, then
     18       [...]
     19    10. Let thenAction be then.[[value]].
     20    11. If IsCallable(thenAction) is false, then
     21        a. Return FulfillPromise(promise, resolution).
     22 flags: [async]
     23 ---*/
     24 
     25 var returnValue = null;
     26 var nonThenable = {
     27  then: null
     28 };
     29 var resolve;
     30 var promise = new Promise(function(_resolve) {
     31  resolve = _resolve;
     32 });
     33 
     34 promise.then(function(value) {
     35  if (value !== nonThenable) {
     36    $DONE('The promise should be fulfilled with the provided value.');
     37    return;
     38  }
     39 
     40  $DONE();
     41 }, function() {
     42  $DONE('The promise should not be rejected.');
     43 });
     44 
     45 returnValue = resolve(nonThenable);
     46 
     47 assert.sameValue(returnValue, undefined, '"resolve" return value');