tor-browser

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

browser_inspector_infobar_textnode.js (1803B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 // Bug 1309212 - Make sure info-bar is displayed with dimensions for text nodes.
      8 
      9 const TEST_URI = URL_ROOT + "doc_inspector_infobar_textnode.html";
     10 
     11 add_task(async function () {
     12  const { inspector, highlighterTestFront } =
     13    await openInspectorForURL(TEST_URI);
     14  const { walker } = inspector;
     15 
     16  info("Retrieve the children of #textnode-container");
     17  const div = await walker.querySelector(
     18    walker.rootNode,
     19    "#textnode-container"
     20  );
     21  const { nodes } = await inspector.walker.children(div);
     22 
     23  // Children 0, 2 and 4 are text nodes, for which we expect to see an infobar containing
     24  // dimensions.
     25 
     26  // Regular text node.
     27  info("Select the first text node");
     28  await selectNode(nodes[0], inspector, "test-highlight");
     29  await checkTextNodeInfoBar(highlighterTestFront);
     30 
     31  // Whitespace-only text node.
     32  info("Select the second text node");
     33  await selectNode(nodes[2], inspector, "test-highlight");
     34  await checkTextNodeInfoBar(highlighterTestFront);
     35 
     36  // Regular text node.
     37  info("Select the third text node");
     38  await selectNode(nodes[4], inspector, "test-highlight");
     39  await checkTextNodeInfoBar(highlighterTestFront);
     40 });
     41 
     42 async function checkTextNodeInfoBar(highlighterTestFront) {
     43  const tag = await highlighterTestFront.getHighlighterNodeTextContent(
     44    "box-model-infobar-tagname"
     45  );
     46  is(tag, "#text", "node display name is #text");
     47  const dims = await highlighterTestFront.getHighlighterNodeTextContent(
     48    "box-model-infobar-dimensions"
     49  );
     50  // Do not assert dimensions as they might be platform specific.
     51  ok(!!dims, "node has dims");
     52 }