OLD | NEW |
1 <html xmlns="http://www.w3.org/1999/xhtml"> | 1 <html xmlns="http://www.w3.org/1999/xhtml"> |
2 <head> | 2 <head> |
3 <title>DOM Traversal: NodeIterator: Basics Backwards</title> | 3 <title>DOM Traversal: NodeIterator: Basics Backwards</title> |
4 <script type="text/javascript"> <![CDATA[ | 4 <script type="text/javascript"> <![CDATA[ |
5 function doTest() { | 5 function doTest() { |
6 if (window.testRunner) testRunner.dumpAsText(); | 6 if (window.testRunner) testRunner.dumpAsText(); |
7 var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ALL,
null, false); | 7 var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ALL,
null, false); |
8 var expected = new Array(9, // document | 8 var expected = new Array(9, // document |
9 1, // html | 9 1, // html |
10 3, 1, // head | 10 3, 1, // head |
11 3, 1, 3, // title | 11 3, 1, 3, // title |
12 3, 1, 3, 4, // script and CDATA block | 12 3, 1, 3, // script |
13 3, 3, 1, // body | 13 3, 3, 1, // body |
14 3, 1, 3, // pre | 14 3, 1, 3, // pre |
15 3, // </body> | 15 3, // </body> |
16 3, 8, // <!-- --> | 16 3, 8, // <!-- --> |
17 3, 7, // <? ?>, | 17 3, 7, // <? ?>, |
18 3, 4, 3); // CDATA | 18 3); // CDATA merged with text |
19 var found = new Array(); | 19 var found = new Array(); |
20 | 20 |
21 // walk document | 21 // walk document |
22 var node; | 22 var node; |
23 while (node = iterator.nextNode()); | 23 while (node = iterator.nextNode()); |
24 while (node = iterator.previousNode()) | 24 while (node = iterator.previousNode()) |
25 found.unshift(node.nodeType); | 25 found.unshift(node.nodeType); |
26 | 26 |
27 // check results | 27 // check results |
28 var errors = 0; | 28 var errors = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
45 p.firstChild.data = 'PASS'; | 45 p.firstChild.data = 'PASS'; |
46 } | 46 } |
47 ]]></script> | 47 ]]></script> |
48 </head> | 48 </head> |
49 <body onload="doTest()"> | 49 <body onload="doTest()"> |
50 <pre id="result">FAIL: Script failed to run.</pre> | 50 <pre id="result">FAIL: Script failed to run.</pre> |
51 </body> | 51 </body> |
52 <!-- some more nodes to test this: --> | 52 <!-- some more nodes to test this: --> |
53 <?test node?> | 53 <?test node?> |
54 <![CDATA[ ]]> | 54 <![CDATA[ ]]> |
55 </html> | 55 </html> |
OLD | NEW |