tor-browser

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

browser_computed_matched-selectors_01.js (1309B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Checking selector counts, matched rules and titles in the computed-view.
      7 
      8 const {
      9  PropertyView,
     10 } = require("resource://devtools/client/inspector/computed/computed.js");
     11 const TEST_URI = URL_ROOT + "doc_matched_selectors.html";
     12 
     13 add_task(async function () {
     14  await addTab(TEST_URI);
     15  const { inspector, view } = await openComputedView();
     16 
     17  await selectNode("#test", inspector);
     18  await testMatchedSelectors(view, inspector);
     19 });
     20 
     21 async function testMatchedSelectors(view, inspector) {
     22  info("checking selector counts, matched rules and titles");
     23 
     24  const nodeFront = await getNodeFront("#test", inspector);
     25  is(
     26    nodeFront,
     27    view.viewedElement,
     28    "style inspector node matches the selected node"
     29  );
     30 
     31  const propertyView = new PropertyView(view, "color");
     32  propertyView.createListItemElement();
     33  propertyView.matchedExpanded = true;
     34 
     35  await propertyView.refreshMatchedSelectors();
     36 
     37  const numMatchedSelectors = propertyView.matchedSelectors.length;
     38  is(
     39    numMatchedSelectors,
     40    7,
     41    "CssLogic returns the correct number of matched selectors for div"
     42  );
     43  is(
     44    propertyView.hasMatchedSelectors,
     45    true,
     46    "hasMatchedSelectors returns true"
     47  );
     48 }