2 <title>Test getMatchingCSSRules for pseudo elements
</title>
3 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
4 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
7 <test-element id=
"test1" slot=
"slot1">test1
</test-element>
8 <test-element id=
"test2" slot=
"slot2">test2
</test-element>
12 const host
= document
.getElementById("host");
13 const shadow
= host
.attachShadow({ mode
: "open" });
16 #outer ::slotted(test-element) {
21 <slot name="slot1"></slot>
24 <slot name="slot2"></slot>
28 const nested
= shadow
.querySelector("#nested").attachShadow({ mode
: "open" });
31 #inner ::slotted(test-element) {
40 const InspectorUtils
= SpecialPowers
.InspectorUtils
;
42 function checkElementRules(id
, text
, property
) {
43 const element
= document
.getElementById(id
);
44 let slottedRules
= InspectorUtils
.getMatchingCSSRules(element
);
45 is(slottedRules
.length
, 1, "Slotted element has expected number of rules.");
47 let slottedText
= slottedRules
[0].cssText
;
48 ok(slottedText
.includes(text
), "Slotted node has expected style content.");
49 ok(slottedText
.includes(property
), "Has expected property.");
52 info("Check that slotted rules are retrieved");
53 checkElementRules("test1", "#outer ::slotted(test-element)", "color");
55 info("Check that slotted rules are also retrieved for nested slots");
56 checkElementRules("test2", "#inner ::slotted(test-element)", "font-weight");