| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <title>DOM Traversal: NodeIterator: Basics Backwards</title> |
| <script type="text/javascript"> <![CDATA[ |
| if (window.layoutTestController) layoutTestController.dumpAsText(); |
| var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ALL, null, false); |
| var expected = new Array(9, // document |
| 3, 1, 3, 4, // script and CDATA block |
| while (node = iterator.nextNode()); |
| while (node = iterator.previousNode()) |
| found.unshift(node.nodeType); |
| var length = (found.length > expected.length) ? found.length : expected.length; |
| for (var i = 0; i < length; i += 1) { |
| s += ' ' + (expected[i] ? expected[i] : '-') + |
| ' ' + (found[i] ? found[i] : '-'); |
| if (found[i] != expected[i]) { |
| var p = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'pre')[0]; |
| p.firstChild.data = 'FAIL: ' + errors + ' errors found:\n\n' + s; |
| p.firstChild.data = 'PASS'; |
| <pre id="result">FAIL: Script failed to run.</pre> |
| <!-- some more nodes to test this: --> |