tor-browser

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

call-resolve-element.js (1173B)


      1 // Copyright (C) 2015 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 es6id: 25.4.4.1.2
      6 description: >
      7  Cannot change result value of resolved Promise.all element.
      8 info: |
      9  Promise.all Resolve Element Functions
     10 
     11  1. Let alreadyCalled be the value of F's [[AlreadyCalled]] internal slot.
     12  2. If alreadyCalled.[[value]] is true, return undefined.
     13  3. Set alreadyCalled.[[value]] to true.
     14  ...
     15 ---*/
     16 
     17 var callCount = 0;
     18 
     19 function Constructor(executor) {
     20  function resolve(values) {
     21    callCount += 1;
     22    assert(Array.isArray(values), "values is array");
     23    assert.sameValue(values.length, 1, "values length");
     24    assert.sameValue(values[0], "expectedValue", "values[0]");
     25  }
     26  executor(resolve, Test262Error.thrower);
     27 }
     28 Constructor.resolve = function(v) {
     29  return v;
     30 };
     31 
     32 var p1 = {
     33  then: function(onFulfilled, onRejected) {
     34    onFulfilled("expectedValue");
     35    onFulfilled("unexpectedValue");
     36  }
     37 };
     38 
     39 assert.sameValue(callCount, 0, "callCount before call to all()");
     40 
     41 Promise.all.call(Constructor, [p1]);
     42 
     43 assert.sameValue(callCount, 1, "callCount after call to all()");
     44 
     45 reportCompare(0, 0);