tor-browser

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

test_eventemitter_destroy.js (878B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 add_task(function () {
      8  const { DevToolsLoader, require } = ChromeUtils.importESModule(
      9    "resource://devtools/shared/loader/Loader.sys.mjs"
     10  );
     11 
     12  // Force-load the module once in the global loader to avoid Bug 1622718.
     13  require("resource://devtools/shared/event-emitter.js");
     14 
     15  const emitterRef = (function () {
     16    const loader = new DevToolsLoader();
     17 
     18    const ref = Cu.getWeakReference(
     19      loader.require("resource://devtools/shared/event-emitter.js")
     20    );
     21 
     22    loader.destroy();
     23    return ref;
     24  })();
     25 
     26  Cu.forceGC();
     27  Cu.forceCC();
     28  Cu.forceGC();
     29  Cu.forceCC();
     30 
     31  Assert.ok(!emitterRef.get(), "weakref has been cleared by gc");
     32 });