4 <title>Test for WebKit bug
78595: CollectingRules and QueryingRules modes of SelectorChecker miss some complex selectors with pseudo elements
</title>
5 <style type=
"text/css">
6 .parent.secondParent .firstChild:before {
11 .topParent.topmost .parent.secondParent .secondChild:before {
16 .parent.secondParent > .thirdChild:before {
21 .topParent.topmost > .parent.secondParent > .fourthChild:before {
26 .parent.predecessor + .parent.firstParent:before {
31 .parent.firstParent ~ .secondParent:before {
36 .parent.firstParent + .parent.secondParent + .thirdParent:before {
41 .parent.predecessor ~ .parent.secondParent ~ .fourthParent:before {
55 <script type=
"text/javascript">
56 if (window
.testRunner
)
57 testRunner
.dumpAsText();
60 { 'elementId' : 'firstChild', 'expectedValue' : 'brown' },
61 { 'elementId' : 'secondChild', 'expectedValue' : 'cyan' },
62 { 'elementId' : 'thirdChild', 'expectedValue' : 'red' },
63 { 'elementId' : 'fourthChild', 'expectedValue' : 'magenta' },
64 { 'elementId' : 'firstParent', 'expectedValue' : 'green' },
65 { 'elementId' : 'secondParent', 'expectedValue' : 'lime' },
66 { 'elementId' : 'thirdParent', 'expectedValue' : 'blue' },
67 { 'elementId' : 'fourthParent', 'expectedValue' : 'crimson' },
72 var resultsElement
= document
.getElementById('results');
74 tests
.forEach(function(curTest
) {
75 var msg
= document
.createElement('div');
76 var element
= document
.querySelector("#" + curTest
.elementId
);
81 mainMessage
= "Element with id #" + curTest
.elementId
+ " not found";
83 matchedRules
= window
.getMatchedCSSRules(element
, "before");
84 if (!matchedRules
|| matchedRules
.length
!== 1)
85 mainMessage
= " Matching rules for #" + curTest
.elementId
+ ":before do not contain a single rule";
88 msg
.innerHTML
= "<span class='fail'>FAIL</span>" + mainMessage
;
89 resultsElement
.appendChild(msg
);
92 var value
= matchedRules
[0].style
.color
;
93 mainMessage
= " Expected '" + curTest
.expectedValue
+ "' for color in the matched CSS rule for element with id " +
94 curTest
.elementId
+ " and pseudo-element :before";
95 if (value
== curTest
.expectedValue
)
96 msg
.innerHTML
= "<span class='pass'>PASS</span>" + mainMessage
+ " and got '" + value
+ "'";
98 msg
.innerHTML
= "<span class='fail'>FAIL</span>" + mainMessage
+ " but instead got '" + value
+ "'";
99 resultsElement
.appendChild(msg
);
102 if (window
.testRunner
)
103 testRunner
.notifyDone();
107 <body onload=
"runTests();">
108 <h3>Test for
<a href=
"https://bugs.webkit.org/show_bug.cgi?id=24021">WebKit bug
78595</a>: CollectingRules and QueryingRules modes of SelectorChecker miss some complex selectors with pseudo elements
</h3>
110 <div class=
"topParent topmost">
111 <div class=
"parent predecessor"></div>
112 <div class=
"parent firstParent" id=
"firstParent"></div>
113 <div class=
"parent secondParent" id=
"secondParent">
114 <div class=
"firstChild" id=
"firstChild"></div>
115 <div class=
"secondChild" id=
"secondChild"></div>
116 <div class=
"thirdChild" id=
"thirdChild"></div>
117 <div class=
"fourthChild" id=
"fourthChild"></div>
119 <div class=
"parent thirdParent" id=
"thirdParent"></div>
120 <div class=
"parent fourthParent" id=
"fourthParent"></div>
123 <div id=
"results"></div>