tor-browser

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

ctx-ctor.js (683B)


      1 // Copyright (C) 2024 Jordan Harband. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Promise.try produces instances of the receiver
      6 esid: sec-promise.try
      7 features: [promise-try, class]
      8 ---*/
      9 
     10 var executor = null;
     11 var callCount = 0;
     12 
     13 class SubPromise extends Promise {
     14  constructor(a) {
     15    super(a);
     16    executor = a;
     17    callCount += 1;
     18  }
     19 }
     20 
     21 var instance = Promise.try.call(SubPromise, function () {});
     22 
     23 assert.sameValue(instance.constructor, SubPromise);
     24 assert.sameValue(instance instanceof SubPromise, true);
     25 
     26 assert.sameValue(callCount, 1);
     27 assert.sameValue(typeof executor, 'function');
     28 
     29 reportCompare(0, 0);