Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / HTMLDocument / document-special-properties.html
1 <body>
2
3 <p>This test covers the various ways of accessing DOM elements through
4 the document object by name, id or index, directly as properties of
5 the document object. This lookup is supposed to include applet, embed,
6 form, image, object and iframe by name, but only applet and object by
7 id. It should give the element itself in the case of a single match,
8 or an HTMLCollection in the case of multiple matches; except that when
9 exactly one item that is an iframe matches, it will give the window
10 object for that iframe.
11 </p>
12
13 <p>Our results match IE.</p>
14
15 <hr>
16
17 <script>
18 document.custom=new Object();
19
20 if (window.testRunner)
21     window.testRunner.dumpAsText();
22 </script>
23
24 <div style="visibility: hidden; width: 0px; height: 0px;">
25 <img name="image1" width="0" height="0">
26 <img name="image2" width="0" height="0">
27 <img name="image2" width="0" height="0">
28 <img id="image3" width="0" height="0">
29 <img id="image4" width="0" height="0">
30 <img id="image4" width="0" height="0">
31 <img id="image5" width="0" height="0">
32 <img name="image5" width="0" height="0">
33 <img name="image5" width="0" height="0">
34 <img id="image5" width="0" height="0">
35 <img id="image6" name="image6name" width="0" height="0">
36 <img id="image7" name="" width="0" height="0">
37 <img id="image8" name="image8name" width="0" height="0">
38 <img id="image8" width="0" height="0">
39 <img id="image8" name="image7name" width="0" height="0">
40 <img id="image9" name="image9name" width="0" height="0">
41
42 <form name="form1" width="0" height="0"></form>
43 <form name="form2" width="0" height="0"></form>
44 <form name="form2" width="0" height="0"></form>
45 <form id="form3" width="0" height="0"></form>
46 <form id="form4" width="0" height="0"></form>
47 <form id="form4" width="0" height="0"></form>
48 <form id="form5" width="0" height="0"></form>
49 <form name="form5" width="0" height="0"></form>
50 <form name="form5" width="0" height="0"></form>
51 <form id="form5" width="0" height="0"></form>
52
53 <applet name="applet1" width="0" height="0"></applet>
54 <applet name="applet2" width="0" height="0"></applet>
55 <applet name="applet2" width="0" height="0"></applet>
56 <applet id="applet3" width="0" height="0"></applet>
57 <applet id="applet4" width="0" height="0"></applet>
58 <applet id="applet4" width="0" height="0"></applet>
59 <applet id="applet5" width="0" height="0"></applet>
60 <applet name="applet5" width="0" height="0"></applet>
61 <applet name="applet5" width="0" height="0"></applet>
62 <applet id="applet5" width="0" height="0"></applet>
63
64 <embed name="embed1" width="0" height="0"></embed>
65 <embed name="embed2" width="0" height="0"></embed>
66 <embed name="embed2" width="0" height="0"></embed>
67 <embed id="embed3" width="0" height="0"></embed>
68 <embed id="embed4" width="0" height="0"></embed>
69 <embed id="embed4" width="0" height="0"></embed>
70 <embed id="embed5" width="0" height="0"></embed>
71 <embed name="embed5" width="0" height="0"></embed>
72 <embed name="embed5" width="0" height="0"></embed>
73 <embed id="embed5" width="0" height="0"></embed>
74 <object name="embed6"><embed name="embed6"></embed></object>
75 <object name="embed7_0"><embed name="embed7"></embed></object>
76 <object name="object8_0" width="0" height="0"><param><embed name="embed8" width="0" height="0"></object></param></object>
77
78 <object name="object1" width="0" height="0"></object>
79 <object name="object2" width="0" height="0"></object>
80 <object name="object2" width="0" height="0"></object>
81 <object id="object3" width="0" height="0"></object>
82 <object id="object4" width="0" height="0"></object>
83 <object id="object4" width="0" height="0"></object>
84 <object id="object5" width="0" height="0"></object>
85 <object name="object5" width="0" height="0"></object>
86 <object name="object5" width="0" height="0"></object>
87 <object id="object5" width="0" height="0"></object>
88 <object name="object6" width="0" height="0"><object name="object6" width="0" height="0"></object></object>
89 <object name="object7_0" width="0" height="0"><object name="object7" width="0" height="0"></object></object>
90
91 <iframe name="iframe1" width="0" height="0"></iframe>
92 <iframe name="iframe2" width="0" height="0"></iframe>
93 <iframe name="iframe2" width="0" height="0"></iframe>
94 <iframe id="iframe3" width="0" height="0"></iframe>
95 <iframe id="iframe4" width="0" height="0"></iframe>
96 <iframe id="iframe4" width="0" height="0"></iframe>
97 <iframe id="iframe5" width="0" height="0"></iframe>
98 <iframe name="iframe5" width="0" height="0"></iframe>
99 <iframe name="iframe5" width="0" height="0"></iframe>
100 <iframe id="iframe5" width="0" height="0"></iframe>
101
102 <span name="span1" width="0" height="0"></span>
103 <span name="span2" width="0" height="0"></span>
104 <span name="span2" width="0" height="0"></span>
105 <span id="span3" width="0" height="0"></span>
106 <span id="span4" width="0" height="0"></span>
107 <span id="span4" width="0" height="0"></span>
108 <span id="span5" width="0" height="0"></span>
109 <span name="span5" width="0" height="0"></span>
110 <span name="span5" width="0" height="0"></span>
111 <span id="span5" width="0" height="0"></span>
112
113 <img id="mixed1" width="0" height="0">
114 <form id="mixed1" width="0" height="0"></form>
115 <applet id="mixed1" width="0" height="0"></applet>
116 <embed id="mixed1" width="0" height="0"></embed>
117 <object id="mixed1" width="0" height="0"></object>
118 <iframe id="mixed1" width="0" height="0"></iframe>
119 <span id="mixed1" width="0" height="0"></span>
120
121 <img name="mixed2" width="0" height="0">
122 <form name="mixed2" width="0" height="0"></form>
123 <applet name="mixed2" width="0" height="0"></applet>
124 <embed name="mixed2" width="0" height="0"></embed>
125 <object name="mixed2" width="0" height="0"></object>
126 <iframe name="mixed2" width="0" height="0"></iframe>
127 <span name="mixed2" width="0" height="0"></span>
128
129 <img id="mixed3" width="0" height="0">
130 <form id="mixed3" width="0" height="0"></form>
131 <applet id="mixed3" width="0" height="0"></applet>
132 <embed id="mixed3" width="0" height="0"></embed>
133 <object id="mixed3" width="0" height="0"></object>
134 <span id="mixed3" width="0" height="0"></span>
135
136 <img name="mixed4" width="0" height="0">
137 <form name="mixed4" width="0" height="0"></form>
138 <applet name="mixed4" width="0" height="0"></applet>
139 <embed name="mixed4" width="0" height="0"></embed>
140 <object name="mixed4" width="0" height="0"></object>
141 <span name="mixed4" width="0" height="0"></span>
142
143 <img name="body" with="0" height="0">
144 <img name="custom" with="0" height="0">
145 <iframe name="location" with="0" height="0"></iframe>
146
147 </div>
148
149 <pre id="results">
150 Results:<br>
151 </pre>
152
153 <script>
154 function print(x)
155 {
156    document.getElementById("results").innerHTML += x;
157 }
158
159 function printElement(e)
160 {
161     if (e.tagName) {
162         print(" " + e.tagName);
163
164     if (e.name && e.id) {
165         print("(id,name)");
166     } else if (e.name) {
167         print("(name)");
168         } else if (e.id) {
169         print("(id)");
170     }
171     } else if (e.navigator) {
172         print(" WINDOW");
173     } else {
174         print(" OTHER");
175     }
176 }
177
178 function testProperty(description, propName) {
179     print(description);
180     print(":");
181     var propVal = document[propName];
182
183     if (!propVal) {
184         print(" undefined");
185     } else if (propVal.length) {
186         print(" collection(" + propVal.length + ")");
187     for (var i = 0; i < propVal.length; i++) {
188         printElement(propVal[i]);
189     }
190     } else {
191         print(" single");
192     printElement(propVal);
193     }
194     
195     print("<br>");
196 }
197
198 testProperty("Nonexistent image name", "image0");
199 testProperty("Image by name (unique)", "image1");
200 testProperty("Image by name (multiple)", "image2");
201 testProperty("Image by id (unique)", "image3");
202 testProperty("Image by id (multiple)", "image4");
203 testProperty("Image by id/name mixed", "image5");
204 testProperty("Image by id, name present (unique)", "image6");
205 testProperty("Image by id, empty name present (unique)", "image7");
206 testProperty("Image by id, name present (multiple)", "image8");
207 testProperty("Image by name, id present (unique)", "image9name");
208
209 print("<br>");
210
211 testProperty("Nonexistent form name", "form0");
212 testProperty("Form by name (unique)", "form1");
213 testProperty("Form by name (multiple)", "form2");
214 testProperty("Form by id (unique)", "form3");
215 testProperty("Form by id (multiple)", "form4");
216 testProperty("Form by id/name mixed", "form5");
217 print("<br>");
218
219 testProperty("Nonexistent applet name", "applet0");
220 testProperty("Applet by name (unique)", "applet1");
221 testProperty("Applet by name (multiple)", "applet2");
222 testProperty("Applet by id (unique)", "applet3");
223 testProperty("Applet by id (multiple)", "applet4");
224 testProperty("Applet by id/name mixed", "applet5");
225 print("<br>");
226
227 testProperty("Nonexistent object name", "object0");
228 testProperty("Object by name (unique)", "object1");
229 testProperty("Object by name (multiple)", "object2");
230 testProperty("Object by id (unique)", "object3");
231 testProperty("Object by id (multiple)", "object4");
232 testProperty("Object by id/name mixed", "object5");
233 testProperty("Object by name nested in object with the same name", "object6");
234 testProperty("Object by name nested in object with a different name", "object7");
235 print("<br>");
236
237 testProperty("Nonexistent embed name", "embed0");
238 testProperty("Embed by name (unique)", "embed1");
239 testProperty("Embed by name (multiple)", "embed2");
240 testProperty("Embed by id (unique)", "embed3");
241 testProperty("Embed by id (multiple)", "embed4");
242 testProperty("Embed by id/name mixed", "embed5");
243 testProperty("Embed by name nested in object with the same name", "embed6");
244 testProperty("Embed by name nested in object with a different name", "embed7");
245 testProperty("Embed by name nested in param of an object with a different name", "embed8");
246 print("<br>");
247
248 testProperty("Nonexistent iframe name", "iframe0");
249 testProperty("Iframe by name (unique)", "iframe1");
250 testProperty("Iframe by name (multiple)", "iframe2");
251 testProperty("Iframe by id (unique)", "iframe3");
252 testProperty("Iframe by id (multiple)", "iframe4");
253 testProperty("Iframe by id/name mixed", "iframe5");
254 print("<br>");
255
256 testProperty("Nonexistent span name", "span0");
257 testProperty("Span by name (unique)", "span1");
258 testProperty("Span by name (multiple)", "span2");
259 testProperty("Span by id (unique)", "span3");
260 testProperty("Span by id (multiple)", "span4");
261 testProperty("Span by id/name mixed", "span5");
262 print("<br>");
263
264 testProperty("Mixed by id", "mixed1");
265 testProperty("Mixed by name", "mixed2");
266 testProperty("Mixed by id (no iframe)", "mixed3");
267 testProperty("Mixed by name (no iframe)", "mixed4");
268 print("<br>");
269
270 testProperty("Numeric 0", 0);
271 testProperty("Numeric 12", 12);
272 testProperty("Numeric 13", 13);
273 print("<br>");
274
275 testProperty("Conflicting image", "body");
276 testProperty("Conflicting image (custom property)", "custom");
277 testProperty("Conflicting iframe", "location");
278
279 </script>
280 </body>