tor-browser

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

browser_application_panel_telemetry-start-worker.js (1473B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TAB_URL = URL_ROOT + "resources/service-workers/simple.html";
      7 
      8 // check telemetry for starting a service worker
      9 add_task(async function () {
     10  info("Set a low service worker idle timeout");
     11  await pushPref("dom.serviceWorkers.idle_timeout", 1000);
     12  await pushPref("dom.serviceWorkers.idle_extended_timeout", 1000);
     13 
     14  await enableApplicationPanel();
     15 
     16  const { panel, tab, commands } = await openNewTabAndApplicationPanel(TAB_URL);
     17  const doc = panel.panelWin.document;
     18 
     19  selectPage(panel, "service-workers");
     20  await waitForWorkerRegistration(tab);
     21 
     22  setupTelemetryTest();
     23 
     24  info("Wait until the service worker appears in the application panel");
     25  await waitUntil(() => getWorkerContainers(doc).length === 1);
     26 
     27  info("Wait until the start button is displayed and enabled");
     28  const container = getWorkerContainers(doc)[0];
     29  await waitUntil(() => {
     30    const button = container.querySelector(".js-start-button");
     31    return button && !button.disabled;
     32  });
     33 
     34  info("Click the start button");
     35  const button = container.querySelector(".js-start-button");
     36  button.click();
     37 
     38  checkTelemetryEvent({ method: "start_worker" });
     39 
     40  // clean up and close the tab
     41  await unregisterAllWorkers(commands.client, doc);
     42  info("Closing the tab.");
     43  await commands.client.waitForRequestsToSettle();
     44  await BrowserTestUtils.removeTab(tab);
     45 });