diff options
Diffstat (limited to 'testing/web-platform/tests/dom/traversal/unfinished')
11 files changed, 540 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/traversal/unfinished/001.xml b/testing/web-platform/tests/dom/traversal/unfinished/001.xml new file mode 100644 index 0000000000..08bce72fcf --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/001.xml @@ -0,0 +1,53 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Basics</title> + <script type="text/javascript"> <![CDATA[ + function doTest() { + var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ALL, null, false); + var expected = new Array(9, // document + 1, // html + 3, 1, // head + 3, 1, 3, // title + 3, 1, 3, 4, // script and CDATA block + 3, 3, 1, // body + 3, 1, 3, // pre + 3, // </body> + 3, 8, // <!-- --> + 3, 7, // <? ?>, + 3, 4, 3); // CDATA + var found = new Array(); + + // walk document + var node; + while (node = iterator.nextNode()) + found.push(node.nodeType); + + // check results + var errors = 0; + var s = ''; + var length = (found.length > expected.length) ? found.length : expected.length; + s += 'EXPECTED FOUND\n'; + for (var i = 0; i < length; i += 1) { + s += ' ' + (expected[i] ? expected[i] : '-') + + ' ' + (found[i] ? found[i] : '-'); + if (found[i] != expected[i]) { + s += ' MISMATCH'; + errors += 1; + } + s += '\n'; + } + var p = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'pre')[0]; + if (errors) + p.firstChild.data = 'FAIL: ' + errors + ' errors found:\n\n' + s; + else + p.firstChild.data = 'PASS'; + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script failed to run.</pre> + </body> + <!-- some more nodes to test this: --> + <?test node?> + <![CDATA[]]> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/dom/traversal/unfinished/002.xml b/testing/web-platform/tests/dom/traversal/unfinished/002.xml new file mode 100644 index 0000000000..bf3489688c --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/002.xml @@ -0,0 +1,54 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Basics Backwards</title> + <script type="text/javascript"> <![CDATA[ + function doTest() { + var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ALL, null, false); + var expected = new Array(9, // document + 1, // html + 3, 1, // head + 3, 1, 3, // title + 3, 1, 3, 4, // script and CDATA block + 3, 3, 1, // body + 3, 1, 3, // pre + 3, // </body> + 3, 8, // <!-- --> + 3, 7, // <? ?>, + 3, 4, 3); // CDATA + var found = new Array(); + + // walk document + var node; + while (node = iterator.nextNode()); + while (node = iterator.previousNode()) + found.unshift(node.nodeType); + + // check results + var errors = 0; + var s = ''; + var length = (found.length > expected.length) ? found.length : expected.length; + s += 'EXPECTED FOUND\n'; + for (var i = 0; i < length; i += 1) { + s += ' ' + (expected[i] ? expected[i] : '-') + + ' ' + (found[i] ? found[i] : '-'); + if (found[i] != expected[i]) { + s += ' MISMATCH'; + errors += 1; + } + s += '\n'; + } + var p = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'pre')[0]; + if (errors) + p.firstChild.data = 'FAIL: ' + errors + ' errors found:\n\n' + s; + else + p.firstChild.data = 'PASS'; + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script failed to run.</pre> + </body> + <!-- some more nodes to test this: --> + <?test node?> + <![CDATA[]]> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/dom/traversal/unfinished/003.xml b/testing/web-platform/tests/dom/traversal/unfinished/003.xml new file mode 100644 index 0000000000..268e6bb4d7 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/003.xml @@ -0,0 +1,58 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Removal of nodes that should have no effect</title> + <!-- + This tests these cases that should have no effect: + 1. Remove a node unrelated to the reference node + 2. Remove an ancestor of the root node + 3. Remove the root node itself + 4. Remove descendant of reference node + --> + <script type="text/javascript"> <![CDATA[ + var errors = 0; + var log = ''; + function doTest() { + var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false); + var root = document.getElementById('root'); + var A = document.getElementById('A'); + var B = document.getElementById('B'); + var C = document.getElementById('C'); + var D = document.getElementById('D'); + var E = document.getElementById('E'); + check(iterator.nextNode(), root); + remove(document.getElementById('X')); + check(iterator.nextNode(), A); + remove(document.getElementById('Y')); + check(iterator.nextNode(), B); + remove(root); + check(iterator.nextNode(), C); + remove(E); + check(iterator.nextNode(), D); + if (errors) + document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log; + else + document.getElementById('result').firstChild.data = 'PASS'; + } + function check(a, b) { + if (!a) { + errors += 1; + log += 'Found null but expected ' + b + ' (' + b.id + ').\n'; + } else if (a != b) { + errors += 1; + log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n'; + } + } + function remove(a) { + if (!a) { + errors += 1; + log += 'Tried removing null node.\n'; + } else + a.parentNode.removeChild(a); + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script did not complete.</pre> + <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> + </body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/dom/traversal/unfinished/004.xml b/testing/web-platform/tests/dom/traversal/unfinished/004.xml new file mode 100644 index 0000000000..618978f021 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/004.xml @@ -0,0 +1,49 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Removal of the Reference Node</title> + <script type="text/javascript"> <![CDATA[ + var errors = 0; + var log = ''; + function doTest() { + var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false); + var root = document.getElementById('root'); + var A = document.getElementById('A'); + var AA = document.getElementById('AA'); + var B = document.getElementById('B'); + var C = document.getElementById('C'); + check(iterator.nextNode(), root); + check(iterator.nextNode(), A); + check(iterator.nextNode(), AA); + check(iterator.nextNode(), B); + remove(B); + check(iterator.previousNode(), AA); + remove(AA); + check(iterator.nextNode(), C); + if (errors) + document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log; + else + document.getElementById('result').firstChild.data = 'PASS'; + } + function check(a, b) { + if (!a) { + errors += 1; + log += 'Found null but expected ' + b + ' (' + b.id + ').\n'; + } else if (a != b) { + errors += 1; + log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n'; + } + } + function remove(a) { + if (!a) { + errors += 1; + log += 'Tried removing null node.\n'; + } else + a.parentNode.removeChild(a); + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script did not complete.</pre> + <p><span id="root"><span id="A"><span id="AA"></span></span><span id="B"></span><span id="C"><span id="CC"></span></span></span></p> + </body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/dom/traversal/unfinished/005.xml b/testing/web-platform/tests/dom/traversal/unfinished/005.xml new file mode 100644 index 0000000000..643e2f1cd4 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/005.xml @@ -0,0 +1,57 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Removal of the Reference Node (deep check)</title> + <script type="text/javascript"> <![CDATA[ + var errors = 0; + var log = ''; + function doTest() { + var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false); + var root = document.getElementById('root'); + var A = document.getElementById('A'); + var AA = document.getElementById('AA'); + var B = document.getElementById('B'); + var C = document.getElementById('C'); + check(iterator.nextNode(), root); + check(iterator.nextNode(), A); + check(iterator.nextNode(), AA); + check(iterator.nextNode(), B); + remove(B); + var X = addChildTo(AA); + check(iterator.nextNode(), X); + check(iterator.previousNode(), X); + remove(X); + var Y = addChildTo(AA); + check(iterator.previousNode(), Y); + if (errors) + document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log; + else + document.getElementById('result').firstChild.data = 'PASS'; + } + function check(a, b) { + if (!a) { + errors += 1; + log += 'Found null but expected ' + b + ' (' + b.id + ').\n'; + } else if (a != b) { + errors += 1; + log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n'; + } + } + function remove(a) { + if (!a) { + errors += 1; + log += 'Tried removing null node.\n'; + } else + a.parentNode.removeChild(a); + } + function addChildTo(a) { + var x = document.createElementNS('http://www.w3.org/1999/xhtml', 'span'); + a.appendChild(x); + return x; + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script did not complete.</pre> + <p><span id="root"><span id="A"><span id="AA"></span></span><span id="B"></span><span id="C"><span id="CC"></span></span></span></p> + </body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/dom/traversal/unfinished/006.xml b/testing/web-platform/tests/dom/traversal/unfinished/006.xml new file mode 100644 index 0000000000..c2302af836 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/006.xml @@ -0,0 +1,47 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Removal of an ancestor of the Reference Node (forwards)</title> + <script type="text/javascript"> <![CDATA[ + var errors = 0; + var log = ''; + function doTest() { + var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false); + var root = document.getElementById('root'); + var A = document.getElementById('A'); + var B = document.getElementById('B'); + var BB = document.getElementById('BB'); + var C = document.getElementById('C'); + check(iterator.nextNode(), root); + check(iterator.nextNode(), A); + check(iterator.nextNode(), B); + check(iterator.nextNode(), BB); + remove(B); + check(iterator.previousNode(), A); + if (errors) + document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log; + else + document.getElementById('result').firstChild.data = 'PASS'; + } + function check(a, b) { + if (!a) { + errors += 1; + log += 'Found null but expected ' + b + ' (' + b.id + ').\n'; + } else if (a != b) { + errors += 1; + log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n'; + } + } + function remove(a) { + if (!a) { + errors += 1; + log += 'Tried removing null node.\n'; + } else + a.parentNode.removeChild(a); + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script did not complete.</pre> + <p><span id="root"><span id="A"></span><span id="B"><span id="BB"></span></span><span id="C"></span></span></p> + </body> +</html> diff --git a/testing/web-platform/tests/dom/traversal/unfinished/007.xml b/testing/web-platform/tests/dom/traversal/unfinished/007.xml new file mode 100644 index 0000000000..98b212e4e5 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/007.xml @@ -0,0 +1,54 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Removal of an ancestor of the Reference Node (forwards) (deep check)</title> + <script type="text/javascript"> <![CDATA[ + var errors = 0; + var log = ''; + function doTest() { + var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false); + var root = document.getElementById('root'); + var A = document.getElementById('A'); + var B = document.getElementById('B'); + var BB = document.getElementById('BB'); + var C = document.getElementById('C'); + check(iterator.nextNode(), root); + check(iterator.nextNode(), A); + check(iterator.nextNode(), B); + check(iterator.nextNode(), BB); + remove(B); + var X = addChildTo(A); + check(iterator.nextNode(), X); + if (errors) + document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log; + else + document.getElementById('result').firstChild.data = 'PASS'; + } + function check(a, b) { + if (!a) { + errors += 1; + log += 'Found null but expected ' + b + ' (' + b.id + ').\n'; + } else if (a != b) { + errors += 1; + log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n'; + } + } + function remove(a) { + if (!a) { + errors += 1; + log += 'Tried removing null node.\n'; + } else + a.parentNode.removeChild(a); + } + function addChildTo(a) { + var x = document.createElementNS('http://www.w3.org/1999/xhtml', 'span'); + x.id = 'X'; + a.appendChild(x); + return x; + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script did not complete.</pre> + <p><span id="root"><span id="A"></span><span id="B"><span id="BB"></span></span><span id="C"></span></span></p> + </body> +</html> diff --git a/testing/web-platform/tests/dom/traversal/unfinished/008.xml b/testing/web-platform/tests/dom/traversal/unfinished/008.xml new file mode 100644 index 0000000000..41d7008ae4 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/008.xml @@ -0,0 +1,48 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Removal of an ancestor of the Reference Node (backwards)</title> + <script type="text/javascript"> <![CDATA[ + var errors = 0; + var log = ''; + function doTest() { + var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false); + var root = document.getElementById('root'); + var A = document.getElementById('A'); + var B = document.getElementById('B'); + var BB = document.getElementById('BB'); + var C = document.getElementById('C'); + check(iterator.nextNode(), root); + check(iterator.nextNode(), A); + check(iterator.nextNode(), B); + check(iterator.nextNode(), BB); + check(iterator.previousNode(), BB); + remove(B); + check(iterator.nextNode(), C); + if (errors) + document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log; + else + document.getElementById('result').firstChild.data = 'PASS'; + } + function check(a, b) { + if (!a) { + errors += 1; + log += 'Found null but expected ' + b + ' (' + b.id + ').\n'; + } else if (a != b) { + errors += 1; + log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n'; + } + } + function remove(a) { + if (!a) { + errors += 1; + log += 'Tried removing null node.\n'; + } else + a.parentNode.removeChild(a); + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script did not complete.</pre> + <p><span id="root"><span id="A"></span><span id="B"><span id="BB"></span></span><span id="C"></span></span></p> + </body> +</html> diff --git a/testing/web-platform/tests/dom/traversal/unfinished/009.xml b/testing/web-platform/tests/dom/traversal/unfinished/009.xml new file mode 100644 index 0000000000..c3006ecbd6 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/009.xml @@ -0,0 +1,55 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Removal of an ancestor of the Reference Node (backwards) (deep check)</title> + <script type="text/javascript"> <![CDATA[ + var errors = 0; + var log = ''; + function doTest() { + var iterator = document.createNodeIterator(document.getElementById('root'), NodeFilter.SHOW_ALL, null, false); + var root = document.getElementById('root'); + var A = document.getElementById('A'); + var B = document.getElementById('B'); + var BB = document.getElementById('BB'); + var C = document.getElementById('C'); + check(iterator.nextNode(), root); + check(iterator.nextNode(), A); + check(iterator.nextNode(), B); + check(iterator.nextNode(), BB); + check(iterator.previousNode(), BB); + remove(B); + var X = addChildTo(A); + check(iterator.previousNode(), X); + if (errors) + document.getElementById('result').firstChild.data = 'FAIL: ' + errors + ' errors:\n' + log; + else + document.getElementById('result').firstChild.data = 'PASS'; + } + function check(a, b) { + if (!a) { + errors += 1; + log += 'Found null but expected ' + b + ' (' + b.id + ').\n'; + } else if (a != b) { + errors += 1; + log += 'Found ' + a + ' (' + a.id + ') but expected ' + b + ' (' + b.id + ').\n'; + } + } + function remove(a) { + if (!a) { + errors += 1; + log += 'Tried removing null node.\n'; + } else + a.parentNode.removeChild(a); + } + function addChildTo(a) { + var x = document.createElementNS('http://www.w3.org/1999/xhtml', 'span'); + x.id = 'X'; + a.appendChild(x); + return x; + } + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script did not complete.</pre> + <p><span id="root"><span id="A"></span><span id="B"><span id="BB"></span></span><span id="C"></span></span></p> + </body> +</html> diff --git a/testing/web-platform/tests/dom/traversal/unfinished/010.xml b/testing/web-platform/tests/dom/traversal/unfinished/010.xml new file mode 100644 index 0000000000..63263a5fd7 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/010.xml @@ -0,0 +1,64 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>DOM Traversal: NodeIterator: Filters</title> + <script type="text/javascript"> <![CDATA[ + function doTest() { + var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ALL, testFilter, false); + // skips text nodes and body element + var expected = new Array(9, // document + 1, // html + 1, // head + 1, // title + 1, 4, // script and CDATA block + // body (skipped) + 1, // pre + // </body> + 8, // <!-- --> + // PI skipped + 4); // CDATA + var found = new Array(); + + // walk document + var node; + while (node = iterator.nextNode()) + found.push(node.nodeType); + + // check results + var errors = 0; + var s = ''; + var length = (found.length > expected.length) ? found.length : expected.length; + s += 'EXPECTED FOUND\n'; + for (var i = 0; i < length; i += 1) { + s += ' ' + (expected[i] ? expected[i] : '-') + + ' ' + (found[i] ? found[i] : '-'); + if (found[i] != expected[i]) { + s += ' MISMATCH'; + errors += 1; + } + s += '\n'; + } + var p = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'pre')[0]; + if (errors) + p.firstChild.data = 'FAIL: ' + errors + ' errors found:\n\n' + s; + else + p.firstChild.data = 'PASS'; + } + + function testFilter(n) { + if (n.nodeType == 3) { + return NodeFilter.FILTER_SKIP; + } else if (n.nodeName == 'body') { + return NodeFilter.FILTER_REJECT; // same as _SKIP + } + return 1; // FILTER_ACCEPT + } + + ]]></script> + </head> + <body onload="doTest()"> + <pre id="result">FAIL: Script failed to run.</pre> + </body> + <!-- some more nodes to test this: --> + <?body test?> + <![CDATA[]]> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/dom/traversal/unfinished/TODO b/testing/web-platform/tests/dom/traversal/unfinished/TODO new file mode 100644 index 0000000000..cecdf98b08 --- /dev/null +++ b/testing/web-platform/tests/dom/traversal/unfinished/TODO @@ -0,0 +1 @@ +Check what happens when a NodeFilter turns a number not in the range 1..3
\ No newline at end of file |