| 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.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"> |
|---|
| 145 | Results:<br> |
|---|
| 146 | </pre> |
|---|
| 147 | |
|---|
| 148 | <script> |
|---|
| 149 | function print(x) |
|---|
| 150 | { |
|---|
| 151 | document.getElementById("results").innerHTML += x; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | function 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 | |
|---|
| 173 | function 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 | |
|---|
| 193 | testProperty("Nonexistent image name", "image0"); |
|---|
| 194 | testProperty("Image by name (unique)", "image1"); |
|---|
| 195 | testProperty("Image by name (multiple)", "image2"); |
|---|
| 196 | testProperty("Image by id (unique)", "image3"); |
|---|
| 197 | testProperty("Image by id (multiple)", "image4"); |
|---|
| 198 | testProperty("Image by id/name mixed", "image5"); |
|---|
| 199 | testProperty("Image by id, name present (unique)", "image6"); |
|---|
| 200 | testProperty("Image by id, empty name present (unique)", "image7"); |
|---|
| 201 | testProperty("Image by id, name present (multiple)", "image8"); |
|---|
| 202 | testProperty("Image by name, id present (unique)", "image9name"); |
|---|
| 203 | |
|---|
| 204 | print("<br>"); |
|---|
| 205 | |
|---|
| 206 | testProperty("Nonexistent form name", "form0"); |
|---|
| 207 | testProperty("Form by name (unique)", "form1"); |
|---|
| 208 | testProperty("Form by name (multiple)", "form2"); |
|---|
| 209 | testProperty("Form by id (unique)", "form3"); |
|---|
| 210 | testProperty("Form by id (multiple)", "form4"); |
|---|
| 211 | testProperty("Form by id/name mixed", "form5"); |
|---|
| 212 | print("<br>"); |
|---|
| 213 | |
|---|
| 214 | testProperty("Nonexistent applet name", "applet0"); |
|---|
| 215 | testProperty("Applet by name (unique)", "applet1"); |
|---|
| 216 | testProperty("Applet by name (multiple)", "applet2"); |
|---|
| 217 | testProperty("Applet by id (unique)", "applet3"); |
|---|
| 218 | testProperty("Applet by id (multiple)", "applet4"); |
|---|
| 219 | testProperty("Applet by id/name mixed", "applet5"); |
|---|
| 220 | print("<br>"); |
|---|
| 221 | |
|---|
| 222 | testProperty("Nonexistent object name", "object0"); |
|---|
| 223 | testProperty("Object by name (unique)", "object1"); |
|---|
| 224 | testProperty("Object by name (multiple)", "object2"); |
|---|
| 225 | testProperty("Object by id (unique)", "object3"); |
|---|
| 226 | testProperty("Object by id (multiple)", "object4"); |
|---|
| 227 | testProperty("Object by id/name mixed", "object5"); |
|---|
| 228 | print("<br>"); |
|---|
| 229 | |
|---|
| 230 | testProperty("Nonexistent embed name", "embed0"); |
|---|
| 231 | testProperty("Embed by name (unique)", "embed1"); |
|---|
| 232 | testProperty("Embed by name (multiple)", "embed2"); |
|---|
| 233 | testProperty("Embed by id (unique)", "embed3"); |
|---|
| 234 | testProperty("Embed by id (multiple)", "embed4"); |
|---|
| 235 | testProperty("Embed by id/name mixed", "embed5"); |
|---|
| 236 | print("<br>"); |
|---|
| 237 | |
|---|
| 238 | testProperty("Nonexistent iframe name", "iframe0"); |
|---|
| 239 | testProperty("Iframe by name (unique)", "iframe1"); |
|---|
| 240 | testProperty("Iframe by name (multiple)", "iframe2"); |
|---|
| 241 | testProperty("Iframe by id (unique)", "iframe3"); |
|---|
| 242 | testProperty("Iframe by id (multiple)", "iframe4"); |
|---|
| 243 | testProperty("Iframe by id/name mixed", "iframe5"); |
|---|
| 244 | print("<br>"); |
|---|
| 245 | |
|---|
| 246 | testProperty("Nonexistent span name", "span0"); |
|---|
| 247 | testProperty("Span by name (unique)", "span1"); |
|---|
| 248 | testProperty("Span by name (multiple)", "span2"); |
|---|
| 249 | testProperty("Span by id (unique)", "span3"); |
|---|
| 250 | testProperty("Span by id (multiple)", "span4"); |
|---|
| 251 | testProperty("Span by id/name mixed", "span5"); |
|---|
| 252 | print("<br>"); |
|---|
| 253 | |
|---|
| 254 | testProperty("Mixed by id", "mixed1"); |
|---|
| 255 | testProperty("Mixed by name", "mixed2"); |
|---|
| 256 | testProperty("Mixed by id (no iframe)", "mixed3"); |
|---|
| 257 | testProperty("Mixed by name (no iframe)", "mixed4"); |
|---|
| 258 | print("<br>"); |
|---|
| 259 | |
|---|
| 260 | testProperty("Numeric 0", 0); |
|---|
| 261 | testProperty("Numeric 12", 12); |
|---|
| 262 | testProperty("Numeric 13", 13); |
|---|
| 263 | print("<br>"); |
|---|
| 264 | |
|---|
| 265 | testProperty("Conflicting image", "body"); |
|---|
| 266 | testProperty("Conflicting image (custom property)", "custom"); |
|---|
| 267 | testProperty("Conflicting iframe", "location"); |
|---|
| 268 | |
|---|
| 269 | </script> |
|---|
| 270 | </body> |
|---|