1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>DOM Traversal: NodeIterator: Removal of nodes that should have no effect</title>
5 This tests these cases that should have no effect:
6 1. Remove a node unrelated to the reference node
7 2. Remove an ancestor of the root node
8 3. Remove the root node itself
9 4. Remove descendant of reference node
11 <script type="text/javascript"> <![CDATA[
15 if (window.testRunner) testRunner.dumpAsText();
16 var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false);
17 var root = document.getElementById('root');
18 var A = document.getElementById('A');
19 var B = document.getElementById('B');
20 var C = document.getElementById('C');
21 var D = document.getElementById('D');
22 var E = document.getElementById('E');
23 check(iterator.nextNode(), root);
24 remove(document.getElementById('X'));
25 check(iterator.nextNode(), A);
26 remove(document.getElementById('Y'));
27 check(iterator.nextNode(), B);
29 check(iterator.nextNode(), C);
31 check(iterator.nextNode(), D);
33 document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log;
35 document.getElementById('result').firstChild.data = 'PASS';
37 function check(a, b) {
40 log += 'Found null but expected ' + b + ' (' + b.id + ').\n';
43 log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n';
49 log += 'Tried removing null node.\n';
51 a.parentNode.removeChild(a);
55 <body onload="doTest()">
56 <pre id="result">FAIL: Script did not complete.</pre>
57 <p><span id="X"></span><span id="Y"><span id="root"><span id="A"><span id="B"><span id="C"><span id="D"><span id="E"></span></span></span></span></span></span></span></p>