2 <script src=
"../../resources/js-test.js"></script>
5 :-webkit-any( #div1, b ),
6 :-webkit-any(.foo, #bar),
7 :-webkit-any(i,p,:link,span:focus) {
8 background-color: blue;
11 #test-last-child :-webkit-any(:last-child),
12 :-webkit-any(:link:focus),
13 #container-div :-webkit-any(:link, :not(a)),
14 h1:-webkit-any(.h1class, #bar) {
15 background-color: green;
18 /* Only simple selectors should work. */
20 background-color: red;
23 :-webkit-any(s,:nonexistentpseudo) {
24 background-color: red;
28 background-color: blue;
30 :-webkit-any(div ~ q) {
31 background-color: red;
34 background-color: red;
38 background-color: blue;
41 background-color: red;
45 background-color: blue;
47 :-webkit-any(q
>span) {
48 background-color: red;
52 background-color: blue;
54 :-webkit-any(div span) {
55 background-color: red;
57 :-webkit-any( div span ) {
58 background-color: red;
61 This page tests :-webkit-any. This window needs to be focused for the :focus tests to pass.
<br>
63 <h1 class=
"h1class">h1
</h1>
64 <div id=
"div1">div
</div>
69 <a href=
"http://webkit.org">a
</a>
70 <span id=
"span1">span
<span>
71 <li class=
"foo">li
</li>
74 <div id=
"container-div"><input type='text'
><a href='http://www.example.com/'
></a><div></div><a name='foo'
></div>
75 <div><span>div span
</span></div>
78 <q><span>q
>span
</span></q>
79 <div id=
"test-last-child"><p>first
</p><p>last
</p></div>
80 <pre id=
"console"></pre>
83 if (window
.testRunner
)
84 testRunner
.dumpAsText();
86 function assertColor(selectorOrElement
, rbgColor
)
90 if (typeof selectorOrElement
== "string") {
91 debug(selectorOrElement
);
92 element
= document
.querySelector(selectorOrElement
);
94 debug("Element: " + element
.nodeName
);
95 element
= selectorOrElement
;
98 shouldBe("document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color')", rbgColor
);
101 function assertBlue(selectorOrElement
)
103 assertColor(selectorOrElement
, "'rgb(0, 0, 255)'")
106 function assertWhite(selectorOrElement
)
108 assertColor(selectorOrElement
, "'rgba(0, 0, 0, 0)'")
111 function assertGreen(selectorOrElement
)
113 assertColor(selectorOrElement
, "'rgb(0, 128, 0)'")
116 function focus(selector
)
118 var element
= document
.querySelector(selector
);
119 element
.tabIndex
= -1;
126 // Ensure the div with ID after the first div does not share a ComputedStyle with the first div.
127 assertWhite(document
.querySelectorAll("div")[1]);
133 assertWhite("#span1");
135 assertBlue("span:focus");
139 assertGreen("a:focus");
144 assertGreen("h1.h1class");
147 shouldBe("document.querySelectorAll('#container-div :-webkit-any([href],input[type],input[name])').length", "2");
148 shouldBe("document.querySelectorAll('#container-div :-webkit-any(div,a):-webkit-any([type],[href],[name])').length", "2");
149 shouldBe("document.querySelectorAll('#container-div :-webkit-any(:link, :not(a))').length", "3");
150 assertGreen("#container-div input");
151 assertGreen("#container-div a[href]");
152 assertGreen("#container-div div");
153 assertWhite("#container-div a[name]");
156 assertBlue("div span");
157 assertBlue("div ~ q");
159 assertBlue("q>span");
161 assertBlue("#test-last-child :first-child");
162 assertGreen("#test-last-child :last-child");