2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / traversal / hixie-node-iterator / 006.xml
blobaa91b91a61fcec3a38cce49a5553718702866aff
1 <html xmlns="http://www.w3.org/1999/xhtml">
2  <head>
3   <title>DOM Traversal: NodeIterator: Removal of an ancestor of the Reference Node (forwards)</title>
4   <script type="text/javascript"> <![CDATA[
5     var errors = 0;
6     var log = '';
7     function doTest() {
8       if (window.layoutTestController) layoutTestController.dumpAsText();
9       var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false);
10       var root = document.getElementById('root');
11       var A = document.getElementById('A');
12       var B = document.getElementById('B');
13       var BB = document.getElementById('BB');
14       var C = document.getElementById('C');
15       check(iterator.nextNode(), root);
16       check(iterator.nextNode(), A);
17       check(iterator.nextNode(), B);
18       check(iterator.nextNode(), BB);
19       remove(B);
20       check(iterator.previousNode(), A);
21       if (errors)
22         document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log;
23       else
24         document.getElementById('result').firstChild.data = 'PASS';
25     }
26     function check(a, b) {
27       if (!a) {
28         errors += 1;
29         log += 'Found null but expected ' + b + ' (' + b.id + ').\n';
30       } else if (a != b) {
31         errors += 1;
32         log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n';
33       }
34     }
35     function remove(a) {
36       if (!a) {
37         errors += 1;
38         log += 'Tried removing null node.\n';
39       } else
40       a.parentNode.removeChild(a);
41     }
42   ]]></script>
43  </head>
44  <body onload="doTest()">
45   <pre id="result">FAIL: Script did not complete.</pre>
46   <p><span id="root"><span id="A"></span><span id="B"><span id="BB"></span></span><span id="C"></span></span></p>
47  </body>
48 </html>