tor-browser

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

subclass.js (1054B)


      1 // |reftest| skip-if(!xulRuntime.shell) -- needs drainJobQueue
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 const AsyncFunction = async function(){}.constructor;
      7 
      8 class MyAsync extends AsyncFunction {}
      9 
     10 // MyGen inherits from %AsyncFunction%.
     11 assertEq(Object.getPrototypeOf(MyAsync), AsyncFunction);
     12 
     13 // MyGen.prototype inherits from %AsyncFunctionPrototype%.
     14 assertEq(Object.getPrototypeOf(MyAsync.prototype), AsyncFunction.prototype);
     15 
     16 var fn = new MyAsync("return await 'ok';");
     17 
     18 // fn inherits from MyAsync.prototype.
     19 assertEq(Object.getPrototypeOf(fn), MyAsync.prototype);
     20 
     21 // Ensure the new async function can be executed.
     22 var promise = fn();
     23 
     24 // promise inherits from %Promise.prototype%.
     25 assertEq(Object.getPrototypeOf(promise), Promise.prototype);
     26 
     27 // Computes the expected result.
     28 assertEventuallyEq(promise, "ok");
     29 
     30 if (typeof reportCompare === "function")
     31    reportCompare(0, 0);