| <!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-pre.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: Not enough arguments'"); |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |