blob: 46259803bad8da65ce8af9e623adef26fee04d26 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#dom-nodelist-item">
<script src="../../resources/js-test.js"></script>
</head>
<body>
<span id="target">
<div id="a"></div>
<div id="b"></div>
</span>
<script>
description("Tests that the NodeList.item() argument is correctly validated.");
var nodeList = document.getElementById("target").querySelectorAll('div');
shouldBe("nodeList.__proto__", "NodeList.prototype");
shouldBeEqualToString("nodeList.item(0).id", "a");
shouldBeEqualToString("nodeList.item(1).id", "b");
shouldBeNull("nodeList.item(2)");
shouldBeNull("nodeList.item(-1)");
shouldBeEqualToString("nodeList.item(-4294967295).id", "b"); // Wraps to 1.
shouldThrow("nodeList.item()", '"TypeError: Failed to execute \'item\' on \'NodeList\': 1 argument required, but only 0 present."');
</script>
</body>
</html>