tor-browser

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

browser_inspector_highlighter-embed.js (1161B)


      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 the highlighter can go inside <embed> elements
      8 
      9 const TEST_URL = URL_ROOT + "doc_inspector_embed.html";
     10 
     11 add_task(async function () {
     12  const { inspector } = await openInspectorForURL(TEST_URL);
     13 
     14  info("Get a node inside the <embed> element and select/highlight it");
     15  const body = await getEmbeddedBody(inspector);
     16  await selectAndHighlightNode(body, inspector);
     17 
     18  const selectedNode = inspector.selection.nodeFront;
     19  is(selectedNode.tagName.toLowerCase(), "body", "The selected node is <body>");
     20  ok(
     21    selectedNode.baseURI.endsWith("doc_inspector_menu.html"),
     22    "The selected node is the <body> node inside the <embed> element"
     23  );
     24 });
     25 
     26 async function getEmbeddedBody({ walker }) {
     27  const embed = await walker.querySelector(walker.rootNode, "embed");
     28  const { nodes } = await walker.children(embed);
     29  const contentDoc = nodes[0];
     30  const body = await walker.querySelector(contentDoc, "body");
     31  return body;
     32 }