tor-browser

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

call-resolve-element-items.js (1391B)


      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 elements.
      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, 2, "values length");
     24    assert.sameValue(values[0], "expectedValue-p1", "values[0]");
     25    assert.sameValue(values[1], "expectedValue-p2", "values[1]");
     26  }
     27  executor(resolve, Test262Error.thrower);
     28 }
     29 Constructor.resolve = function(v) {
     30  return v;
     31 };
     32 
     33 var p1 = {
     34  then: function(onFulfilled, onRejected) {
     35    onFulfilled("expectedValue-p1");
     36    onFulfilled("unexpectedValue-p1");
     37  }
     38 };
     39 var p2 = {
     40  then: function(onFulfilled, onRejected) {
     41    onFulfilled("expectedValue-p2");
     42    onFulfilled("unexpectedValue-p2");
     43  }
     44 };
     45 
     46 assert.sameValue(callCount, 0, "callCount before call to all()");
     47 
     48 Promise.all.call(Constructor, [p1, p2]);
     49 
     50 assert.sameValue(callCount, 1, "callCount after call to all()");
     51 
     52 reportCompare(0, 0);