4 <title>Test InspectorUtils.parseStyleSheet with nested rules
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
18 <h1>Hello
<span class=
"mySpan">world
</span>
22 // This is important to reproduce the original issue
23 document
.documentElement
.getBoundingClientRect();
25 const InspectorUtils
= SpecialPowers
.InspectorUtils
;
26 const sheet
= document
.styleSheets
[0];
27 const spanEl
= document
.querySelector(".mySpan");
30 sheet
.cssRules
[0].cssRules
[0].cssRules
[0].cssText
,
31 `&.mySpan { color: red; }`,
32 "Nested rule has expected initial text"
36 InspectorUtils
.getMatchingCSSRules(spanEl
).length
,
38 "getMatchingCSSRules returned 2 rules for .mySpan"
41 info("Modify stylesheet using InspectorUtils.parseStyleSheet");
42 InspectorUtils
.parseStyleSheet(
55 sheet
.cssRules
[0].cssRules
[0].cssRules
[0].cssText
,
56 `&.mySpan { color: black; }`,
57 "Nested rule has expected text after updating the stylesheet"
61 // This is important to reproduce the original issue
62 document
.documentElement
.getBoundingClientRect();
65 getComputedStyle(spanEl
).color
,
67 "the color of the span element was properly updated"
69 const rules
= InspectorUtils
.getMatchingCSSRules(spanEl
);
73 "getMatchingCSSRules still returned 2 rules for .mySpan after stylesheet was updated"
75 is(rules
[1].style
.color
, "black", "rule was properly updated");