tor-browser

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

browser_rules_flexbox-toggle-telemetry.js (1562B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that the telemetry is correct when the flexbox highlighter is activated from
      7 // the rules view.
      8 
      9 const TEST_URI = `
     10  <style type='text/css'>
     11    #flex {
     12      display: flex;
     13    }
     14  </style>
     15  <div id="flex"></div>
     16 `;
     17 
     18 add_task(async function () {
     19  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     20  startTelemetry();
     21  const { inspector, view } = await openRuleView();
     22  const HIGHLIGHTER_TYPE = inspector.highlighters.TYPES.FLEXBOX;
     23  const { waitForHighlighterTypeShown, waitForHighlighterTypeHidden } =
     24    getHighlighterTestHelpers(inspector);
     25 
     26  await selectNode("#flex", inspector);
     27  const container = getRuleViewProperty(view, "#flex", "display").valueSpan;
     28  const flexboxToggle = container.querySelector(
     29    ".js-toggle-flexbox-highlighter"
     30  );
     31 
     32  info("Toggling ON the flexbox highlighter from the rule-view.");
     33  const onHighlighterShown = waitForHighlighterTypeShown(HIGHLIGHTER_TYPE);
     34  flexboxToggle.click();
     35  await onHighlighterShown;
     36 
     37  info("Toggling OFF the flexbox highlighter from the rule-view.");
     38  const onHighlighterHidden = waitForHighlighterTypeHidden(HIGHLIGHTER_TYPE);
     39  flexboxToggle.click();
     40  await onHighlighterHidden;
     41 
     42  checkResults();
     43 });
     44 
     45 function checkResults() {
     46  checkTelemetry("devtools.rules.flexboxhighlighter.opened", "", 1, "scalar");
     47  checkTelemetry(
     48    "DEVTOOLS_FLEXBOX_HIGHLIGHTER_TIME_ACTIVE_SECONDS",
     49    "",
     50    null,
     51    "hasentries"
     52  );
     53 }