2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / traversal / hixie-node-iterator / 009.xml
blob3c400fa8548a0834c2736b5cb88f0510da2673a0
1 <html xmlns="http://www.w3.org/1999/xhtml">
2  <head>
3   <title>DOM Traversal: NodeIterator: Removal of an ancestor of the Reference Node (backwards) (deep check)</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       check(iterator.previousNode(), BB);
20       remove(B);
21       var X = addChildTo(A);
22       check(iterator.previousNode(), X);
23       if (errors)
24         document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log;
25       else
26         document.getElementById('result').firstChild.data = 'PASS';
27     }
28     function check(a, b) {
29       if (!a) {
30         errors += 1;
31         log += 'Found null but expected ' + b + ' (' + b.id + ').\n';
32       } else if (a != b) {
33         errors += 1;
34         log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n';
35       }
36     }
37     function remove(a) {
38       if (!a) {
39         errors += 1;
40         log += 'Tried removing null node.\n';
41       } else
42       a.parentNode.removeChild(a);
43     }
44     function addChildTo(a) {
45       var x = document.createElementNS('http://www.w3.org/1999/xhtml', 'span');
46       x.id = 'X';
47       a.appendChild(x);
48       return x;
49     }
50   ]]></script>
51  </head>
52  <body onload="doTest()">
53   <pre id="result">FAIL: Script did not complete.</pre>
54   <p><span id="root"><span id="A"></span><span id="B"><span id="BB"></span></span><span id="C"></span></span></p>
55  </body>
56 </html>