tor-browser

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

ctx-ctor.js (856B)


      1 // Copyright (C) 2019 Sergey Rubanov. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6  Promise.any invoked on a constructor value
      7 esid: sec-promise.any
      8 info: |
      9  2. Let promiseCapability be ? NewPromiseCapability(C).
     10  ...
     11  5. Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
     12  ...
     13  7. Return Completion(result).
     14 features: [Promise.any, class]
     15 ---*/
     16 
     17 var executor = null;
     18 var callCount = 0;
     19 
     20 class SubPromise extends Promise {
     21  constructor(a) {
     22    super(a);
     23    executor = a;
     24    callCount += 1;
     25  }
     26 }
     27 
     28 var instance = Promise.any.call(SubPromise, []);
     29 
     30 assert.sameValue(instance.constructor, SubPromise);
     31 assert.sameValue(instance instanceof SubPromise, true);
     32 
     33 assert.sameValue(callCount, 1);
     34 assert.sameValue(typeof executor, 'function');
     35 
     36 reportCompare(0, 0);