Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-special-properties.html
blob0fd80d31eb6026109726c8f48dbb719a47ce46c6
1 <body>
3 <p>This test covers the various ways of accessing DOM elements through
4 the window object by name, id or index, directly as properties of the
5 window object. This lookup is supposed to include embed, form,
6 image and object by name, and all elements by id. It should give the
7 element itself in the case of a single match, or an HTMLCollection in
8 the case of multiple matches; except that when iframes are involved,
9 it will give the window object for the first iframe match.
10 </p>
12 <p>Our results match WinIE in all respects but one. We allow child
13 frame names to take precedence over built-in and custom properties of
14 the window object. This is the Mozilla behavior and is required to
15 make some sites work because they use frame names that collide with
16 built-in properties in Mozilla but not IE - specifically "toobar". See
17 <a href="rdar://problem/3870317">Radar 3870317</a>.</p>
19 <hr>
21 <script>
22 window.custom=new Object();
24 if (window.testRunner)
25 window.testRunner.dumpAsText();
26 </script>
28 <div style="visibility: hidden; width: 0px; height: 0px;">
29 <img name="image1" width="0" height="0">
30 <img name="image2" width="0" height="0">
31 <img name="image2" width="0" height="0">
32 <img id="image3" width="0" height="0">
33 <img id="image4" width="0" height="0">
34 <img id="image4" width="0" height="0">
35 <img id="image5" width="0" height="0">
36 <img name="image5" width="0" height="0">
37 <img name="image5" width="0" height="0">
38 <img id="image5" width="0" height="0">
40 <form name="form1" width="0" height="0"></form>
41 <form name="form2" width="0" height="0"></form>
42 <form name="form2" width="0" height="0"></form>
43 <form id="form3" width="0" height="0"></form>
44 <form id="form4" width="0" height="0"></form>
45 <form id="form4" width="0" height="0"></form>
46 <form id="form5" width="0" height="0"></form>
47 <form name="form5" width="0" height="0"></form>
48 <form name="form5" width="0" height="0"></form>
49 <form id="form5" width="0" height="0"></form>
51 <embed name="embed1" width="0" height="0"></embed>
52 <embed name="embed2" width="0" height="0"></embed>
53 <embed name="embed2" width="0" height="0"></embed>
54 <embed id="embed3" width="0" height="0"></embed>
55 <embed id="embed4" width="0" height="0"></embed>
56 <embed id="embed4" width="0" height="0"></embed>
57 <embed id="embed5" width="0" height="0"></embed>
58 <embed name="embed5" width="0" height="0"></embed>
59 <embed name="embed5" width="0" height="0"></embed>
60 <embed id="embed5" width="0" height="0"></embed>
62 <object name="object1" width="0" height="0"></object>
63 <object name="object2" width="0" height="0"></object>
64 <object name="object2" width="0" height="0"></object>
65 <object id="object3" width="0" height="0"></object>
66 <object id="object4" width="0" height="0"></object>
67 <object id="object4" width="0" height="0"></object>
68 <object id="object5" width="0" height="0"></object>
69 <object name="object5" width="0" height="0"></object>
70 <object name="object5" width="0" height="0"></object>
71 <object id="object5" width="0" height="0"></object>
73 <iframe name="iframe1" width="0" height="0"></iframe>
74 <iframe name="iframe2" width="0" height="0"></iframe>
75 <iframe name="iframe2" width="0" height="0"></iframe>
76 <iframe id="iframe3" width="0" height="0"></iframe>
77 <iframe id="iframe4" width="0" height="0"></iframe>
78 <iframe id="iframe4" width="0" height="0"></iframe>
79 <iframe id="iframe5" width="0" height="0"></iframe>
80 <iframe name="iframe5" width="0" height="0"></iframe>
81 <iframe name="iframe5" width="0" height="0"></iframe>
82 <iframe id="iframe5" width="0" height="0"></iframe>
84 <span name="span1" width="0" height="0"></span>
85 <span name="span2" width="0" height="0"></span>
86 <span name="span2" width="0" height="0"></span>
87 <span id="span3" width="0" height="0"></span>
88 <span id="span4" width="0" height="0"></span>
89 <span id="span4" width="0" height="0"></span>
90 <span id="span5" width="0" height="0"></span>
91 <span name="span5" width="0" height="0"></span>
92 <span name="span5" width="0" height="0"></span>
93 <span id="span5" width="0" height="0"></span>
95 <img id="mixed1" width="0" height="0">
96 <form id="mixed1" width="0" height="0"></form>
97 <embed id="mixed1" width="0" height="0"></embed>
98 <object id="mixed1" width="0" height="0"></object>
99 <iframe id="mixed1" width="0" height="0"></iframe>
100 <span id="mixed1" width="0" height="0"></span>
102 <img name="mixed2" width="0" height="0">
103 <form name="mixed2" width="0" height="0"></form>
104 <embed name="mixed2" width="0" height="0"></embed>
105 <object name="mixed2" width="0" height="0"></object>
106 <iframe name="mixed2" width="0" height="0"></iframe>
107 <span name="mixed2" width="0" height="0"></span>
109 <img id="mixed3" width="0" height="0">
110 <form id="mixed3" width="0" height="0"></form>
111 <embed id="mixed3" width="0" height="0"></embed>
112 <object id="mixed3" width="0" height="0"></object>
113 <span id="mixed3" width="0" height="0"></span>
115 <img name="mixed4" width="0" height="0">
116 <form name="mixed4" width="0" height="0"></form>
117 <embed name="mixed4" width="0" height="0"></embed>
118 <object name="mixed4" width="0" height="0"></object>
119 <span name="mixed4" width="0" height="0"></span>
121 <img name="navigator" with="0" height="0">
122 <img name="custom" with="0" height="0">
123 <iframe name="location" with="0" height="0"></iframe>
125 <input id="navigator" value="an input" type="text"/>
126 <input id="location" value="an input" type="text"/>
127 <input id="real_input" value="an input" type="text"/>
129 </div>
131 <pre id="results">
132 Results:<br>
133 </pre>
135 <script>
136 function print(x)
138 document.getElementById("results").innerHTML += x;
141 function printElement(e)
143 if (e.tagName) {
144 print(" " + e.tagName);
146 if (e.name && e.id) {
147 print("(id,name)");
148 } else if (e.name) {
149 print("(name)");
150 } else if (e.id) {
151 print("(id)");
153 } else if (e.navigator) {
154 print(" WINDOW");
155 } else {
156 print(" OTHER");
160 function testProperty(description, propName) {
161 print(description);
162 print(":");
163 var propVal = window[propName];
165 if (!propVal) {
166 print(" undefined");
167 } else if (propVal.length) {
168 print(" collection(" + propVal.length + ")");
169 for (var i = 0; i < propVal.length; i++) {
170 printElement(propVal[i]);
172 } else {
173 print(" single");
174 printElement(propVal);
177 print("<br>");
180 testProperty("Nonexistent image name", "image0");
181 testProperty("Image by name (unique)", "image1");
182 testProperty("Image by name (multiple)", "image2");
183 testProperty("Image by id (unique)", "image3");
184 testProperty("Image by id (multiple)", "image4");
185 testProperty("Image by id/name mixed", "image5");
186 print("<br>");
188 testProperty("Nonexistent form name", "form0");
189 testProperty("Form by name (unique)", "form1");
190 testProperty("Form by name (multiple)", "form2");
191 testProperty("Form by id (unique)", "form3");
192 testProperty("Form by id (multiple)", "form4");
193 testProperty("Form by id/name mixed", "form5");
194 print("<br>");
196 testProperty("Nonexistent object name", "object0");
197 testProperty("Object by name (unique)", "object1");
198 testProperty("Object by name (multiple)", "object2");
199 testProperty("Object by id (unique)", "object3");
200 testProperty("Object by id (multiple)", "object4");
201 testProperty("Object by id/name mixed", "object5");
202 print("<br>");
204 testProperty("Nonexistent embed name", "embed0");
205 testProperty("Embed by name (unique)", "embed1");
206 testProperty("Embed by name (multiple)", "embed2");
207 testProperty("Embed by id (unique)", "embed3");
208 testProperty("Embed by id (multiple)", "embed4");
209 testProperty("Embed by id/name mixed", "embed5");
210 print("<br>");
212 testProperty("Nonexistent iframe name", "iframe0");
213 testProperty("Iframe by name (unique)", "iframe1");
214 testProperty("Iframe by name (multiple)", "iframe2");
215 testProperty("Iframe by id (unique)", "iframe3");
216 testProperty("Iframe by id (multiple)", "iframe4");
217 testProperty("Iframe by id/name mixed", "iframe5");
218 print("<br>");
220 testProperty("Nonexistent span name", "span0");
221 testProperty("Span by name (unique)", "span1");
222 testProperty("Span by name (multiple)", "span2");
223 testProperty("Span by id (unique)", "span3");
224 testProperty("Span by id (multiple)", "span4");
225 testProperty("Span by id/name mixed", "span5");
226 print("<br>");
228 testProperty("Mixed by id", "mixed1");
229 testProperty("Mixed by name", "mixed2");
230 testProperty("Mixed by id (no iframe)", "mixed3");
231 testProperty("Mixed by name (no iframe)", "mixed4");
232 print("<br>");
234 testProperty("Numeric 0", 0);
235 testProperty("Numeric 12", 12);
236 testProperty("Numeric 13", 13);
237 print("<br>");
239 testProperty("Conflicting image name", "navigator");
240 testProperty("Conflicting image name (custom property)", "custom");
241 testProperty("Conflicting iframe", "location");
242 print("<br>");
244 testProperty("Input by id (unique)", "real_input");
245 testProperty("Conflicting input id (navigator)", "navigator");
246 testProperty("Conflicting input id (location)", "location");
248 </script>
249 </body>