tor-browser

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

browser_inspector_highlighter-geometry_03.js (1994B)


      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 /* Globals defined in: devtools/client/inspector/test/head.js */
      6 
      7 "use strict";
      8 
      9 // Test that the right arrows/labels are shown even when the css properties are
     10 // in several different css rules.
     11 
     12 const TEST_URL = URL_ROOT + "doc_inspector_highlighter-geometry_01.html";
     13 const ID = "geometry-editor-";
     14 const { TYPES } = ChromeUtils.importESModule(
     15  "resource://devtools/shared/highlighters.mjs"
     16 );
     17 const HIGHLIGHTER_TYPE = TYPES.GEOMETRY;
     18 const PROPS = ["left", "right", "top", "bottom"];
     19 
     20 add_task(async function () {
     21  const helper = await openInspectorForURL(TEST_URL).then(
     22    getHighlighterHelperFor(HIGHLIGHTER_TYPE)
     23  );
     24 
     25  helper.prefix = ID;
     26 
     27  const { finalize } = helper;
     28 
     29  await checkArrowsLabelsAndHandlers(
     30    "#node2",
     31    ["top", "left", "bottom", "right"],
     32    helper
     33  );
     34 
     35  await checkArrowsLabelsAndHandlers("#node3", ["top", "left"], helper);
     36 
     37  await finalize();
     38 });
     39 
     40 async function checkArrowsLabelsAndHandlers(
     41  selector,
     42  expectedProperties,
     43  { show, hide, isElementHidden }
     44 ) {
     45  info("Getting node " + selector + " from the page");
     46 
     47  await show(selector);
     48 
     49  for (const name of expectedProperties) {
     50    const hidden =
     51      (await isElementHidden("arrow-" + name)) &&
     52      (await isElementHidden("handler-" + name));
     53    ok(
     54      !hidden,
     55      "The " + name + " label/arrow & handler is visible for node " + selector
     56    );
     57  }
     58 
     59  // Testing that the other arrows are hidden
     60  for (const name of PROPS) {
     61    if (expectedProperties.includes(name)) {
     62      continue;
     63    }
     64    const hidden =
     65      (await isElementHidden("arrow-" + name)) &&
     66      (await isElementHidden("handler-" + name));
     67    ok(
     68      hidden,
     69      "The " + name + " arrow & handler is hidden for node " + selector
     70    );
     71  }
     72 
     73  info("Hiding the highlighter");
     74  await hide();
     75 }