tor-browser

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

browser_inspector_highlighter-hover_03.js (2145B)


      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 once a node has been hovered over and marked as such, if it is
      7 // navigated away using the keyboard, the highlighter moves to the new node, and
      8 // if it is then navigated back to, it is briefly highlighted again
      9 
     10 const TEST_PAGE =
     11  "data:text/html;charset=utf-8," + '<p id="one">one</p><p id="two">two</p>';
     12 
     13 add_task(async function () {
     14  const { inspector } = await openInspectorForURL(TEST_PAGE);
     15  const { waitForHighlighterTypeShown } = getHighlighterTestHelpers(inspector);
     16 
     17  info("Making sure the markup-view frame is focused");
     18  inspector.markup._frame.focus();
     19 
     20  let highlightedNode = null;
     21 
     22  async function isHighlighting(selector, desc) {
     23    const nodeFront = await getNodeFront(selector, inspector);
     24    is(highlightedNode, nodeFront, desc);
     25  }
     26 
     27  async function waitForHighlighterShown() {
     28    const onShownData = await waitForHighlighterTypeShown(
     29      inspector.highlighters.TYPES.BOXMODEL
     30    );
     31    highlightedNode = onShownData.nodeFront;
     32  }
     33 
     34  async function waitForInspectorUpdated() {
     35    await inspector.once("inspector-updated");
     36  }
     37 
     38  info("Hover over <p#one> line in the markup-view");
     39  let onShown = waitForHighlighterShown();
     40  await hoverContainer("#one", inspector);
     41  await onShown;
     42  await isHighlighting("#one", "<p#one> is highlighted");
     43 
     44  info("Navigate to <p#two> with the keyboard");
     45  let onUpdated = waitForInspectorUpdated();
     46  EventUtils.synthesizeKey("VK_DOWN", {}, inspector.panelWin);
     47  await onUpdated;
     48  onUpdated = waitForInspectorUpdated();
     49  onShown = waitForHighlighterShown();
     50  EventUtils.synthesizeKey("VK_DOWN", {}, inspector.panelWin);
     51  await Promise.all([onShown, onUpdated]);
     52  await isHighlighting("#two", "<p#two> is highlighted");
     53 
     54  info("Navigate back to <p#one> with the keyboard");
     55  onUpdated = waitForInspectorUpdated();
     56  onShown = waitForHighlighterShown();
     57  EventUtils.synthesizeKey("VK_UP", {}, inspector.panelWin);
     58  await Promise.all([onShown, onUpdated]);
     59  await isHighlighting("#one", "<p#one> is highlighted again");
     60 });