| <body> |
| |
| <p>This test covers the various ways of accessing DOM elements through |
| the window object by name, id or index, directly as properties of the |
| window object. This lookup is supposed to include applet, embed, form, |
| image and object by name, and all elements by id. It should give the |
| element itself in the case of a single match, or an HTMLCollection in |
| the case of multiple matches; except that when iframes are involved, |
| it will give the window object for the first iframe match. |
| </p> |
| |
| <p>Our results match WinIE in all respects but one. We allow child |
| frame names to take precedence over built-in and custom properties of |
| the window object. This is the Mozilla behavior and is required to |
| make some sites work because they use frame names that collide with |
| built-in properties in Mozilla but not IE - specifically "toobar". See |
| <a href="rdar://problem/3870317">Radar 3870317</a>.</p> |
| |
| <hr> |
| |
| <script> |
| window.custom=new Object(); |
| |
| if (window.testRunner) |
| window.testRunner.dumpAsText(); |
| </script> |
| |
| <div style="visibility: hidden; width: 0px; height: 0px;"> |
| <img name="image1" width="0" height="0"> |
| <img name="image2" width="0" height="0"> |
| <img name="image2" width="0" height="0"> |
| <img id="image3" width="0" height="0"> |
| <img id="image4" width="0" height="0"> |
| <img id="image4" width="0" height="0"> |
| <img id="image5" width="0" height="0"> |
| <img name="image5" width="0" height="0"> |
| <img name="image5" width="0" height="0"> |
| <img id="image5" width="0" height="0"> |
| |
| <form name="form1" width="0" height="0"></form> |
| <form name="form2" width="0" height="0"></form> |
| <form name="form2" width="0" height="0"></form> |
| <form id="form3" width="0" height="0"></form> |
| <form id="form4" width="0" height="0"></form> |
| <form id="form4" width="0" height="0"></form> |
| <form id="form5" width="0" height="0"></form> |
| <form name="form5" width="0" height="0"></form> |
| <form name="form5" width="0" height="0"></form> |
| <form id="form5" width="0" height="0"></form> |
| |
| <applet name="applet1" width="0" height="0"></applet> |
| <applet name="applet2" width="0" height="0"></applet> |
| <applet name="applet2" width="0" height="0"></applet> |
| <applet id="applet3" width="0" height="0"></applet> |
| <applet id="applet4" width="0" height="0"></applet> |
| <applet id="applet4" width="0" height="0"></applet> |
| <applet id="applet5" width="0" height="0"></applet> |
| <applet name="applet5" width="0" height="0"></applet> |
| <applet name="applet5" width="0" height="0"></applet> |
| <applet id="applet5" width="0" height="0"></applet> |
| |
| <embed name="embed1" width="0" height="0"></embed> |
| <embed name="embed2" width="0" height="0"></embed> |
| <embed name="embed2" width="0" height="0"></embed> |
| <embed id="embed3" width="0" height="0"></embed> |
| <embed id="embed4" width="0" height="0"></embed> |
| <embed id="embed4" width="0" height="0"></embed> |
| <embed id="embed5" width="0" height="0"></embed> |
| <embed name="embed5" width="0" height="0"></embed> |
| <embed name="embed5" width="0" height="0"></embed> |
| <embed id="embed5" width="0" height="0"></embed> |
| |
| <object name="object1" width="0" height="0"></object> |
| <object name="object2" width="0" height="0"></object> |
| <object name="object2" width="0" height="0"></object> |
| <object id="object3" width="0" height="0"></object> |
| <object id="object4" width="0" height="0"></object> |
| <object id="object4" width="0" height="0"></object> |
| <object id="object5" width="0" height="0"></object> |
| <object name="object5" width="0" height="0"></object> |
| <object name="object5" width="0" height="0"></object> |
| <object id="object5" width="0" height="0"></object> |
| |
| <iframe name="iframe1" width="0" height="0"></iframe> |
| <iframe name="iframe2" width="0" height="0"></iframe> |
| <iframe name="iframe2" width="0" height="0"></iframe> |
| <iframe id="iframe3" width="0" height="0"></iframe> |
| <iframe id="iframe4" width="0" height="0"></iframe> |
| <iframe id="iframe4" width="0" height="0"></iframe> |
| <iframe id="iframe5" width="0" height="0"></iframe> |
| <iframe name="iframe5" width="0" height="0"></iframe> |
| <iframe name="iframe5" width="0" height="0"></iframe> |
| <iframe id="iframe5" width="0" height="0"></iframe> |
| |
| <span name="span1" width="0" height="0"></span> |
| <span name="span2" width="0" height="0"></span> |
| <span name="span2" width="0" height="0"></span> |
| <span id="span3" width="0" height="0"></span> |
| <span id="span4" width="0" height="0"></span> |
| <span id="span4" width="0" height="0"></span> |
| <span id="span5" width="0" height="0"></span> |
| <span name="span5" width="0" height="0"></span> |
| <span name="span5" width="0" height="0"></span> |
| <span id="span5" width="0" height="0"></span> |
| |
| <img id="mixed1" width="0" height="0"> |
| <form id="mixed1" width="0" height="0"></form> |
| <applet id="mixed1" width="0" height="0"></applet> |
| <embed id="mixed1" width="0" height="0"></embed> |
| <object id="mixed1" width="0" height="0"></object> |
| <iframe id="mixed1" width="0" height="0"></iframe> |
| <span id="mixed1" width="0" height="0"></span> |
| |
| <img name="mixed2" width="0" height="0"> |
| <form name="mixed2" width="0" height="0"></form> |
| <applet name="mixed2" width="0" height="0"></applet> |
| <embed name="mixed2" width="0" height="0"></embed> |
| <object name="mixed2" width="0" height="0"></object> |
| <iframe name="mixed2" width="0" height="0"></iframe> |
| <span name="mixed2" width="0" height="0"></span> |
| |
| <img id="mixed3" width="0" height="0"> |
| <form id="mixed3" width="0" height="0"></form> |
| <applet id="mixed3" width="0" height="0"></applet> |
| <embed id="mixed3" width="0" height="0"></embed> |
| <object id="mixed3" width="0" height="0"></object> |
| <span id="mixed3" width="0" height="0"></span> |
| |
| <img name="mixed4" width="0" height="0"> |
| <form name="mixed4" width="0" height="0"></form> |
| <applet name="mixed4" width="0" height="0"></applet> |
| <embed name="mixed4" width="0" height="0"></embed> |
| <object name="mixed4" width="0" height="0"></object> |
| <span name="mixed4" width="0" height="0"></span> |
| |
| <img name="navigator" with="0" height="0"> |
| <img name="custom" with="0" height="0"> |
| <iframe name="location" with="0" height="0"></iframe> |
| |
| <input id="navigator" value="an input" type="text"/> |
| <input id="location" value="an input" type="text"/> |
| <input id="real_input" value="an input" type="text"/> |
| |
| </div> |
| |
| <pre id="results"> |
| Results:<br> |
| </pre> |
| |
| <script> |
| function print(x) |
| { |
| document.getElementById("results").innerHTML += x; |
| } |
| |
| function printElement(e) |
| { |
| if (e.tagName) { |
| print(" " + e.tagName); |
| |
| if (e.name && e.id) { |
| print("(id,name)"); |
| } else if (e.name) { |
| print("(name)"); |
| } else if (e.id) { |
| print("(id)"); |
| } |
| } else if (e.navigator) { |
| print(" WINDOW"); |
| } else { |
| print(" OTHER"); |
| } |
| } |
| |
| function testProperty(description, propName) { |
| print(description); |
| print(":"); |
| var propVal = window[propName]; |
| |
| if (!propVal) { |
| print(" undefined"); |
| } else if (propVal.length) { |
| print(" collection(" + propVal.length + ")"); |
| for (var i = 0; i < propVal.length; i++) { |
| printElement(propVal[i]); |
| } |
| } else { |
| print(" single"); |
| printElement(propVal); |
| } |
| |
| print("<br>"); |
| } |
| |
| testProperty("Nonexistent image name", "image0"); |
| testProperty("Image by name (unique)", "image1"); |
| testProperty("Image by name (multiple)", "image2"); |
| testProperty("Image by id (unique)", "image3"); |
| testProperty("Image by id (multiple)", "image4"); |
| testProperty("Image by id/name mixed", "image5"); |
| print("<br>"); |
| |
| testProperty("Nonexistent form name", "form0"); |
| testProperty("Form by name (unique)", "form1"); |
| testProperty("Form by name (multiple)", "form2"); |
| testProperty("Form by id (unique)", "form3"); |
| testProperty("Form by id (multiple)", "form4"); |
| testProperty("Form by id/name mixed", "form5"); |
| print("<br>"); |
| |
| testProperty("Nonexistent applet name", "applet0"); |
| testProperty("Applet by name (unique)", "applet1"); |
| testProperty("Applet by name (multiple)", "applet2"); |
| testProperty("Applet by id (unique)", "applet3"); |
| testProperty("Applet by id (multiple)", "applet4"); |
| testProperty("Applet by id/name mixed", "applet5"); |
| print("<br>"); |
| |
| testProperty("Nonexistent object name", "object0"); |
| testProperty("Object by name (unique)", "object1"); |
| testProperty("Object by name (multiple)", "object2"); |
| testProperty("Object by id (unique)", "object3"); |
| testProperty("Object by id (multiple)", "object4"); |
| testProperty("Object by id/name mixed", "object5"); |
| print("<br>"); |
| |
| testProperty("Nonexistent embed name", "embed0"); |
| testProperty("Embed by name (unique)", "embed1"); |
| testProperty("Embed by name (multiple)", "embed2"); |
| testProperty("Embed by id (unique)", "embed3"); |
| testProperty("Embed by id (multiple)", "embed4"); |
| testProperty("Embed by id/name mixed", "embed5"); |
| print("<br>"); |
| |
| testProperty("Nonexistent iframe name", "iframe0"); |
| testProperty("Iframe by name (unique)", "iframe1"); |
| testProperty("Iframe by name (multiple)", "iframe2"); |
| testProperty("Iframe by id (unique)", "iframe3"); |
| testProperty("Iframe by id (multiple)", "iframe4"); |
| testProperty("Iframe by id/name mixed", "iframe5"); |
| print("<br>"); |
| |
| testProperty("Nonexistent span name", "span0"); |
| testProperty("Span by name (unique)", "span1"); |
| testProperty("Span by name (multiple)", "span2"); |
| testProperty("Span by id (unique)", "span3"); |
| testProperty("Span by id (multiple)", "span4"); |
| testProperty("Span by id/name mixed", "span5"); |
| print("<br>"); |
| |
| testProperty("Mixed by id", "mixed1"); |
| testProperty("Mixed by name", "mixed2"); |
| testProperty("Mixed by id (no iframe)", "mixed3"); |
| testProperty("Mixed by name (no iframe)", "mixed4"); |
| print("<br>"); |
| |
| testProperty("Numeric 0", 0); |
| testProperty("Numeric 12", 12); |
| testProperty("Numeric 13", 13); |
| print("<br>"); |
| |
| testProperty("Conflicting image name", "navigator"); |
| testProperty("Conflicting image name (custom property)", "custom"); |
| testProperty("Conflicting iframe", "location"); |
| print("<br>"); |
| |
| testProperty("Input by id (unique)", "real_input"); |
| testProperty("Conflicting input id (navigator)", "navigator"); |
| testProperty("Conflicting input id (location)", "location"); |
| |
| </script> |
| </body> |