1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>DOM Traversal: NodeIterator: Basics</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 found.push(node.nodeType);
29 var length = (found.length > expected.length) ? found.length : expected.length;
30 s += 'EXPECTED FOUND\n';
31 for (var i = 0; i < length; i += 1) {
32 s += ' ' + (expected[i] ? expected[i] : '-') +
33 ' ' + (found[i] ? found[i] : '-');
34 if (found[i] != expected[i]) {
40 var p = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'pre')[0];
42 p.firstChild.data = 'FAIL: ' + errors + ' errors found:\n\n' + s;
44 p.firstChild.data = 'PASS';
48 <body onload="doTest()">
49 <pre id="result">FAIL: Script failed to run.</pre>
51 <!-- some more nodes to test this: -->