1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>DOM Traversal: NodeIterator: Basics Backwards</title>
4 <script type="text/javascript"> <![CDATA[
6 if (window.testRunner) testRunner.dumpAsText();
7 var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ALL, null, false);
8 var expected = new Array(9, // document
12 3, 1, 3, 4, // script and CDATA block
19 var found = new Array();
23 while (node = iterator.nextNode());
24 while (node = iterator.previousNode())
25 found.unshift(node.nodeType);
30 var length = (found.length > expected.length) ? found.length : expected.length;
31 s += 'EXPECTED FOUND\n';
32 for (var i = 0; i < length; i += 1) {
33 s += ' ' + (expected[i] ? expected[i] : '-') +
34 ' ' + (found[i] ? found[i] : '-');
35 if (found[i] != expected[i]) {
41 var p = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'pre')[0];
43 p.firstChild.data = 'FAIL: ' + errors + ' errors found:\n\n' + s;
45 p.firstChild.data = 'PASS';
49 <body onload="doTest()">
50 <pre id="result">FAIL: Script failed to run.</pre>
52 <!-- some more nodes to test this: -->