tor-browser

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

browser_shutdown_remote_only.js (1626B)


      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(async function () {
      8  await BrowserTestUtils.withNewTab(
      9    {
     10      gBrowser,
     11      url: `data:text/html,
     12      <html>
     13        <head>
     14          <meta charset="utf-8"/>
     15          <title>Accessibility Test</title>
     16        </head>
     17        <body></body>
     18      </html>`,
     19    },
     20    async function (browser) {
     21      info("Creating a service in content");
     22      await loadContentScripts(browser, {
     23        script: "Common.sys.mjs",
     24        symbol: "CommonUtils",
     25      });
     26      // Create a11y service in the content process.
     27      const [a11yInitObserver, a11yInit] = initAccService(browser);
     28      await a11yInitObserver;
     29      await SpecialPowers.spawn(browser, [], () => {
     30        content.CommonUtils.accService;
     31      });
     32      await a11yInit;
     33      ok(
     34        true,
     35        "Accessibility service is started in content process correctly."
     36      );
     37 
     38      info("Removing a service in content");
     39      // Remove a11y service reference from the content process.
     40      const [a11yShutdownObserver, a11yShutdown] = shutdownAccService(browser);
     41      await a11yShutdownObserver;
     42      // Force garbage collection that should trigger shutdown.
     43      await SpecialPowers.spawn(browser, [], () => {
     44        content.CommonUtils.clearAccService();
     45      });
     46      await a11yShutdown;
     47      ok(
     48        true,
     49        "Accessibility service is shutdown in content process correctly."
     50      );
     51    }
     52  );
     53 });