root/trunk/LayoutTests/fast/dom/HTMLDocument/document-special-properties.html

Revision 19979, 9.6 KB (checked in by andersca, 21 months ago)

LayoutTests:

Reviewed by Maciej.

<rdar://problem/5035045>
REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html


Add some tests where image elements have id _and_ name elements.


  • fast/dom/HTMLDocument/document-special-properties-expected.txt:
  • fast/dom/HTMLDocument/document-special-properties.html:

WebCore:

Reviewed by Maciej.

<rdar://problem/5035045>
REGRESSION: WebKit browser doesn't display image at http://www.metoffice.gov.uk/weather/satellite/index.html


It turns out WinIE does allow you to access images by their id as special document properties. However, this is only
allowed when the element also has a name attribute. The value of the name attribute is ignored and can even be empty!


  • bindings/js/kjs_html.cpp: (KJS::JSHTMLDocument::namedItemGetter): Return jsUndefined() if the collection is empty.


  • html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::parseMappedAttribute): (WebCore::HTMLImageElement::insertedIntoDocument): (WebCore::HTMLImageElement::removedFromDocument):
  • html/HTMLImageElement.h: Add the id attribute value to the extra named item map.


  • html/HTMLNameCollection.cpp: (WebCore::HTMLNameCollection::traverseNextItem): Check for images with name attributes that match, as well as elements with id attributes that match where the element also has a name attribute.
  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1<body>
2
3<p>This test covers the various ways of accessing DOM elements through
4the document object by name, id or index, directly as properties of
5the document object. This lookup is supposed to include applet, embed,
6form, image, object and iframe by name, but only applet and object by
7id. It should give the element itself in the case of a single match,
8or an HTMLCollection in the case of multiple matches; except that when
9exactly one item that is an iframe matches, it will give the window
10object for that iframe.
11</p>
12
13<p>Our results match IE.</p>
14
15<hr>
16
17<script>
18document.custom=new Object();
19
20if (window.layoutTestController)
21    window.layoutTestController.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
75<object name="object1" width="0" height="0"></object>
76<object name="object2" width="0" height="0"></object>
77<object name="object2" width="0" height="0"></object>
78<object id="object3" width="0" height="0"></object>
79<object id="object4" width="0" height="0"></object>
80<object id="object4" width="0" height="0"></object>
81<object id="object5" width="0" height="0"></object>
82<object name="object5" width="0" height="0"></object>
83<object name="object5" width="0" height="0"></object>
84<object id="object5" width="0" height="0"></object>
85
86<iframe name="iframe1" width="0" height="0"></iframe>
87<iframe name="iframe2" width="0" height="0"></iframe>
88<iframe name="iframe2" width="0" height="0"></iframe>
89<iframe id="iframe3" width="0" height="0"></iframe>
90<iframe id="iframe4" width="0" height="0"></iframe>
91<iframe id="iframe4" width="0" height="0"></iframe>
92<iframe id="iframe5" width="0" height="0"></iframe>
93<iframe name="iframe5" width="0" height="0"></iframe>
94<iframe name="iframe5" width="0" height="0"></iframe>
95<iframe id="iframe5" width="0" height="0"></iframe>
96
97<span name="span1" width="0" height="0"></span>
98<span name="span2" width="0" height="0"></span>
99<span name="span2" width="0" height="0"></span>
100<span id="span3" width="0" height="0"></span>
101<span id="span4" width="0" height="0"></span>
102<span id="span4" width="0" height="0"></span>
103<span id="span5" width="0" height="0"></span>
104<span name="span5" width="0" height="0"></span>
105<span name="span5" width="0" height="0"></span>
106<span id="span5" width="0" height="0"></span>
107
108<img id="mixed1" width="0" height="0">
109<form id="mixed1" width="0" height="0"></form>
110<applet id="mixed1" width="0" height="0"></applet>
111<embed id="mixed1" width="0" height="0"></embed>
112<object id="mixed1" width="0" height="0"></object>
113<iframe id="mixed1" width="0" height="0"></iframe>
114<span id="mixed1" width="0" height="0"></span>
115
116<img name="mixed2" width="0" height="0">
117<form name="mixed2" width="0" height="0"></form>
118<applet name="mixed2" width="0" height="0"></applet>
119<embed name="mixed2" width="0" height="0"></embed>
120<object name="mixed2" width="0" height="0"></object>
121<iframe name="mixed2" width="0" height="0"></iframe>
122<span name="mixed2" width="0" height="0"></span>
123
124<img id="mixed3" width="0" height="0">
125<form id="mixed3" width="0" height="0"></form>
126<applet id="mixed3" width="0" height="0"></applet>
127<embed id="mixed3" width="0" height="0"></embed>
128<object id="mixed3" width="0" height="0"></object>
129<span id="mixed3" width="0" height="0"></span>
130
131<img name="mixed4" width="0" height="0">
132<form name="mixed4" width="0" height="0"></form>
133<applet name="mixed4" width="0" height="0"></applet>
134<embed name="mixed4" width="0" height="0"></embed>
135<object name="mixed4" width="0" height="0"></object>
136<span name="mixed4" width="0" height="0"></span>
137
138<img name="body" with="0" height="0">
139<img name="custom" with="0" height="0">
140<iframe name="location" with="0" height="0"></iframe>
141
142</div>
143
144<pre id="results">
145Results:<br>
146</pre>
147
148<script>
149function print(x)
150{
151   document.getElementById("results").innerHTML += x;
152}
153
154function printElement(e)
155{
156    if (e.tagName) {
157        print(" " + e.tagName);
158
159    if (e.name && e.id) {
160        print("(id,name)");
161    } else if (e.name) {
162        print("(name)");
163        } else if (e.id) {
164        print("(id)");
165    }
166    } else if (e.navigator) {
167        print(" WINDOW");
168    } else {
169        print(" OTHER");
170    }
171}
172
173function testProperty(description, propName) {
174    print(description);
175    print(":");
176    var propVal = document[propName];
177
178    if (!propVal) {
179        print(" undefined");
180    } else if (propVal.length) {
181        print(" collection(" + propVal.length + ")");
182    for (var i = 0; i < propVal.length; i++) {
183        printElement(propVal[i]);
184    }
185    } else {
186        print(" single");
187    printElement(propVal);
188    }
189   
190    print("<br>");
191}
192
193testProperty("Nonexistent image name", "image0");
194testProperty("Image by name (unique)", "image1");
195testProperty("Image by name (multiple)", "image2");
196testProperty("Image by id (unique)", "image3");
197testProperty("Image by id (multiple)", "image4");
198testProperty("Image by id/name mixed", "image5");
199testProperty("Image by id, name present (unique)", "image6");
200testProperty("Image by id, empty name present (unique)", "image7");
201testProperty("Image by id, name present (multiple)", "image8");
202testProperty("Image by name, id present (unique)", "image9name");
203
204print("<br>");
205
206testProperty("Nonexistent form name", "form0");
207testProperty("Form by name (unique)", "form1");
208testProperty("Form by name (multiple)", "form2");
209testProperty("Form by id (unique)", "form3");
210testProperty("Form by id (multiple)", "form4");
211testProperty("Form by id/name mixed", "form5");
212print("<br>");
213
214testProperty("Nonexistent applet name", "applet0");
215testProperty("Applet by name (unique)", "applet1");
216testProperty("Applet by name (multiple)", "applet2");
217testProperty("Applet by id (unique)", "applet3");
218testProperty("Applet by id (multiple)", "applet4");
219testProperty("Applet by id/name mixed", "applet5");
220print("<br>");
221
222testProperty("Nonexistent object name", "object0");
223testProperty("Object by name (unique)", "object1");
224testProperty("Object by name (multiple)", "object2");
225testProperty("Object by id (unique)", "object3");
226testProperty("Object by id (multiple)", "object4");
227testProperty("Object by id/name mixed", "object5");
228print("<br>");
229
230testProperty("Nonexistent embed name", "embed0");
231testProperty("Embed by name (unique)", "embed1");
232testProperty("Embed by name (multiple)", "embed2");
233testProperty("Embed by id (unique)", "embed3");
234testProperty("Embed by id (multiple)", "embed4");
235testProperty("Embed by id/name mixed", "embed5");
236print("<br>");
237
238testProperty("Nonexistent iframe name", "iframe0");
239testProperty("Iframe by name (unique)", "iframe1");
240testProperty("Iframe by name (multiple)", "iframe2");
241testProperty("Iframe by id (unique)", "iframe3");
242testProperty("Iframe by id (multiple)", "iframe4");
243testProperty("Iframe by id/name mixed", "iframe5");
244print("<br>");
245
246testProperty("Nonexistent span name", "span0");
247testProperty("Span by name (unique)", "span1");
248testProperty("Span by name (multiple)", "span2");
249testProperty("Span by id (unique)", "span3");
250testProperty("Span by id (multiple)", "span4");
251testProperty("Span by id/name mixed", "span5");
252print("<br>");
253
254testProperty("Mixed by id", "mixed1");
255testProperty("Mixed by name", "mixed2");
256testProperty("Mixed by id (no iframe)", "mixed3");
257testProperty("Mixed by name (no iframe)", "mixed4");
258print("<br>");
259
260testProperty("Numeric 0", 0);
261testProperty("Numeric 12", 12);
262testProperty("Numeric 13", 13);
263print("<br>");
264
265testProperty("Conflicting image", "body");
266testProperty("Conflicting image (custom property)", "custom");
267testProperty("Conflicting iframe", "location");
268
269</script>
270</body>
Note: See TracBrowser for help on using the browser.