| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <p id="description"></p> |
| <div id='div1'>text1</div> |
| <div id='div2'>text2</div><br> |
| |
| <div id="console"></div> |
| |
| <script> |
| description('This tests that items in a NodeList can be retrieved by index.'); |
| |
| var nodeList = document.getElementsByTagName('div'); |
| var div0 = nodeList[0]; |
| var div0s = nodeList["0"]; |
| var div0s_ = nodeList["0 "]; |
| var div1 = nodeList["1"]; |
| |
| // Getting properties 0 and "0" should get the same thing, but getting |
| // properties "0 " and 1 should get different items. "0 " should not |
| // be converted to 0, so should be undefined, and the item at index |
| // 1 should be defined (since there are at least two divs on the page), |
| // but should be a different div to the one at index 0. |
| shouldBeTrue("div0 == div0s"); |
| shouldBeFalse("div0 == div0s_"); |
| shouldBeFalse("div0 == div1"); |
| shouldBeFalse("div0s == div0s_"); |
| shouldBeFalse("div0s == div1"); |
| shouldBeFalse("div0s_ == div1"); |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |