summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/NodeList/nodelist-item-with-index.html
blob: 369e0219b9b5bf1886154cfa4ac115a81d969329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/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");

var successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>