tor-browser

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

browser_net_telemetry_sidepanel_changed.js (1846B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const ALL_CHANNELS = Ci.nsITelemetry.DATASET_ALL_CHANNELS;
      7 
      8 /**
      9 * Test the sidepanel_changed telemetry event.
     10 */
     11 add_task(async function () {
     12  const { monitor } = await initNetMonitor(HTTPS_SIMPLE_URL, {
     13    requestCount: 1,
     14  });
     15  info("Starting test... ");
     16 
     17  const { document, store, windowRequire } = monitor.panelWin;
     18  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     19  store.dispatch(Actions.batchEnable(false));
     20 
     21  // Remove all telemetry events (you can check about:telemetry).
     22  Services.telemetry.clearEvents();
     23 
     24  // Ensure no events have been logged
     25  const snapshot = Services.telemetry.snapshotEvents(ALL_CHANNELS, true);
     26  ok(!snapshot.parent, "No events have been logged for the main process");
     27 
     28  // Reload to have one request in the list.
     29  const waitForEvents = waitForNetworkEvents(monitor, 1);
     30  await navigateTo(HTTPS_SIMPLE_URL);
     31  await waitForEvents;
     32 
     33  // Click on a request and wait till the default "Headers" side panel is opened.
     34  info("Click on a request");
     35  const waitForHeaders = waitUntil(() =>
     36    document.querySelector(".headers-overview")
     37  );
     38  EventUtils.sendMouseEvent(
     39    { type: "mousedown" },
     40    document.querySelectorAll(".request-list-item")[0]
     41  );
     42  await waitForHeaders;
     43  await waitForRequestData(store, ["requestHeaders", "responseHeaders"]);
     44 
     45  // Click on the Cookies panel and wait till it's opened.
     46  info("Click on the Cookies panel");
     47  clickOnSidebarTab(document, "cookies");
     48  await waitForRequestData(store, ["requestCookies", "responseCookies"]);
     49 
     50  checkTelemetryEvent(
     51    {
     52      oldpanel: "headers",
     53      newpanel: "cookies",
     54    },
     55    {
     56      method: "sidepanel_changed",
     57    }
     58  );
     59 
     60  return teardown(monitor);
     61 });