tor-browser

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

browser_toolbox_hosts_telemetry.js (1294B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const { Toolbox } = require("resource://devtools/client/framework/toolbox.js");
      7 const { LEFT, RIGHT, BOTTOM, WINDOW } = Toolbox.HostType;
      8 
      9 const URL = "data:text/html;charset=utf8,browser_toolbox_hosts_telemetry.js";
     10 
     11 add_task(async function () {
     12  startTelemetry();
     13 
     14  info("Create a test tab and open the toolbox");
     15  const tab = await addTab(URL);
     16  const toolbox = await gDevTools.showToolboxForTab(tab, {
     17    toolId: "webconsole",
     18  });
     19 
     20  await changeToolboxHost(toolbox);
     21  await checkResults();
     22 });
     23 
     24 async function changeToolboxHost(toolbox) {
     25  info("Switch toolbox host");
     26  await toolbox.switchHost(RIGHT);
     27  await toolbox.switchHost(WINDOW);
     28  await toolbox.switchHost(BOTTOM);
     29  await toolbox.switchHost(LEFT);
     30  await toolbox.switchHost(RIGHT);
     31  await toolbox.switchHost(WINDOW);
     32  await toolbox.switchHost(BOTTOM);
     33  await toolbox.switchHost(LEFT);
     34  await toolbox.switchHost(RIGHT);
     35 }
     36 
     37 function checkResults() {
     38  // Check for:
     39  //   - 3 "bottom" entries.
     40  //   - 2 "left" entries.
     41  //   - 3 "right" entries.
     42  //   - 2 "window" entries.
     43  checkTelemetry(
     44    "DEVTOOLS_TOOLBOX_HOST",
     45    "",
     46    { 0: 3, 1: 3, 2: 2, 4: 2, 5: 0 },
     47    "array"
     48  );
     49 }