3 <script src=
"../../../resources/js-test.js"></script>
6 <p id=
"description"></p>
7 <div id='div1'
>text1
</div>
8 <div id='div2'
>text2
</div><br>
10 <div id=
"console"></div>
13 description('This tests that items in a NodeList can be retrieved by index.');
15 var nodeList
= document
.getElementsByTagName('div');
16 var div0
= nodeList
[0];
17 var div0s
= nodeList
["0"];
18 var div0s_
= nodeList
["0 "];
19 var div1
= nodeList
["1"];
21 // Getting properties 0 and "0" should get the same thing, but getting
22 // properties "0 " and 1 should get different items. "0 " should not
23 // be converted to 0, so should be undefined, and the item at index
24 // 1 should be defined (since there are at least two divs on the page),
25 // but should be a different div to the one at index 0.
26 shouldBeTrue("div0 == div0s");
27 shouldBeFalse("div0 == div0s_");
28 shouldBeFalse("div0 == div1");
29 shouldBeFalse("div0s == div0s_");
30 shouldBeFalse("div0s == div1");
31 shouldBeFalse("div0s_ == div1");