tor-browser

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

browser_computed_matched-selectors_02.js (1253B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests for matched selector texts in the computed view.
      7 
      8 add_task(async function () {
      9  await addTab("data:text/html;charset=utf-8,<div style='color:blue;'></div>");
     10  const { inspector, view } = await openComputedView();
     11  await selectNode("div", inspector);
     12 
     13  info("Checking the color property view");
     14  const propertyView = getPropertyView(view, "color");
     15  ok(propertyView, "found PropertyView for color");
     16  is(propertyView.hasMatchedSelectors, true, "hasMatchedSelectors is true");
     17 
     18  info("Expanding the matched selectors");
     19  propertyView.matchedExpanded = true;
     20  await propertyView.refreshMatchedSelectors();
     21 
     22  const span =
     23    propertyView.matchedSelectorsContainer.querySelector("span.rule-text");
     24  ok(span, "Found the first table row");
     25 
     26  const selector = propertyView.matchedSelectorViews[0];
     27  ok(selector, "Found the first matched selector view");
     28 });
     29 
     30 function getPropertyView(computedView, name) {
     31  let propertyView = null;
     32  computedView.propertyViews.some(function (view) {
     33    if (view.name == name) {
     34      propertyView = view;
     35      return true;
     36    }
     37    return false;
     38  });
     39  return propertyView;
     40 }