1 | <body>
|
---|
2 |
|
---|
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 applet, 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>
|
---|
11 |
|
---|
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>
|
---|
18 |
|
---|
19 | <hr>
|
---|
20 |
|
---|
21 | <script>
|
---|
22 | window.custom=new Object();
|
---|
23 |
|
---|
24 | if (window.testRunner)
|
---|
25 | window.testRunner.dumpAsText();
|
---|
26 | </script>
|
---|
27 |
|
---|
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">
|
---|
39 |
|
---|
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>
|
---|
50 |
|
---|
51 | <applet name="applet1" width="0" height="0"></applet>
|
---|
52 | <applet name="applet2" width="0" height="0"></applet>
|
---|
53 | <applet name="applet2" width="0" height="0"></applet>
|
---|
54 | <applet id="applet3" width="0" height="0"></applet>
|
---|
55 | <applet id="applet4" width="0" height="0"></applet>
|
---|
56 | <applet id="applet4" width="0" height="0"></applet>
|
---|
57 | <applet id="applet5" width="0" height="0"></applet>
|
---|
58 | <applet name="applet5" width="0" height="0"></applet>
|
---|
59 | <applet name="applet5" width="0" height="0"></applet>
|
---|
60 | <applet id="applet5" width="0" height="0"></applet>
|
---|
61 |
|
---|
62 | <embed name="embed1" width="0" height="0"></embed>
|
---|
63 | <embed name="embed2" width="0" height="0"></embed>
|
---|
64 | <embed name="embed2" width="0" height="0"></embed>
|
---|
65 | <embed id="embed3" width="0" height="0"></embed>
|
---|
66 | <embed id="embed4" width="0" height="0"></embed>
|
---|
67 | <embed id="embed4" width="0" height="0"></embed>
|
---|
68 | <embed id="embed5" width="0" height="0"></embed>
|
---|
69 | <embed name="embed5" width="0" height="0"></embed>
|
---|
70 | <embed name="embed5" width="0" height="0"></embed>
|
---|
71 | <embed id="embed5" width="0" height="0"></embed>
|
---|
72 |
|
---|
73 | <object name="object1" width="0" height="0"></object>
|
---|
74 | <object name="object2" width="0" height="0"></object>
|
---|
75 | <object name="object2" width="0" height="0"></object>
|
---|
76 | <object id="object3" width="0" height="0"></object>
|
---|
77 | <object id="object4" width="0" height="0"></object>
|
---|
78 | <object id="object4" width="0" height="0"></object>
|
---|
79 | <object id="object5" width="0" height="0"></object>
|
---|
80 | <object name="object5" width="0" height="0"></object>
|
---|
81 | <object name="object5" width="0" height="0"></object>
|
---|
82 | <object id="object5" width="0" height="0"></object>
|
---|
83 |
|
---|
84 | <iframe name="iframe1" width="0" height="0"></iframe>
|
---|
85 | <iframe name="iframe2" width="0" height="0"></iframe>
|
---|
86 | <iframe name="iframe2" width="0" height="0"></iframe>
|
---|
87 | <iframe id="iframe3" width="0" height="0"></iframe>
|
---|
88 | <iframe id="iframe4" width="0" height="0"></iframe>
|
---|
89 | <iframe id="iframe4" width="0" height="0"></iframe>
|
---|
90 | <iframe id="iframe5" width="0" height="0"></iframe>
|
---|
91 | <iframe name="iframe5" width="0" height="0"></iframe>
|
---|
92 | <iframe name="iframe5" width="0" height="0"></iframe>
|
---|
93 | <iframe id="iframe5" width="0" height="0"></iframe>
|
---|
94 |
|
---|
95 | <span name="span1" width="0" height="0"></span>
|
---|
96 | <span name="span2" width="0" height="0"></span>
|
---|
97 | <span name="span2" width="0" height="0"></span>
|
---|
98 | <span id="span3" width="0" height="0"></span>
|
---|
99 | <span id="span4" width="0" height="0"></span>
|
---|
100 | <span id="span4" width="0" height="0"></span>
|
---|
101 | <span id="span5" width="0" height="0"></span>
|
---|
102 | <span name="span5" width="0" height="0"></span>
|
---|
103 | <span name="span5" width="0" height="0"></span>
|
---|
104 | <span id="span5" width="0" height="0"></span>
|
---|
105 |
|
---|
106 | <img id="mixed1" width="0" height="0">
|
---|
107 | <form id="mixed1" width="0" height="0"></form>
|
---|
108 | <applet id="mixed1" width="0" height="0"></applet>
|
---|
109 | <embed id="mixed1" width="0" height="0"></embed>
|
---|
110 | <object id="mixed1" width="0" height="0"></object>
|
---|
111 | <iframe id="mixed1" width="0" height="0"></iframe>
|
---|
112 | <span id="mixed1" width="0" height="0"></span>
|
---|
113 |
|
---|
114 | <img name="mixed2" width="0" height="0">
|
---|
115 | <form name="mixed2" width="0" height="0"></form>
|
---|
116 | <applet name="mixed2" width="0" height="0"></applet>
|
---|
117 | <embed name="mixed2" width="0" height="0"></embed>
|
---|
118 | <object name="mixed2" width="0" height="0"></object>
|
---|
119 | <iframe name="mixed2" width="0" height="0"></iframe>
|
---|
120 | <span name="mixed2" width="0" height="0"></span>
|
---|
121 |
|
---|
122 | <img id="mixed3" width="0" height="0">
|
---|
123 | <form id="mixed3" width="0" height="0"></form>
|
---|
124 | <applet id="mixed3" width="0" height="0"></applet>
|
---|
125 | <embed id="mixed3" width="0" height="0"></embed>
|
---|
126 | <object id="mixed3" width="0" height="0"></object>
|
---|
127 | <span id="mixed3" width="0" height="0"></span>
|
---|
128 |
|
---|
129 | <img name="mixed4" width="0" height="0">
|
---|
130 | <form name="mixed4" width="0" height="0"></form>
|
---|
131 | <applet name="mixed4" width="0" height="0"></applet>
|
---|
132 | <embed name="mixed4" width="0" height="0"></embed>
|
---|
133 | <object name="mixed4" width="0" height="0"></object>
|
---|
134 | <span name="mixed4" width="0" height="0"></span>
|
---|
135 |
|
---|
136 | <img name="navigator" with="0" height="0">
|
---|
137 | <img name="custom" with="0" height="0">
|
---|
138 | <iframe name="location" with="0" height="0"></iframe>
|
---|
139 |
|
---|
140 | <input id="navigator" value="an input" type="text"/>
|
---|
141 | <input id="location" value="an input" type="text"/>
|
---|
142 | <input id="real_input" value="an input" type="text"/>
|
---|
143 |
|
---|
144 | </div>
|
---|
145 |
|
---|
146 | <pre id="results">
|
---|
147 | Results:<br>
|
---|
148 | </pre>
|
---|
149 |
|
---|
150 | <script>
|
---|
151 | function print(x)
|
---|
152 | {
|
---|
153 | document.getElementById("results").innerHTML += x;
|
---|
154 | }
|
---|
155 |
|
---|
156 | function printElement(e)
|
---|
157 | {
|
---|
158 | if (e.tagName) {
|
---|
159 | print(" " + e.tagName);
|
---|
160 |
|
---|
161 | if (e.name && e.id) {
|
---|
162 | print("(id,name)");
|
---|
163 | } else if (e.name) {
|
---|
164 | print("(name)");
|
---|
165 | } else if (e.id) {
|
---|
166 | print("(id)");
|
---|
167 | }
|
---|
168 | } else if (e.navigator) {
|
---|
169 | print(" WINDOW");
|
---|
170 | } else {
|
---|
171 | print(" OTHER");
|
---|
172 | }
|
---|
173 | }
|
---|
174 |
|
---|
175 | function testProperty(description, propName) {
|
---|
176 | print(description);
|
---|
177 | print(":");
|
---|
178 | var propVal = window[propName];
|
---|
179 |
|
---|
180 | if (!propVal) {
|
---|
181 | print(" undefined");
|
---|
182 | } else if (propVal.length) {
|
---|
183 | print(" collection(" + propVal.length + ")");
|
---|
184 | for (var i = 0; i < propVal.length; i++) {
|
---|
185 | printElement(propVal[i]);
|
---|
186 | }
|
---|
187 | } else {
|
---|
188 | print(" single");
|
---|
189 | printElement(propVal);
|
---|
190 | }
|
---|
191 |
|
---|
192 | print("<br>");
|
---|
193 | }
|
---|
194 |
|
---|
195 | testProperty("Nonexistent image name", "image0");
|
---|
196 | testProperty("Image by name (unique)", "image1");
|
---|
197 | testProperty("Image by name (multiple)", "image2");
|
---|
198 | testProperty("Image by id (unique)", "image3");
|
---|
199 | testProperty("Image by id (multiple)", "image4");
|
---|
200 | testProperty("Image by id/name mixed", "image5");
|
---|
201 | print("<br>");
|
---|
202 |
|
---|
203 | testProperty("Nonexistent form name", "form0");
|
---|
204 | testProperty("Form by name (unique)", "form1");
|
---|
205 | testProperty("Form by name (multiple)", "form2");
|
---|
206 | testProperty("Form by id (unique)", "form3");
|
---|
207 | testProperty("Form by id (multiple)", "form4");
|
---|
208 | testProperty("Form by id/name mixed", "form5");
|
---|
209 | print("<br>");
|
---|
210 |
|
---|
211 | testProperty("Nonexistent applet name", "applet0");
|
---|
212 | testProperty("Applet by name (unique)", "applet1");
|
---|
213 | testProperty("Applet by name (multiple)", "applet2");
|
---|
214 | testProperty("Applet by id (unique)", "applet3");
|
---|
215 | testProperty("Applet by id (multiple)", "applet4");
|
---|
216 | testProperty("Applet by id/name mixed", "applet5");
|
---|
217 | print("<br>");
|
---|
218 |
|
---|
219 | testProperty("Nonexistent object name", "object0");
|
---|
220 | testProperty("Object by name (unique)", "object1");
|
---|
221 | testProperty("Object by name (multiple)", "object2");
|
---|
222 | testProperty("Object by id (unique)", "object3");
|
---|
223 | testProperty("Object by id (multiple)", "object4");
|
---|
224 | testProperty("Object by id/name mixed", "object5");
|
---|
225 | print("<br>");
|
---|
226 |
|
---|
227 | testProperty("Nonexistent embed name", "embed0");
|
---|
228 | testProperty("Embed by name (unique)", "embed1");
|
---|
229 | testProperty("Embed by name (multiple)", "embed2");
|
---|
230 | testProperty("Embed by id (unique)", "embed3");
|
---|
231 | testProperty("Embed by id (multiple)", "embed4");
|
---|
232 | testProperty("Embed by id/name mixed", "embed5");
|
---|
233 | print("<br>");
|
---|
234 |
|
---|
235 | testProperty("Nonexistent iframe name", "iframe0");
|
---|
236 | testProperty("Iframe by name (unique)", "iframe1");
|
---|
237 | testProperty("Iframe by name (multiple)", "iframe2");
|
---|
238 | testProperty("Iframe by id (unique)", "iframe3");
|
---|
239 | testProperty("Iframe by id (multiple)", "iframe4");
|
---|
240 | testProperty("Iframe by id/name mixed", "iframe5");
|
---|
241 | print("<br>");
|
---|
242 |
|
---|
243 | testProperty("Nonexistent span name", "span0");
|
---|
244 | testProperty("Span by name (unique)", "span1");
|
---|
245 | testProperty("Span by name (multiple)", "span2");
|
---|
246 | testProperty("Span by id (unique)", "span3");
|
---|
247 | testProperty("Span by id (multiple)", "span4");
|
---|
248 | testProperty("Span by id/name mixed", "span5");
|
---|
249 | print("<br>");
|
---|
250 |
|
---|
251 | testProperty("Mixed by id", "mixed1");
|
---|
252 | testProperty("Mixed by name", "mixed2");
|
---|
253 | testProperty("Mixed by id (no iframe)", "mixed3");
|
---|
254 | testProperty("Mixed by name (no iframe)", "mixed4");
|
---|
255 | print("<br>");
|
---|
256 |
|
---|
257 | testProperty("Numeric 0", 0);
|
---|
258 | testProperty("Numeric 12", 12);
|
---|
259 | testProperty("Numeric 13", 13);
|
---|
260 | print("<br>");
|
---|
261 |
|
---|
262 | testProperty("Conflicting image name", "navigator");
|
---|
263 | testProperty("Conflicting image name (custom property)", "custom");
|
---|
264 | testProperty("Conflicting iframe", "location");
|
---|
265 | print("<br>");
|
---|
266 |
|
---|
267 | testProperty("Input by id (unique)", "real_input");
|
---|
268 | testProperty("Conflicting input id (navigator)", "navigator");
|
---|
269 | testProperty("Conflicting input id (location)", "location");
|
---|
270 |
|
---|
271 | </script>
|
---|
272 | </body>
|
---|