source: webkit/trunk/LayoutTests/fast/dom/Window/window-special-properties.html

Last change on this file was 120792, checked in by rniwa@webkit.org, 12 years ago

Use testRunner instead of layoutTestController in fast/doctypes, dom, dynamic, encoding, events, eventsource, and exclusions tests
https://bugs.webkit.org/show_bug.cgi?id=89438

Reviewed by Tony Chang.

  • fast/doctypes/005-case-preserving.html:
  • fast/doctypes/doctype-after-comment.html:
  • fast/doctypes/doctype-at-end.html:
  • fast/doctypes/doctype-in-element.html:
  • fast/doctypes/doctype-parsing.html:
  • fast/doctypes/html-doctype.html:
  • fast/doctypes/xhtml-with-xhtmlmp-doctype.xhtml:
  • fast/doctypes/xml-doctype.xhtml:
  • fast/dom/:
  • fast/dynamic/5872671.html:
  • fast/dynamic/ancestor-to-absolute.html:
  • fast/dynamic/checkbox-selection-crash.html:
  • fast/dynamic/containing-block-change.html:
  • fast/dynamic/crash-generated-counter.html:
  • fast/dynamic/crash-generated-image.html:
  • fast/dynamic/crash-generated-quote.html:
  • fast/dynamic/crash-generated-text.html:
  • fast/dynamic/crash-paint-no-documentElement-renderer.html-disabled:
  • fast/dynamic/float-remove-above-line-2.html:
  • fast/dynamic/float-remove-above-line.html:
  • fast/dynamic/hover-before-position-after-style-change.html:
  • fast/dynamic/hover-before-position-after-style-change2.html:
  • fast/dynamic/hover-style-recalc-crash.html:
  • fast/dynamic/hovered-detach.html:
  • fast/dynamic/inline-to-block-crash.html:
  • fast/dynamic/insertAdjacentElement.html:
  • fast/dynamic/insertAdjacentHTML-allowed-parents.html:
  • fast/dynamic/insertAdjacentHTML.html:
  • fast/dynamic/insertAdjacentText.html:
  • fast/dynamic/jQuery-animation-crash.html:
  • fast/dynamic/layer-hit-test-crash.html:
  • fast/dynamic/layer-no-longer-paginated.html:
  • fast/dynamic/outerHTML-no-element.html:
  • fast/dynamic/paused-event-dispatch.html:
  • fast/dynamic/position-absolute-to-fixed-crash.html:
  • fast/dynamic/position-change-layout.html:
  • fast/dynamic/recursive-layout.html:
  • fast/dynamic/style-access-late-stylesheet-load.html:
  • fast/dynamic/subtree-common-root.html:
  • fast/dynamic/subtree-table-cell-height.html:
  • fast/dynamic/subtree-unrooted.html:
  • fast/encoding/:
  • fast/events/:
  • platform/chromium/fast/events/drag-downloadURL.html:
  • platform/chromium/fast/events/intercept-postmessage.html:
  • platform/chromium/fast/events/rtl-scrollbar.html:
  • platform/gtk/fast/events/event-sender-metakey.html:
  • platform/mac/fast/dom/HTMLImageElement/dashboard-src-quirk.html:
  • platform/mac/fast/dom/character-index-for-point.html:
  • platform/mac/fast/dom/objc-wrapper-identity.html:
  • platform/mac/fast/dom/wrapper-classes-objc.html:
  • platform/mac/fast/dom/wrapper-round-tripping.html:
  • platform/mac/fast/events/objc-event-api.html:
  • platform/mac/fast/events/objc-keyboard-event-creation.html:
  • platform/qt/fast/events/event-sender-keydown-frame.html:
  • platform/win/fast/events/alt-numpad.html:
  • platform/win/fast/events/alt-space-scroll.html:
  • platform/win/fast/events/double-dead-char.html:
  • platform/win/fast/events/keyLocation-numpad.html:
  • platform/win/fast/events/panScroll-correct-direction.html:
  • platform/win/fast/events/panScroll-event-fired.html:
  • platform/win/fast/events/panScroll-image-no-scroll.html:
  • platform/win/fast/events/panScroll-imageMap-href-no-scroll.html:
  • platform/win/fast/events/panScroll-imageMap-noHref-scroll.html:
  • platform/win/fast/events/panScroll-nested-divs.html:
  • platform/win/fast/events/panScroll-no-iframe-jump.html:
  • platform/win/fast/events/panScroll-preventDefault.html:
  • platform/win/fast/events/script-tests/context-click-events.js:
  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/html
File size: 9.7 KB
Line 
1<body>
2
3<p>This test covers the various ways of accessing DOM elements through
4the window object by name, id or index, directly as properties of the
5window object. This lookup is supposed to include applet, embed, form,
6image and object by name, and all elements by id. It should give the
7element itself in the case of a single match, or an HTMLCollection in
8the case of multiple matches; except that when iframes are involved,
9it 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
13frame names to take precedence over built-in and custom properties of
14the window object. This is the Mozilla behavior and is required to
15make some sites work because they use frame names that collide with
16built-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>
22window.custom=new Object();
23
24if (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">
147Results:<br>
148</pre>
149
150<script>
151function print(x)
152{
153   document.getElementById("results").innerHTML += x;
154}
155
156function 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
175function 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
195testProperty("Nonexistent image name", "image0");
196testProperty("Image by name (unique)", "image1");
197testProperty("Image by name (multiple)", "image2");
198testProperty("Image by id (unique)", "image3");
199testProperty("Image by id (multiple)", "image4");
200testProperty("Image by id/name mixed", "image5");
201print("<br>");
202
203testProperty("Nonexistent form name", "form0");
204testProperty("Form by name (unique)", "form1");
205testProperty("Form by name (multiple)", "form2");
206testProperty("Form by id (unique)", "form3");
207testProperty("Form by id (multiple)", "form4");
208testProperty("Form by id/name mixed", "form5");
209print("<br>");
210
211testProperty("Nonexistent applet name", "applet0");
212testProperty("Applet by name (unique)", "applet1");
213testProperty("Applet by name (multiple)", "applet2");
214testProperty("Applet by id (unique)", "applet3");
215testProperty("Applet by id (multiple)", "applet4");
216testProperty("Applet by id/name mixed", "applet5");
217print("<br>");
218
219testProperty("Nonexistent object name", "object0");
220testProperty("Object by name (unique)", "object1");
221testProperty("Object by name (multiple)", "object2");
222testProperty("Object by id (unique)", "object3");
223testProperty("Object by id (multiple)", "object4");
224testProperty("Object by id/name mixed", "object5");
225print("<br>");
226
227testProperty("Nonexistent embed name", "embed0");
228testProperty("Embed by name (unique)", "embed1");
229testProperty("Embed by name (multiple)", "embed2");
230testProperty("Embed by id (unique)", "embed3");
231testProperty("Embed by id (multiple)", "embed4");
232testProperty("Embed by id/name mixed", "embed5");
233print("<br>");
234
235testProperty("Nonexistent iframe name", "iframe0");
236testProperty("Iframe by name (unique)", "iframe1");
237testProperty("Iframe by name (multiple)", "iframe2");
238testProperty("Iframe by id (unique)", "iframe3");
239testProperty("Iframe by id (multiple)", "iframe4");
240testProperty("Iframe by id/name mixed", "iframe5");
241print("<br>");
242
243testProperty("Nonexistent span name", "span0");
244testProperty("Span by name (unique)", "span1");
245testProperty("Span by name (multiple)", "span2");
246testProperty("Span by id (unique)", "span3");
247testProperty("Span by id (multiple)", "span4");
248testProperty("Span by id/name mixed", "span5");
249print("<br>");
250
251testProperty("Mixed by id", "mixed1");
252testProperty("Mixed by name", "mixed2");
253testProperty("Mixed by id (no iframe)", "mixed3");
254testProperty("Mixed by name (no iframe)", "mixed4");
255print("<br>");
256
257testProperty("Numeric 0", 0);
258testProperty("Numeric 12", 12);
259testProperty("Numeric 13", 13);
260print("<br>");
261
262testProperty("Conflicting image name", "navigator");
263testProperty("Conflicting image name (custom property)", "custom");
264testProperty("Conflicting iframe", "location");
265print("<br>");
266
267testProperty("Input by id (unique)", "real_input");
268testProperty("Conflicting input id (navigator)", "navigator");
269testProperty("Conflicting input id (location)", "location");
270
271</script>
272</body>
Note: See TracBrowser for help on using the repository browser.