tor-browser

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

browser_inspector_breadcrumbs_namespaced.js (1958B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Test that the breadcrumbs widget content for namespaced elements is correct.
      6 
      7 const XHTML = `
      8  <!DOCTYPE html>
      9  <html xmlns="http://www.w3.org/1999/xhtml"
     10        xmlns:svg="http://www.w3.org/2000/svg">
     11    <body>
     12      <svg:svg width="100" height="100">
     13        <svg:clipPath id="clip">
     14          <svg:rect id="rectangle" x="0" y="0" width="10" height="5"></svg:rect>
     15        </svg:clipPath>
     16        <svg:circle cx="0" cy="0" r="5"></svg:circle>
     17      </svg:svg>
     18    </body>
     19  </html>
     20 `;
     21 
     22 const TEST_URI = "data:application/xhtml+xml;charset=utf-8," + encodeURI(XHTML);
     23 
     24 const NODES = [
     25  {
     26    selector: "clipPath",
     27    nodes: ["svg:svg", "svg:clipPath"],
     28    nodeName: "svg:clipPath",
     29    title: "svg:clipPath#clip",
     30  },
     31  {
     32    selector: "circle",
     33    nodes: ["svg:svg", "svg:circle"],
     34    nodeName: "svg:circle",
     35    title: "svg:circle",
     36  },
     37 ];
     38 
     39 add_task(async function () {
     40  const { inspector } = await openInspectorForURL(TEST_URI);
     41  const container = inspector.panelDoc.getElementById("inspector-breadcrumbs");
     42 
     43  for (const node of NODES) {
     44    info("Testing node " + node.selector);
     45 
     46    info("Selecting node and waiting for breadcrumbs to update");
     47    const breadcrumbsUpdated = inspector.once("breadcrumbs-updated");
     48    await selectNode(node.selector, inspector);
     49    await breadcrumbsUpdated;
     50 
     51    info("Performing checks for node " + node.selector);
     52 
     53    const checkedButton = container.querySelector(
     54      `button[aria-pressed="true"]`
     55    );
     56 
     57    const labelTag = checkedButton.querySelector(
     58      ".breadcrumbs-widget-item-tag"
     59    );
     60    is(
     61      labelTag.textContent,
     62      node.nodeName,
     63      "Node " + node.selector + " has the expected tag name"
     64    );
     65 
     66    is(
     67      checkedButton.getAttribute("title"),
     68      node.title,
     69      "Node " + node.selector + " has the expected tooltip"
     70    );
     71  }
     72 });