tor-browser

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

browser_rules_selector-highlighter-iframe-picker.js (2012B)


      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 selector highlighter is hidden when selecting frames in the iframe picker
      7 
      8 const TEST_URI = `
      9  <style type="text/css">
     10    body {
     11      background: red;
     12    }
     13  </style>
     14  <h1>Test the selector highlighter</h1>
     15  <iframe src="data:text/html,<meta charset=utf8><style>h2 {background: yellow;}</style><h2>In iframe</h2>">
     16 `;
     17 
     18 add_task(async function () {
     19  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     20  const { inspector, toolbox, view } = await openRuleView();
     21 
     22  info("Clicking on a selector icon");
     23  const { highlighter, isShown } = await clickSelectorIcon(view, "body");
     24 
     25  ok(highlighter, "The selector highlighter instance was created");
     26  ok(isShown, "The selector highlighter was shown");
     27  is(
     28    highlighter,
     29    inspector.highlighters.getActiveHighlighter(
     30      inspector.highlighters.TYPES.SELECTOR
     31    ),
     32    "The selector highlighter is the active highlighter"
     33  );
     34 
     35  // Open frame menu and wait till it's available on the screen.
     36  const panel = toolbox.doc.getElementById("command-button-frames-panel");
     37  const btn = toolbox.doc.getElementById("command-button-frames");
     38  btn.click();
     39  ok(panel, "popup panel has created.");
     40  await waitUntil(() => panel.classList.contains("tooltip-visible"));
     41 
     42  // Verify that the menu is populated.
     43  const menuList = toolbox.doc.getElementById("toolbox-frame-menu");
     44  const frames = Array.from(menuList.querySelectorAll(".command"));
     45 
     46  // Wait for the inspector to be reloaded
     47  // (instead of only new-root) in order to wait for full
     48  // async update of the inspector.
     49  const onNewRoot = inspector.once("reloaded");
     50  frames[1].click();
     51  await onNewRoot;
     52 
     53  await waitFor(
     54    () =>
     55      !inspector.highlighters.getActiveHighlighter(
     56        inspector.highlighters.TYPES.SELECTOR
     57      )
     58  );
     59  ok(true, "The selector highlighter gets hidden after selecting a frame");
     60 });