tor-browser

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

resolve-poisoned-then-deferred.js (1234B)


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