4 <title>Test for CSS Selectors
</title>
6 Separate from test_selectors.html so we don't need to deal with
7 waiting for the binding document to load.
9 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
10 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
12 <style type=
"text/css">
14 #display { -moz-binding: url
(xbl_bindings
.xml#onedivchild
); }
19 <div id=
"display"></div>
21 <script class=
"testbody" type=
"text/javascript">
23 SimpleTest.waitForExplicitFinish();
27 function setup_style() {
28 var style_elem = document.createElement(
"style");
29 style_elem.setAttribute(
"type",
"text/css");
30 document.getElementsByTagName(
"head")[
0].appendChild(style_elem);
31 var style_text = document.createTextNode(
"");
32 style_elem.appendChild(style_text);
36 var style_text = setup_style();
40 function test_selector(selector, matches_docdiv, matches_anondiv)
43 style_text.data = selector +
"{ z-index: " + zi +
" }";
45 var doc_div = document.getElementById(
"display");
46 var anon_div = document.getAnonymousNodes(doc_div)[
0];
47 var should_match = [];
48 var should_not_match = [];
49 (matches_docdiv ? should_match : should_not_match).push(doc_div);
50 (matches_anondiv ? should_match : should_not_match).push(anon_div);
52 for (var i =
0; i < should_match.length; ++i) {
53 var e = should_match[i];
54 is(getComputedStyle(e,
"").zIndex, zi,
55 "element matched " + selector);
57 for (var i =
0; i < should_not_match.length; ++i) {
58 var e = should_not_match[i];
59 is(getComputedStyle(e,
"").zIndex,
"auto",
60 "element did not match " + selector);
66 // Test that the root of an XBL1 anonymous content subtree doesn't
67 // match :nth-child().
68 test_selector(
"div.anondiv", false, true);
69 test_selector(
"div:nth-child(odd)", true, false);
70 test_selector(
"div:nth-child(even)", false, false);