1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6 <div class=
"two">Line
2</div>
9 <div id=
"test" class=
"one two">
13 <div id=
"Test2" class=
"one two">line
4</div>
14 <p class=
"two">line
5</p>
17 <pre id=
"console"></pre>
18 <script type=
"text/javascript">
19 if (window
.testRunner
)
20 testRunner
.dumpAsText();
24 document
.getElementById('console').appendChild(document
.createTextNode(message
+ "\n"));
27 Element
.prototype.dump = function()
32 NodeList
.prototype.dump = function()
35 var length
= this.length
;
36 for (var i
= 0; i
< length
; i
++)
37 result
+= this[i
] + ", ";
38 result
+= "length: " + length
;
42 testQuerySelectorAll = function(node
, selectorString
)
45 log(node
.querySelectorAll(selectorString
).dump());
51 testQuerySelector = function(node
, selectorString
)
54 log(node
.querySelector(selectorString
).dump());
60 var elm
= document
.getElementById("test");
62 var tagString
= elm
.outerHTML
;
63 var range
= document
.createRange();
64 range
.selectNode(elm
);
65 var frag
= range
.createContextualFragment(tagString
);
67 log("Document.querySelectorAll");
70 testQuerySelectorAll(document
, "#test");
71 testQuerySelectorAll(document
, "#notthere");
72 testQuerySelectorAll(document
, "#dupe");
73 testQuerySelectorAll(document
, ".two");
74 testQuerySelectorAll(document
, ".one, .two");
75 testQuerySelectorAll(document
, "@font-face");
76 testQuerySelectorAll(document
, "");
77 testQuerySelectorAll(document
, null);
78 testQuerySelectorAll(document
, undefined);
79 testQuerySelectorAll(document
, "#test>div");
82 log("Element.querySelectorAll");
85 testQuerySelectorAll(elm
, "#test");
86 testQuerySelectorAll(elm
, "#Test2");
87 testQuerySelectorAll(elm
, "#notthere");
88 testQuerySelectorAll(elm
, "#dupe");
89 testQuerySelectorAll(elm
, ".two");
90 testQuerySelectorAll(elm
, ".one, .two");
91 testQuerySelectorAll(elm
, "@font-face");
92 testQuerySelectorAll(elm
, "");
93 testQuerySelectorAll(elm
, null);
94 testQuerySelectorAll(elm
, undefined);
97 log("DocumentFragment.querySelectorAll");
100 testQuerySelectorAll(frag
, "#test");
101 testQuerySelectorAll(frag
, "#Test2");
102 testQuerySelectorAll(frag
, "#notthere");
103 testQuerySelectorAll(frag
, "#dupe");
104 testQuerySelectorAll(frag
, ".two");
105 testQuerySelectorAll(frag
, ".one, .two");
106 testQuerySelectorAll(frag
, "@font-face");
107 testQuerySelectorAll(frag
, "");
108 testQuerySelectorAll(frag
, null);
109 testQuerySelectorAll(frag
, undefined);
112 log("Document.querySelector");
115 testQuerySelector(document
, "#test");
116 testQuerySelector(document
, "#notthere");
117 testQuerySelector(document
, "#dupe");
118 testQuerySelector(document
, ".two");
119 testQuerySelector(document
, ".one, .two");
120 testQuerySelector(document
, "@font-face");
121 testQuerySelector(document
, "");
122 testQuerySelector(document
, null);
123 testQuerySelector(document
, undefined);
126 log("Element.querySelector");
129 testQuerySelector(elm
, "#test");
130 testQuerySelector(elm
, "#Test2");
131 testQuerySelector(elm
, "#notthere");
132 testQuerySelector(elm
, "#dupe");
133 testQuerySelector(elm
, ".two");
134 testQuerySelector(elm
, ".one, .two");
135 testQuerySelector(elm
, "@font-face");
136 testQuerySelector(elm
, "");
137 testQuerySelector(elm
, null);
138 testQuerySelector(elm
, undefined);
141 log("DocumentFragment.querySelector");
144 testQuerySelector(frag
, "#test");
145 testQuerySelector(frag
, "#Test2");
146 testQuerySelector(frag
, "#notthere");
147 testQuerySelector(frag
, "#dupe");
148 testQuerySelector(frag
, ".two");
149 testQuerySelector(frag
, ".one, .two");
150 testQuerySelector(frag
, "@font-face");
151 testQuerySelector(frag
, "");
152 testQuerySelector(frag
, null);
153 testQuerySelector(frag
, undefined);