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.
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>
22 window
.custom
=new Object();
24 if (window
.testRunner
)
25 window
.testRunner
.dumpAsText();
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"/>
138 document
.getElementById("results").innerHTML
+= x
;
141 function printElement(e
)
144 print(" " + e
.tagName
);
146 if (e
.name
&& e
.id
) {
153 } else if (e
.navigator
) {
160 function testProperty(description
, propName
) {
163 var propVal
= window
[propName
];
167 } else if (propVal
.length
) {
168 print(" collection(" + propVal
.length
+ ")");
169 for (var i
= 0; i
< propVal
.length
; i
++) {
170 printElement(propVal
[i
]);
174 printElement(propVal
);
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");
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");
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");
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");
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");
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");
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");
234 testProperty("Numeric 0", 0);
235 testProperty("Numeric 12", 12);
236 testProperty("Numeric 13", 13);
239 testProperty("Conflicting image name", "navigator");
240 testProperty("Conflicting image name (custom property)", "custom");
241 testProperty("Conflicting iframe", "location");
244 testProperty("Input by id (unique)", "real_input");
245 testProperty("Conflicting input id (navigator)", "navigator");
246 testProperty("Conflicting input id (location)", "location");