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