59 lines
1.5 KiB
HTML
59 lines
1.5 KiB
HTML
<html>
|
|
<head>
|
|
<script language="JavaScript">
|
|
if (window.testRunner)
|
|
testRunner.dumpAsText();
|
|
|
|
function log(message) {
|
|
var console = document.getElementById("console");
|
|
var li = document.createElement("li");
|
|
var text = document.createTextNode(message);
|
|
li.appendChild(text);
|
|
console.appendChild(li);
|
|
}
|
|
|
|
function iteratorTest() {
|
|
log("NodeIterator: testing nextNode() (5 should be null)");
|
|
var iterator = document.createNodeIterator(divB, NodeFilter.SHOW_ELEMENT, null, false);
|
|
iterator.root = divB;
|
|
for (i=0; i < 4; i++)
|
|
log(iterator.nextNode());
|
|
|
|
log("NodeIterator: testing previousNode() (7 should be null)");
|
|
iterator = document.createNodeIterator(divB, NodeFilter.SHOW_ELEMENT, null, false);
|
|
log(iterator.previousNode());
|
|
|
|
log("TreeWalker: testing nextNode() (11 should be null)");
|
|
iterator = document.createTreeWalker(divB, NodeFilter.SHOW_ELEMENT, null, false);
|
|
for (i=0; i < 3; i++)
|
|
log(iterator.nextNode());
|
|
|
|
log("TreeWalker: testing previousNode() (13 should be null)");
|
|
iterator = document.createTreeWalker(divB, NodeFilter.SHOW_ELEMENT, null, false);
|
|
log(iterator.previousNode());
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="divA">
|
|
This test checks that the NodeIterator and TreeWalker functions do not go past the root element that they are supposed to stay within.
|
|
<div id="divB">
|
|
<div id="divC">
|
|
</div>
|
|
<div id="divD">
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<ol id="console" > </ol>
|
|
|
|
<script>
|
|
iteratorTest();
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|