tor-browser

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

browser_rules_inherited-properties_03.js (1409B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Check that inline inherited properties appear in the nested element.
      7 
      8 var {
      9  style: { ELEMENT_STYLE },
     10 } = require("resource://devtools/shared/constants.js");
     11 
     12 const TEST_URI = `
     13  <div id="test2" style="color: red">
     14    <div id="test1">Styled Node</div>
     15  </div>
     16 `;
     17 
     18 add_task(async function () {
     19  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     20  const { inspector, view } = await openRuleView();
     21  await selectNode("#test1", inspector);
     22  await elementStyleInherit(inspector, view);
     23 });
     24 
     25 function elementStyleInherit(inspector, view) {
     26  const elementStyle = view._elementStyle;
     27  is(elementStyle.rules.length, 2, "Should have 2 rules.");
     28 
     29  const elementRule = elementStyle.rules[0];
     30  ok(
     31    !elementRule.inherited,
     32    "Element style attribute should not consider itself inherited."
     33  );
     34 
     35  const inheritRule = elementStyle.rules[1];
     36  is(
     37    inheritRule.domRule.type,
     38    ELEMENT_STYLE,
     39    "Inherited rule should be an element style, not a rule."
     40  );
     41  ok(!!inheritRule.inherited, "Rule should consider itself inherited.");
     42  is(
     43    inheritRule.textProps.length,
     44    1,
     45    "Should only display one inherited style"
     46  );
     47  const inheritProp = inheritRule.textProps[0];
     48  is(inheritProp.name, "color", "color should have been inherited.");
     49 }