tor-browser

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

browser_rules_add-rule-and-property.js (1466B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests adding a new rule and a new property in this rule.
      7 
      8 add_task(async function () {
      9  await addTab(
     10    "data:text/html;charset=utf-8,<div id='testid'>Styled Node</div>"
     11  );
     12  const { inspector, view } = await openRuleView();
     13 
     14  info("Selecting the test node");
     15  await selectNode("#testid", inspector);
     16 
     17  info("Adding a new rule for this node and blurring the new selector field");
     18  await addNewRuleAndDismissEditor(inspector, view, "#testid", 1);
     19 
     20  info("Adding a new property for this rule");
     21  const ruleEditor = getRuleViewRuleEditor(view, 1);
     22 
     23  const onRuleViewChanged = view.once("ruleview-changed");
     24  ruleEditor.addProperty("font-weight", "bold", "", true);
     25  await onRuleViewChanged;
     26 
     27  const textProps = ruleEditor.rule.textProps;
     28  const prop = textProps[textProps.length - 1];
     29  is(prop.name, "font-weight", "The last property name is font-weight");
     30  is(prop.value, "bold", "The last property value is bold");
     31 
     32  info(
     33    "Add another rule to make sure we reuse the stylesheet we created the first time we added a rule"
     34  );
     35  await addNewRuleAndDismissEditor(inspector, view, "#testid", 1);
     36 
     37  const styleSheetsCount = await SpecialPowers.spawn(
     38    gBrowser.selectedBrowser,
     39    [],
     40    () => content.document.styleSheets.length
     41  );
     42  is(styleSheetsCount, 1, "Only one stylesheet was created in the document");
     43 });