Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / SelectorAPI / dumpNodeList-almost-strict.html
blob07286e89351e465117a13e076a1902bc221b5de5
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <body>
4 <div class="one">
5 Line 1
6 <div class="two">Line 2</div>
7 <p>Line <i>3</i></p>
8 </div>
9 <div id="test" class="one two">
10 <div id="me"></div>
11 <div id="dupe"></div>
12 <div id="dupe"></div>
13 <div id="Test2" class="one two">line 4</div>
14 <p class="two">line 5</p>
15 </div>
17 <pre id="console"></pre>
18 <script type="text/javascript">
19 if (window.testRunner)
20 testRunner.dumpAsText();
22 function log(message)
24 document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
27 Element.prototype.dump = function()
29 return this;
32 NodeList.prototype.dump = function()
34 var result = "";
35 var length = this.length;
36 for (var i = 0; i < length; i++)
37 result += this[i] + ", ";
38 result += "length: " + length;
39 return result;
42 testQuerySelectorAll = function(node, selectorString)
44 try {
45 log(node.querySelectorAll(selectorString).dump());
46 } catch (e) {
47 log(e);
51 testQuerySelector = function(node, selectorString)
53 try {
54 log(node.querySelector(selectorString).dump());
55 } catch (e) {
56 log(e);
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");
68 log("");
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");
81 log("");
82 log("Element.querySelectorAll");
83 log("");
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);
96 log("");
97 log("DocumentFragment.querySelectorAll");
98 log("");
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);
111 log("");
112 log("Document.querySelector");
113 log("");
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);
125 log("");
126 log("Element.querySelector");
127 log("");
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);
140 log("");
141 log("DocumentFragment.querySelector");
142 log("");
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);
154 </script>
155 </body>
156 </html>