tor-browser

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

browser_worker_import_esm_source.js (761B)


      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 const BASE_URL =
      6  "chrome://mochitests/content/browser/js/xpconnect/tests/browser/";
      7 const WORKER_URL = BASE_URL + "worker_import_esm_source.mjs";
      8 
      9 add_task(async function testInWorker() {
     10  const string = await new Promise(resolve => {
     11    const worker = new ChromeWorker(WORKER_URL, { type: "module" });
     12    worker.addEventListener("message", event => {
     13      resolve(event.data.string);
     14    });
     15  });
     16  ok(
     17    string.includes("A comment in function."),
     18    "Source should be available in ESM loaded via ChromeUtils.importESModule in worker"
     19  );
     20 });