tor-browser

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

browser_inspector_highlighter-08.js (2661B)


      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 // Test that performing multiple requests to highlight nodes or to hide the highlighter,
      8 // without waiting for the former ones to complete, still works well.
      9 add_task(async function () {
     10  info("Loading the test document and opening the inspector");
     11  const { inspector, highlighterTestFront } =
     12    await openInspectorForURL("data:text/html,");
     13  const html = await getNodeFront("html", inspector);
     14  const body = await getNodeFront("body", inspector);
     15  const type = inspector.highlighters.TYPES.BOXMODEL;
     16  const getActiveHighlighter = () => {
     17    return inspector.highlighters.getActiveHighlighter(type);
     18  };
     19  is(getActiveHighlighter(), null, "The highlighter is hidden by default");
     20 
     21  info("Highlight <body>, and hide the highlighter immediately after");
     22  await Promise.all([
     23    inspector.highlighters.showHighlighterTypeForNode(type, body),
     24    inspector.highlighters.hideHighlighterType(type),
     25  ]);
     26  is(getActiveHighlighter(), null, "The highlighter is hidden");
     27 
     28  info("Highlight <body>, then <html>, then <body> again, synchronously");
     29  await Promise.all([
     30    inspector.highlighters.showHighlighterTypeForNode(type, body),
     31    inspector.highlighters.showHighlighterTypeForNode(type, html),
     32    inspector.highlighters.showHighlighterTypeForNode(type, body),
     33  ]);
     34  ok(
     35    await highlighterTestFront.assertHighlightedNode("body"),
     36    "The highlighter highlights <body>"
     37  );
     38 
     39  info("Highlight <html>, then <body>, then <html> again, synchronously");
     40  await Promise.all([
     41    inspector.highlighters.showHighlighterTypeForNode(type, html),
     42    inspector.highlighters.showHighlighterTypeForNode(type, body),
     43    inspector.highlighters.showHighlighterTypeForNode(type, html),
     44  ]);
     45  ok(
     46    await highlighterTestFront.assertHighlightedNode("html"),
     47    "The highlighter highlights <html>"
     48  );
     49 
     50  info("Hide the highlighter, and highlight <html> immediately after");
     51  await Promise.all([
     52    inspector.highlighters.hideHighlighterType(type),
     53    inspector.highlighters.showHighlighterTypeForNode(type, body),
     54  ]);
     55  ok(
     56    await highlighterTestFront.assertHighlightedNode("body"),
     57    "The highlighter highlights <body>"
     58  );
     59 
     60  info("Highlight <html>, and hide the highlighter immediately after");
     61  await Promise.all([
     62    inspector.highlighters.showHighlighterTypeForNode(type, html),
     63    inspector.highlighters.hideHighlighterType(type),
     64  ]);
     65  is(getActiveHighlighter(), null, "The highlighter is hidden");
     66 });