tor-browser

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

browser_rules_flexbox-highlighter-on-reload.js (1579B)


      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 a flexbox highlighter after reloading the page.
      7 
      8 const TEST_URI = `
      9  <style type='text/css'>
     10    #flex {
     11      display: flex;
     12    }
     13  </style>
     14  <div id="flex"></div>
     15 `;
     16 
     17 add_task(async function () {
     18  const tab = await addTab(
     19    "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)
     20  );
     21 
     22  info("Check that the flexbox highlighter can be displayed.");
     23  await checkFlexboxHighlighter();
     24 
     25  info("Close the toolbox before reloading the tab.");
     26  await gDevTools.closeToolboxForTab(tab);
     27 
     28  await reloadBrowser();
     29 
     30  info(
     31    "Check that the flexbox highlighter can be displayed after reloading the page."
     32  );
     33  await checkFlexboxHighlighter();
     34 });
     35 
     36 async function checkFlexboxHighlighter() {
     37  const { inspector, view } = await openRuleView();
     38  const HIGHLIGHTER_TYPE = inspector.highlighters.TYPES.FLEXBOX;
     39  const { getNodeForActiveHighlighter, waitForHighlighterTypeShown } =
     40    getHighlighterTestHelpers(inspector);
     41 
     42  await selectNode("#flex", inspector);
     43  const container = getRuleViewProperty(view, "#flex", "display").valueSpan;
     44  const flexboxToggle = container.querySelector(
     45    ".js-toggle-flexbox-highlighter"
     46  );
     47 
     48  info("Toggling ON the flexbox highlighter from the rule-view.");
     49  const onHighlighterShown = waitForHighlighterTypeShown(HIGHLIGHTER_TYPE);
     50  flexboxToggle.click();
     51  await onHighlighterShown;
     52 
     53  ok(
     54    getNodeForActiveHighlighter(HIGHLIGHTER_TYPE),
     55    "Flexbox highlighter is shown."
     56  );
     57 }