tor-browser

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

resolve-thenable.js (1071B)


      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: Resolving with a thenable object value
      6 es6id: 25.4.4.5
      7 info: |
      8    [...]
      9    6. Let resolveResult be Call(promiseCapability.[[Resolve]], undefined,
     10       «x»).
     11    [...]
     12 
     13    25.4.1.3.2 Promise Resolve Functions
     14    [...]
     15    8. Let then be Get(resolution, "then").
     16    9. If then is an abrupt completion, then
     17       [...]
     18    10. Let thenAction be then.[[value]].
     19    11. If IsCallable(thenAction) is false, then
     20        [...]
     21    12. Perform EnqueueJob ("PromiseJobs", PromiseResolveThenableJob,
     22        «promise, resolution, thenAction»)
     23 flags: [async]
     24 ---*/
     25 
     26 var value = {};
     27 var thenable = {
     28  then: function(resolve) {
     29    resolve(value);
     30  }
     31 };
     32 
     33 Promise.resolve(thenable).then(function(val) {
     34  if (val !== value) {
     35    $DONE('The promise should be fulfilled with the provided value.');
     36    return;
     37  }
     38 
     39  $DONE();
     40 }, function() {
     41  $DONE('The promise should not be rejected.');
     42 });