diff options
Diffstat (limited to 'testing/web-platform/tests/dom/traversal')
25 files changed, 0 insertions, 2070 deletions
diff --git a/testing/web-platform/tests/dom/traversal/NodeFilter-constants.html b/testing/web-platform/tests/dom/traversal/NodeFilter-constants.html deleted file mode 100644 index 1ce4736cc..000000000 --- a/testing/web-platform/tests/dom/traversal/NodeFilter-constants.html +++ /dev/null @@ -1,34 +0,0 @@ -<!doctype html> -<title>NodeFilter constants</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="../constants.js"></script> -<div id="log"></div> -<script> -var objects; -setup(function() { - objects = [ - [NodeFilter, "NodeFilter interface object"], - ] -}) -testConstants(objects, [ - ["FILTER_ACCEPT", 1], - ["FILTER_REJECT", 2], - ["FILTER_SKIP", 3] -], "acceptNode") -testConstants(objects, [ - ["SHOW_ALL", 0xFFFFFFFF], - ["SHOW_ELEMENT", 0x1], - ["SHOW_ATTRIBUTE", 0x2], - ["SHOW_TEXT", 0x4], - ["SHOW_CDATA_SECTION", 0x8], - ["SHOW_ENTITY_REFERENCE", 0x10], - ["SHOW_ENTITY", 0x20], - ["SHOW_PROCESSING_INSTRUCTION", 0x40], - ["SHOW_COMMENT", 0x80], - ["SHOW_DOCUMENT", 0x100], - ["SHOW_DOCUMENT_TYPE", 0x200], - ["SHOW_DOCUMENT_FRAGMENT", 0x400], - ["SHOW_NOTATION", 0x800] -], "whatToShow") -</script> diff --git a/testing/web-platform/tests/dom/traversal/NodeIterator-removal.html b/testing/web-platform/tests/dom/traversal/NodeIterator-removal.html deleted file mode 100644 index b5fc69541..000000000 --- a/testing/web-platform/tests/dom/traversal/NodeIterator-removal.html +++ /dev/null @@ -1,100 +0,0 @@ -<!doctype html> -<title>NodeIterator removal tests</title> -<link rel="author" title="Aryeh Gregor" href=ayg@aryeh.name> -<meta name=timeout content=long> -<div id=log></div> -<script src=/resources/testharness.js></script> -<script src=/resources/testharnessreport.js></script> -<script src=../common.js></script> -<script> -"use strict"; - -for (var i = 0; i < testNodes.length; i++) { - var node = eval(testNodes[i]); - if (!node.parentNode) { - // Nothing to test - continue; - } - test(function() { - var iters = []; - var descs = []; - var expectedReferenceNodes = []; - var expectedPointers = []; - - for (var j = 0; j < testNodes.length; j++) { - var root = eval(testNodes[j]); - // Add all distinct iterators with this root, calling nextNode() - // repeatedly until it winds up with the same iterator. - for (var k = 0; ; k++) { - var iter = document.createNodeIterator(root); - for (var l = 0; l < k; l++) { - iter.nextNode(); - } - if (k && iter.referenceNode == iters[iters.length - 1].referenceNode - && iter.pointerBeforeReferenceNode - == iters[iters.length - 1].pointerBeforeReferenceNode) { - break; - } else { - iters.push(iter); - descs.push("document.createNodeIterator(" + testNodes[j] - + ") advanced " + k + " times"); - expectedReferenceNodes.push(iter.referenceNode); - expectedPointers.push(iter.pointerBeforeReferenceNode); - - var idx = iters.length - 1; - - // "If the node is root or is not an inclusive ancestor of the - // referenceNode attribute value, terminate these steps." - // - // We also have to rule out the case where node is an ancestor of - // root, which is implicitly handled by the spec since such a node - // was not part of the iterator collection to start with. - if (isInclusiveAncestor(node, root) - || !isInclusiveAncestor(node, iter.referenceNode)) { - continue; - } - - // "If the pointerBeforeReferenceNode attribute value is false, set - // the referenceNode attribute to the first node preceding the node - // that is being removed, and terminate these steps." - if (!iter.pointerBeforeReferenceNode) { - expectedReferenceNodes[idx] = previousNode(node); - continue; - } - - // "If there is a node following the last inclusive descendant of the - // node that is being removed, set the referenceNode attribute to the - // first such node, and terminate these steps." - var next = nextNodeDescendants(node); - if (next) { - expectedReferenceNodes[idx] = next; - continue; - } - - // "Set the referenceNode attribute to the first node preceding the - // node that is being removed and set the pointerBeforeReferenceNode - // attribute to false." - expectedReferenceNodes[idx] = previousNode(node); - expectedPointers[idx] = false; - } - } - } - - var oldParent = node.parentNode; - var oldSibling = node.nextSibling; - oldParent.removeChild(node); - - for (var j = 0; j < iters.length; j++) { - var iter = iters[j]; - assert_equals(iter.referenceNode, expectedReferenceNodes[j], - ".referenceNode of " + descs[j]); - assert_equals(iter.pointerBeforeReferenceNode, expectedPointers[j], - ".pointerBeforeReferenceNode of " + descs[j]); - } - - oldParent.insertBefore(node, oldSibling); - }, "Test removing node " + testNodes[i]); -} - -testDiv.style.display = "none"; -</script> diff --git a/testing/web-platform/tests/dom/traversal/NodeIterator.html b/testing/web-platform/tests/dom/traversal/NodeIterator.html deleted file mode 100644 index 0f618efb4..000000000 --- a/testing/web-platform/tests/dom/traversal/NodeIterator.html +++ /dev/null @@ -1,202 +0,0 @@ -<!doctype html> -<title>NodeIterator tests</title> -<link rel="author" title="Aryeh Gregor" href=ayg@aryeh.name> -<meta name=timeout content=long> -<div id=log></div> -<script src=/resources/testharness.js></script> -<script src=/resources/testharnessreport.js></script> -<script src=../common.js></script> -<script> -"use strict"; - -function check_iter(iter, root, whatToShowValue) { - whatToShowValue = whatToShowValue === undefined ? 0xFFFFFFFF : whatToShowValue; - - assert_equals(iter.toString(), '[object NodeIterator]', 'toString'); - assert_equals(iter.root, root, 'root'); - assert_equals(iter.whatToShow, whatToShowValue, 'whatToShow'); - assert_equals(iter.filter, null, 'filter'); - assert_equals(iter.referenceNode, root, 'referenceNode'); - assert_equals(iter.pointerBeforeReferenceNode, true, 'pointerBeforeReferenceNode'); - assert_readonly(iter, 'root'); - assert_readonly(iter, 'whatToShow'); - assert_readonly(iter, 'filter'); - assert_readonly(iter, 'referenceNode'); - assert_readonly(iter, 'pointerBeforeReferenceNode'); -} - -test(function() { - var iter = document.createNodeIterator(document); - iter.detach(); - iter.detach(); -}, "detach() should be a no-op"); - -test(function() { - var iter = document.createNodeIterator(document); - check_iter(iter, document); -}, "createNodeIterator() parameter defaults"); - -test(function() { - var iter = document.createNodeIterator(document, null, null); - check_iter(iter, document, 0); -}, "createNodeIterator() with null as arguments"); - -test(function() { - var iter = document.createNodeIterator(document, undefined, undefined); - check_iter(iter, document); -}, "createNodeIterator() with undefined as arguments"); - -test(function() { - var iter = document.createNodeIterator(document, NodeFilter.SHOW_ALL, - function() { throw {name: "failed"} }); - assert_throws({name: "failed"}, function() { iter.nextNode() }); -}, "Propagate exception from filter function"); - -function testIterator(root, whatToShow, filter) { - var iter = document.createNodeIterator(root, whatToShow, filter); - - assert_equals(iter.root, root, ".root"); - assert_equals(iter.referenceNode, root, "Initial .referenceNode"); - assert_equals(iter.pointerBeforeReferenceNode, true, - ".pointerBeforeReferenceNode"); - assert_equals(iter.whatToShow, whatToShow, ".whatToShow"); - assert_equals(iter.filter, filter, ".filter"); - - var expectedReferenceNode = root; - var expectedBeforeNode = true; - // "Let node be the value of the referenceNode attribute." - var node = root; - // "Let before node be the value of the pointerBeforeReferenceNode - // attribute." - var beforeNode = true; - var i = 1; - // Each loop iteration runs nextNode() once. - while (node) { - do { - if (!beforeNode) { - // "If before node is false, let node be the first node following node - // in the iterator collection. If there is no such node return null." - node = nextNode(node); - if (!isInclusiveDescendant(node, root)) { - node = null; - break; - } - } else { - // "If before node is true, set it to false." - beforeNode = false; - } - // "Filter node and let result be the return value. - // - // "If result is FILTER_ACCEPT, go to the next step in the overall set of - // steps. - // - // "Otherwise, run these substeps again." - if (!((1 << (node.nodeType - 1)) & whatToShow) - || (filter && filter(node) != NodeFilter.FILTER_ACCEPT)) { - continue; - } - - // "Set the referenceNode attribute to node, set the - // pointerBeforeReferenceNode attribute to before node, and return node." - expectedReferenceNode = node; - expectedBeforeNode = beforeNode; - - break; - } while (true); - - assert_equals(iter.nextNode(), node, ".nextNode() " + i + " time(s)"); - assert_equals(iter.referenceNode, expectedReferenceNode, - ".referenceNode after nextNode() " + i + " time(s)"); - assert_equals(iter.pointerBeforeReferenceNode, expectedBeforeNode, - ".pointerBeforeReferenceNode after nextNode() " + i + " time(s)"); - - i++; - } - - // Same but for previousNode() (mostly copy-pasted, oh well) - var iter = document.createNodeIterator(root, whatToShow, filter); - - var expectedReferenceNode = root; - var expectedBeforeNode = true; - // "Let node be the value of the referenceNode attribute." - var node = root; - // "Let before node be the value of the pointerBeforeReferenceNode - // attribute." - var beforeNode = true; - var i = 1; - // Each loop iteration runs previousNode() once. - while (node) { - do { - if (beforeNode) { - // "If before node is true, let node be the first node preceding node - // in the iterator collection. If there is no such node return null." - node = previousNode(node); - if (!isInclusiveDescendant(node, root)) { - node = null; - break; - } - } else { - // "If before node is false, set it to true." - beforeNode = true; - } - // "Filter node and let result be the return value. - // - // "If result is FILTER_ACCEPT, go to the next step in the overall set of - // steps. - // - // "Otherwise, run these substeps again." - if (!((1 << (node.nodeType - 1)) & whatToShow) - || (filter && filter(node) != NodeFilter.FILTER_ACCEPT)) { - continue; - } - - // "Set the referenceNode attribute to node, set the - // pointerBeforeReferenceNode attribute to before node, and return node." - expectedReferenceNode = node; - expectedBeforeNode = beforeNode; - - break; - } while (true); - - assert_equals(iter.previousNode(), node, ".previousNode() " + i + " time(s)"); - assert_equals(iter.referenceNode, expectedReferenceNode, - ".referenceNode after previousNode() " + i + " time(s)"); - assert_equals(iter.pointerBeforeReferenceNode, expectedBeforeNode, - ".pointerBeforeReferenceNode after previousNode() " + i + " time(s)"); - - i++; - } -} - -var whatToShows = [ - "0", - "0xFFFFFFFF", - "NodeFilter.SHOW_ELEMENT", - "NodeFilter.SHOW_ATTRIBUTE", - "NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_DOCUMENT", -]; - -var callbacks = [ - "null", - "(function(node) { return true })", - "(function(node) { return false })", - "(function(node) { return node.nodeName[0] == '#' })", -]; - -var tests = []; -for (var i = 0; i < testNodes.length; i++) { - for (var j = 0; j < whatToShows.length; j++) { - for (var k = 0; k < callbacks.length; k++) { - tests.push([ - "document.createNodeIterator(" + testNodes[i] - + ", " + whatToShows[j] + ", " + callbacks[k] + ")", - eval(testNodes[i]), eval(whatToShows[j]), eval(callbacks[k]) - ]); - } - } -} - -generate_tests(testIterator, tests); - -testDiv.style.display = "none"; -</script> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-acceptNode-filter.html b/testing/web-platform/tests/dom/traversal/TreeWalker-acceptNode-filter.html deleted file mode 100644 index 1446f40f6..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-acceptNode-filter.html +++ /dev/null @@ -1,155 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js ---> -<head> -<title>TreeWalker: acceptNode-filter</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>Test JS objects as NodeFilters</p> -<script> -var testElement; -setup(function() { - testElement = document.createElement("div"); - testElement.id = 'root'; - //testElement.innerHTML='<div id="A1"><div id="B1"></div><div id="B2"></div></div>'; - - // XXX for Servo, build the tree without using innerHTML - var a1 = document.createElement("div"); - a1.id = "A1"; - var b1 = document.createElement("div"); - b1.id = "B1"; - var b2 = document.createElement("div"); - b2.id = "B2"; - testElement.appendChild(a1); - a1.appendChild(b1); - a1.appendChild(b2); -}); - -test(function() -{ - function filter(node) - { - if (node.id == "B1") - return NodeFilter.FILTER_SKIP; - return NodeFilter.FILTER_ACCEPT; - } - - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.currentNode, { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B2' }); - assert_node(walker.currentNode, { type: Element, id: 'B2' }); -}, 'Testing with raw function filter'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, { - acceptNode : function(node) { - if (node.id == "B1") - return NodeFilter.FILTER_SKIP; - return NodeFilter.FILTER_ACCEPT; - } - }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.currentNode, { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B2' }); - assert_node(walker.currentNode, { type: Element, id: 'B2' }); -}, 'Testing with object filter'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, null); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.currentNode, { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B1' }); - assert_node(walker.currentNode, { type: Element, id: 'B1' }); -}, 'Testing with null filter'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, undefined); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.currentNode, { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B1' }); - assert_node(walker.currentNode, { type: Element, id: 'B1' }); -}, 'Testing with undefined filter'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, {}); - assert_throws(new TypeError(), function () { walker.firstChild(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_throws(new TypeError(), function () { walker.nextNode(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); -}, 'Testing with object lacking acceptNode property'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, { acceptNode: "foo" }); - assert_throws(new TypeError(), function () { walker.firstChild(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_throws(new TypeError(), function () { walker.nextNode(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); -}, 'Testing with object with non-function acceptNode property'); - -test(function() -{ - var filter = function() { return NodeFilter.FILTER_ACCEPT; }; - filter.acceptNode = function(node) { return NodeFilter.FILTER_SKIP; }; - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B1' }); -}, 'Testing with function having acceptNode function'); - -test(function() -{ - var filter = { - acceptNode: function(node) { - return NodeFilter.FILTER_ACCEPT; - } - }; - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); -}, 'Testing acceptNode callee'); - -test(function() -{ - var test_error = { name: "test" }; - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, - function(node) { - throw test_error; - }); - assert_throws(test_error, function () { walker.firstChild(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_throws(test_error, function () { walker.nextNode(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); -}, 'Testing with filter function that throws'); - -test(function() -{ - var test_error = { name: "test" }; - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, - { - acceptNode : function(node) { - throw test_error; - } - }); - assert_throws(test_error, function () { walker.firstChild(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_throws(test_error, function () { walker.nextNode(); }); - assert_node(walker.currentNode, { type: Element, id: 'root' }); -}, 'Testing with filter object that throws'); - -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-basic.html b/testing/web-platform/tests/dom/traversal/TreeWalker-basic.html deleted file mode 100644 index d1147637b..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-basic.html +++ /dev/null @@ -1,154 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/TreeWalker-basic.html ---> -<head> -<title>TreeWalker: Basic test</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>This test checks the basic functionality of TreeWalker.</p> -<script> -function createSampleDOM() -{ - // Tree structure: - // #a - // | - // +----+----+ - // | | - // "b" #c - // | - // +----+----+ - // | | - // #d <!--j--> - // | - // +----+----+ - // | | | - // "e" #f "i" - // | - // +--+--+ - // | | - // "g" <!--h--> - var div = document.createElement('div'); - div.id = 'a'; - // div.innerHTML = 'b<div id="c"><div id="d">e<span id="f">g<!--h--></span>i</div><!--j--></div>'; - - div.appendChild(document.createTextNode("b")); - - var c = document.createElement("div"); - c.id = 'c'; - div.appendChild(c); - - var d = document.createElement("div"); - d.id = 'd'; - c.appendChild(d); - - var e = document.createTextNode("e"); - d.appendChild(e); - - var f = document.createElement("span"); - f.id = 'f'; - d.appendChild(f); - - var g = document.createTextNode("g"); - f.appendChild(g); - - var h = document.createComment("h"); - f.appendChild(h); - - var i = document.createTextNode("i"); - d.appendChild(i); - - var j = document.createComment("j"); - c.appendChild(j); - - return div; -} - -function check_walker(walker, root, whatToShowValue) -{ - whatToShowValue = whatToShowValue === undefined ? 0xFFFFFFFF : whatToShowValue; - - assert_equals(walker.toString(), '[object TreeWalker]', 'toString'); - assert_equals(walker.root, root, 'root'); - assert_equals(walker.whatToShow, whatToShowValue, 'whatToShow'); - assert_equals(walker.filter, null, 'filter'); - assert_equals(walker.currentNode, root, 'currentNode'); - assert_readonly(walker, 'root'); - assert_readonly(walker, 'whatToShow'); - assert_readonly(walker, 'filter'); -} - -test(function () -{ - var root = createSampleDOM(); - var walker = document.createTreeWalker(root); - check_walker(walker, root); -}, 'Construct a TreeWalker by document.createTreeWalker(root).'); - -test(function () -{ - var root = createSampleDOM(); - var walker = document.createTreeWalker(root, null, null); - check_walker(walker, root, 0); -}, 'Construct a TreeWalker by document.createTreeWalker(root, null, null).'); - -test(function () -{ - var root = createSampleDOM(); - var walker = document.createTreeWalker(root, undefined, undefined); - check_walker(walker, root); -}, 'Construct a TreeWalker by document.createTreeWalker(root, undefined, undefined).'); - -test(function () -{ - assert_throws(new TypeError(), function () { document.createTreeWalker(); }); - assert_throws(new TypeError(), function () { document.createTreeWalker(null); }); - assert_throws(new TypeError(), function () { document.createTreeWalker(undefined); }); - assert_throws(new TypeError(), function () { document.createTreeWalker(new Object()); }); - assert_throws(new TypeError(), function () { document.createTreeWalker(1); }); -}, 'Give an invalid root node to document.createTreeWalker().'); - -test(function () -{ - var root = createSampleDOM(); - var walker = document.createTreeWalker(root); - var f = root.lastChild.firstChild.childNodes[1]; // An element node: div#f. - - assert_node(walker.currentNode, { type: Element, id: 'a' }); - assert_equals(walker.parentNode(), null); - assert_node(walker.currentNode, { type: Element, id: 'a' }); - assert_node(walker.firstChild(), { type: Text, nodeValue: 'b' }); - assert_node(walker.currentNode, { type: Text, nodeValue: 'b' }); - assert_node(walker.nextSibling(), { type: Element, id: 'c' }); - assert_node(walker.currentNode, { type: Element, id: 'c' }); - assert_node(walker.lastChild(), { type: Comment, nodeValue: 'j' }); - assert_node(walker.currentNode, { type: Comment, nodeValue: 'j' }); - assert_node(walker.previousSibling(), { type: Element, id: 'd' }); - assert_node(walker.currentNode, { type: Element, id: 'd' }); - assert_node(walker.nextNode(), { type: Text, nodeValue: 'e' }); - assert_node(walker.currentNode, { type: Text, nodeValue: 'e' }); - assert_node(walker.parentNode(), { type: Element, id: 'd' }); - assert_node(walker.currentNode, { type: Element, id: 'd' }); - assert_node(walker.previousNode(), { type: Element, id: 'c' }); - assert_node(walker.currentNode, { type: Element, id: 'c' }); - assert_equals(walker.nextSibling(), null); - assert_node(walker.currentNode, { type: Element, id: 'c' }); - walker.currentNode = f; - assert_equals(walker.currentNode, f); -}, 'Walk over nodes.'); - -test(function() { - var treeWalker = document.createTreeWalker(document.body, 42, null); - assert_equals(treeWalker.root, document.body); - assert_equals(treeWalker.currentNode, document.body); - assert_equals(treeWalker.whatToShow, 42); - assert_equals(treeWalker.filter, null); -}, "Optional arguments to createTreeWalker should be optional (3 passed, null)."); -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-currentNode.html b/testing/web-platform/tests/dom/traversal/TreeWalker-currentNode.html deleted file mode 100644 index 8a09940b1..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-currentNode.html +++ /dev/null @@ -1,73 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/resources/TreeWalker-currentNode.js ---> -<head> -<title>TreeWalker: currentNode</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<div id='parent'> -<div id='subTree'><p>Lorem ipsum <span>dolor <b>sit</b> amet</span>, consectetur <i>adipisicing</i> elit, sed do eiusmod <tt>tempor <b><i>incididunt ut</i> labore</b> et dolore magna</tt> aliqua.</p></div> -</div> -<p>Test TreeWalker currentNode functionality</p> -<script> -// var subTree = document.createElement('div'); -// subTree.innerHTML = "<p>Lorem ipsum <span>dolor <b>sit</b> amet</span>, consectetur <i>adipisicing</i> elit, sed do eiusmod <tt>tempor <b><i>incididunt ut</i> labore</b> et dolore magna</tt> aliqua.</p>" -// document.body.appendChild(subTree); -var subTree = document.getElementById("subTree"); - -var all = function(node) { return true; } - -test(function() -{ - var w = document.createTreeWalker(subTree, NodeFilter.SHOW_ELEMENT, all); - assert_node(w.currentNode, { type: Element, id: 'subTree' }); - assert_equals(w.parentNode(), null); - assert_node(w.currentNode, { type: Element, id: 'subTree' }); -}, "Test that TreeWalker.parent() doesn't set the currentNode to a node not under the root."); - -test(function() -{ - var w = document.createTreeWalker(subTree, - NodeFilter.SHOW_ELEMENT - | NodeFilter.SHOW_COMMENT, - all); - w.currentNode = document.documentElement; - assert_equals(w.parentNode(), null); - assert_equals(w.currentNode, document.documentElement); - w.currentNode = document.documentElement; - assert_equals(w.nextNode(), document.documentElement.firstChild); - assert_equals(w.currentNode, document.documentElement.firstChild); - w.currentNode = document.documentElement; - assert_equals(w.previousNode(), null); - assert_equals(w.currentNode, document.documentElement); - w.currentNode = document.documentElement; - assert_equals(w.firstChild(), document.documentElement.firstChild); - assert_equals(w.currentNode, document.documentElement.firstChild); - w.currentNode = document.documentElement; - assert_equals(w.lastChild(), document.documentElement.lastChild); - assert_equals(w.currentNode, document.documentElement.lastChild); - w.currentNode = document.documentElement; - assert_equals(w.nextSibling(), null); - assert_equals(w.currentNode, document.documentElement); - w.currentNode = document.documentElement; - assert_equals(w.previousSibling(), null); - assert_equals(w.currentNode, document.documentElement); -}, "Test that we handle setting the currentNode to arbitrary nodes not under the root element."); - -test(function() -{ - var w = document.createTreeWalker(subTree, NodeFilter.SHOW_ELEMENT, all); - w.currentNode = subTree.previousSibling; - assert_equals(w.nextNode(), subTree); - w.currentNode = document.getElementById("parent"); - assert_equals(w.firstChild(), subTree); -}, "Test how we handle the case when the traversed to node is within the root, but the currentElement is not."); -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-previousNodeLastChildReject.html b/testing/web-platform/tests/dom/traversal/TreeWalker-previousNodeLastChildReject.html deleted file mode 100644 index 236ab803c..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-previousNodeLastChildReject.html +++ /dev/null @@ -1,87 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/script-tests/previousNodeLastChildReject.js ---> -<head> -<title>TreeWalker: previousNodeLastChildReject</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>Test that previousNode properly respects the filter.</p> -<script> -var testElement; -setup(function() { - testElement = document.createElement("div"); - testElement.id = 'root'; - // testElement.innerHTML='<div id="A1"><div id="B1"><div id="C1"></div><div id="C2"><div id="D1"></div><div id="D2"></div></div></div><div id="B2"><div id="C3"></div><div id="C4"></div></div></div>'; - // testElement.innerHTML=' - // <div id="A1"> - // <div id="B1"> - // <div id="C1"> - // </div> - // <div id="C2"> - // <div id="D1"> - // </div> - // <div id="D2"> - // </div> - // </div> - // </div> - // <div id="B2"> - // <div id="C3"> - // </div> - // <div id="C4"> - // </div> - // </div> - // </div>'; - - // XXX for Servo, build the tree without using innerHTML - var a1 = document.createElement("div"); a1.id = "A1"; - var b1 = document.createElement("div"); b1.id = "B1"; - var b2 = document.createElement("div"); b2.id = "B2"; - var c1 = document.createElement("div"); c1.id = "C1"; - var c2 = document.createElement("div"); c2.id = "C2"; - var c3 = document.createElement("div"); c3.id = "C3"; - var c4 = document.createElement("div"); c4.id = "C4"; - var d1 = document.createElement("div"); d1.id = "D1"; - var d2 = document.createElement("div"); d2.id = "D2"; - - testElement.appendChild(a1); - a1.appendChild(b1); - a1.appendChild(b2); - b1.appendChild(c1); - b1.appendChild(c2); - b2.appendChild(c3); - b2.appendChild(c4); - c2.appendChild(d1); - c2.appendChild(d2); -}); - -test(function() -{ - function filter(node) - { - if (node.id == "C2") - return NodeFilter.FILTER_REJECT; - return NodeFilter.FILTER_ACCEPT; - } - - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.currentNode, { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B1' }); - assert_node(walker.currentNode, { type: Element, id: 'B1' }); - assert_node(walker.nextNode(), { type: Element, id: 'C1' }); - assert_node(walker.currentNode, { type: Element, id: 'C1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B2' }); - assert_node(walker.currentNode, { type: Element, id: 'B2' }); - assert_node(walker.previousNode(), { type: Element, id: 'C1' }); - assert_node(walker.currentNode, { type: Element, id: 'C1' }); -}, 'Test that previousNode properly respects the filter.'); -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html b/testing/web-platform/tests/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html deleted file mode 100644 index 17da4d569..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html +++ /dev/null @@ -1,91 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/script-tests/previousSiblingLastChildSkip.js ---> -<head> -<title>TreeWalker: previousSiblingLastChildSkip</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>Test that previousSibling properly respects the filter.</p> -<script> -var testElement; -setup(function() { - testElement = document.createElement("div"); - testElement.id = 'root'; - // testElement.innerHTML='<div id="A1"><div id="B1"><div id="C1"></div><div id="C2"><div id="D1"></div><div id="D2"></div></div></div><div id="B2"><div id="C3"></div><div id="C4"></div></div></div>'; - // testElement.innerHTML=' - // <div id="A1"> - // <div id="B1"> - // <div id="C1"> - // </div> - // <div id="C2"> - // <div id="D1"> - // </div> - // <div id="D2"> - // </div> - // </div> - // </div> - // <div id="B2"> - // <div id="C3"> - // </div> - // <div id="C4"> - // </div> - // </div> - // </div>'; - - // XXX for Servo, build the tree without using innerHTML - var a1 = document.createElement("div"); a1.id = "A1"; - var b1 = document.createElement("div"); b1.id = "B1"; - var b2 = document.createElement("div"); b2.id = "B2"; - var c1 = document.createElement("div"); c1.id = "C1"; - var c2 = document.createElement("div"); c2.id = "C2"; - var c3 = document.createElement("div"); c3.id = "C3"; - var c4 = document.createElement("div"); c4.id = "C4"; - var d1 = document.createElement("div"); d1.id = "D1"; - var d2 = document.createElement("div"); d2.id = "D2"; - - testElement.appendChild(a1); - a1.appendChild(b1); - a1.appendChild(b2); - b1.appendChild(c1); - b1.appendChild(c2); - b2.appendChild(c3); - b2.appendChild(c4); - c2.appendChild(d1); - c2.appendChild(d2); -}); - -test(function() -{ - function filter(node) - { - if (node.id == "B1") - return NodeFilter.FILTER_SKIP; - return NodeFilter.FILTER_ACCEPT; - } - - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter); - assert_node(walker.currentNode, { type: Element, id: 'root' }); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.currentNode, { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'C1' }); - assert_node(walker.currentNode, { type: Element, id: 'C1' }); - assert_node(walker.nextNode(), { type: Element, id: 'C2' }); - assert_node(walker.currentNode, { type: Element, id: 'C2' }); - assert_node(walker.nextNode(), { type: Element, id: 'D1' }); - assert_node(walker.currentNode, { type: Element, id: 'D1' }); - assert_node(walker.nextNode(), { type: Element, id: 'D2' }); - assert_node(walker.currentNode, { type: Element, id: 'D2' }); - assert_node(walker.nextNode(), { type: Element, id: 'B2' }); - assert_node(walker.currentNode, { type: Element, id: 'B2' }); - assert_node(walker.previousSibling(), { type: Element, id: 'C2' }); - assert_node(walker.currentNode, { type: Element, id: 'C2' }); -}, 'Test that previousSibling properly respects the filter.'); -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-reject.html b/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-reject.html deleted file mode 100644 index 273b33236..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-reject.html +++ /dev/null @@ -1,109 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/script-tests/traversal-reject.js ---> -<head> -<title>TreeWalker: traversal-reject</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>Test TreeWalker with rejection</p> -<script> -var testElement; -setup(function() { - testElement = document.createElement("div"); - testElement.id = 'root'; - //testElement.innerHTML='<div id="A1"> <div id="B1"> <div id="C1"></div> </div> <div id="B2"></div><div id="B3"></div> </div>'; - // <div id="A1"> - // <div id="B1"> - // <div id="C1"></div> - // </div> - // <div id="B2"></div> - // <div id="B3"></div> - // </div> - - - // XXX for Servo, build the tree without using innerHTML - var a1 = document.createElement("div"); a1.id = "A1"; - var b1 = document.createElement("div"); b1.id = "B1"; - var b2 = document.createElement("div"); b2.id = "B2"; - var b3 = document.createElement("div"); b3.id = "B3"; - var c1 = document.createElement("div"); c1.id = "C1"; - - testElement.appendChild(a1); - a1.appendChild(b1); - a1.appendChild(b2); - a1.appendChild(b3); - b1.appendChild(c1); -}); - -var rejectB1Filter = { - acceptNode: function(node) { - if (node.id == 'B1') - return NodeFilter.FILTER_REJECT; - - return NodeFilter.FILTER_ACCEPT; - } -} - -var skipB2Filter = { - acceptNode: function(node) { - if (node.id == 'B2') - return NodeFilter.FILTER_SKIP; - - return NodeFilter.FILTER_ACCEPT; - } -} - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, rejectB1Filter); - assert_node(walker.nextNode(), { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B2' }); - assert_node(walker.nextNode(), { type: Element, id: 'B3' }); -}, 'Testing nextNode'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, rejectB1Filter); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.firstChild(), { type: Element, id: 'B2' }); -}, 'Testing firstChild'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB2Filter); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.firstChild(), { type: Element, id: 'B1' }); - assert_node(walker.nextSibling(), { type: Element, id: 'B3' }); -}, 'Testing nextSibling'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, rejectB1Filter); - walker.currentNode = testElement.querySelectorAll('#C1')[0]; - assert_node(walker.parentNode(), { type: Element, id: 'A1' }); -}, 'Testing parentNode'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB2Filter); - walker.currentNode = testElement.querySelectorAll('#B3')[0]; - assert_node(walker.previousSibling(), { type: Element, id: 'B1' }); -}, 'Testing previousSibling'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, rejectB1Filter); - walker.currentNode = testElement.querySelectorAll('#B3')[0]; - assert_node(walker.previousNode(), { type: Element, id: 'B2' }); - assert_node(walker.previousNode(), { type: Element, id: 'A1' }); -}, 'Testing previousNode'); - -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip-most.html b/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip-most.html deleted file mode 100644 index 567ef6655..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip-most.html +++ /dev/null @@ -1,66 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/script-tests/traversal-skip-most.js ---> -<head> -<title>TreeWalker: traversal-skip-most</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>Test TreeWalker with skipping</p> -<script> -var testElement; -setup(function() { - testElement = document.createElement("div"); - testElement.id = 'root'; - // testElement.innerHTML='<div id="A1"><div id="B1" class="keep"></div><div id="B2">this text matters</div><div id="B3" class="keep"></div></div>'; - // <div id="A1"> - // <div id="B1" class="keep"></div> - // <div id="B2">this text matters</div> - // <div id="B3" class="keep"></div> - // </div> - - - // XXX for Servo, build the tree without using innerHTML - var a1 = document.createElement("div"); a1.id = "A1"; - var b1 = document.createElement("div"); b1.id = "B1"; b1.className = "keep"; - var b2 = document.createElement("div"); b2.id = "B2"; - var b3 = document.createElement("div"); b3.id = "B3"; b3.className = "keep"; - - testElement.appendChild(a1); - a1.appendChild(b1); - a1.appendChild(b2) - .appendChild(document.createTextNode("this text matters")); - a1.appendChild(b3); -}); - -var filter = { - acceptNode: function(node) { - if (node.className == 'keep') - return NodeFilter.FILTER_ACCEPT; - - return NodeFilter.FILTER_SKIP; - } -} - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter); - assert_node(walker.firstChild(), { type: Element, id: 'B1' }); - assert_node(walker.nextSibling(), { type: Element, id: 'B3' }); -}, 'Testing nextSibling'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter); - walker.currentNode = testElement.querySelectorAll('#B3')[0]; - assert_node(walker.previousSibling(), { type: Element, id: 'B1' }); -}, 'Testing previousSibling'); - -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html b/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html deleted file mode 100644 index 0e3b81a27..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html +++ /dev/null @@ -1,111 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit/LayoutTests/fast/dom/TreeWalker/script-tests/traversal-skip.js ---> -<head> -<title>TreeWalker: traversal-skip</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>Test TreeWalker with skipping</p> -<script> -var testElement; -setup(function() { - testElement = document.createElement("div"); - testElement.id = 'root'; - // testElement.innerHTML='<div id="A1"> <div id="B1"> <div id="C1"></div> </div> <div id="B2"></div><div id="B3"></div> </div>'; - // <div id="A1"> - // <div id="B1"> - // <div id="C1"></div> - // </div> - // <div id="B2"></div> - // <div id="B3"></div> - // </div> - - - // XXX for Servo, build the tree without using innerHTML - var a1 = document.createElement("div"); a1.id = "A1"; - var b1 = document.createElement("div"); b1.id = "B1"; - var b2 = document.createElement("div"); b2.id = "B2"; - var b3 = document.createElement("div"); b3.id = "B3"; - var c1 = document.createElement("div"); c1.id = "C1"; - - testElement.appendChild(a1); - a1.appendChild(b1); - a1.appendChild(b2); - a1.appendChild(b3); - b1.appendChild(c1); -}); - -var skipB1Filter = { - acceptNode: function(node) { - if (node.id == 'B1') - return NodeFilter.FILTER_SKIP; - - return NodeFilter.FILTER_ACCEPT; - } -} - -var skipB2Filter = { - acceptNode: function(node) { - if (node.id == 'B2') - return NodeFilter.FILTER_SKIP; - - return NodeFilter.FILTER_ACCEPT; - } -} - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB1Filter); - assert_node(walker.nextNode(), { type: Element, id: 'A1' }); - assert_node(walker.nextNode(), { type: Element, id: 'C1' }); - assert_node(walker.nextNode(), { type: Element, id: 'B2' }); - assert_node(walker.nextNode(), { type: Element, id: 'B3' }); -}, 'Testing nextNode'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB1Filter); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.firstChild(), { type: Element, id: 'C1' }); -}, 'Testing firstChild'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB2Filter); - assert_node(walker.firstChild(), { type: Element, id: 'A1' }); - assert_node(walker.firstChild(), { type: Element, id: 'B1' }); - assert_node(walker.nextSibling(), { type: Element, id: 'B3' }); -}, 'Testing nextSibling'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB1Filter); - walker.currentNode = testElement.querySelectorAll('#C1')[0]; - assert_node(walker.parentNode(), { type: Element, id: 'A1' }); -}, 'Testing parentNode'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB2Filter); - walker.currentNode = testElement.querySelectorAll('#B3')[0]; - assert_node(walker.previousSibling(), { type: Element, id: 'B1' }); -}, 'Testing previousSibling'); - -test(function() -{ - var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, skipB1Filter); - walker.currentNode = testElement.querySelectorAll('#B3')[0]; - assert_node(walker.previousNode(), { type: Element, id: 'B2' }); - assert_node(walker.previousNode(), { type: Element, id: 'C1' }); - assert_node(walker.previousNode(), { type: Element, id: 'A1' }); -}, 'Testing previousNode'); - -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-walking-outside-a-tree.html b/testing/web-platform/tests/dom/traversal/TreeWalker-walking-outside-a-tree.html deleted file mode 100644 index ad4334512..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-walking-outside-a-tree.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE html> -<html> -<!-- -Test adapted from https://github.com/operasoftware/presto-testo/blob/master/core/standards/acid3/individual/006a.html ---> -<head> -<title>TreeWalker: walking-outside-a-tree</title> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="traversal-support.js"></script> -<div id=log></div> -</head> -<body> -<p>[Acid3 - Test 006a] walking outside a tree</p> -<script> -test(function () { - // test 6: walking outside a tree - var doc = document.createElement("div"); - var head = document.createElement('head'); - var title = document.createElement('title'); - var body = document.createElement('body'); - var p = document.createElement('p'); - doc.appendChild(head); - head.appendChild(title); - doc.appendChild(body); - body.appendChild(p); - - var w = document.createTreeWalker(body, 0xFFFFFFFF, null); - doc.removeChild(body); - assert_equals(w.lastChild(), p, "TreeWalker failed after removing the current node from the tree"); - doc.appendChild(p); - assert_equals(w.previousNode(), title, "failed to handle regrafting correctly"); - p.appendChild(body); - assert_equals(w.nextNode(), p, "couldn't retrace steps"); - assert_equals(w.nextNode(), body, "couldn't step back into root"); - assert_equals(w.previousNode(), null, "root didn't retake its rootish position"); -}, "walking outside a tree"); -</script> -</body> -</html> diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker.html b/testing/web-platform/tests/dom/traversal/TreeWalker.html deleted file mode 100644 index e0e285a77..000000000 --- a/testing/web-platform/tests/dom/traversal/TreeWalker.html +++ /dev/null @@ -1,298 +0,0 @@ -<!doctype html> -<title>TreeWalker tests</title> -<link rel="author" title="Aryeh Gregor" href=ayg@aryeh.name> -<meta name=timeout content=long> -<div id=log></div> -<script src=/resources/testharness.js></script> -<script src=/resources/testharnessreport.js></script> -<script src=../common.js></script> -<script> -"use strict"; - -// TODO .previousNode, .nextNode - -function filterNode(node, whatToShow, filter) { - // "If active flag is set throw an "InvalidStateError"." - // Ignore active flag for these tests, we aren't calling recursively - // TODO Test me - - // "Let n be node's nodeType attribute value minus 1." - var n = node.nodeType - 1; - - // "If the nth bit (where 0 is the least significant bit) of whatToShow is - // not set, return FILTER_SKIP." - if (!(whatToShow & (1 << n))) { - return NodeFilter.FILTER_SKIP; - } - - // "If filter is null, return FILTER_ACCEPT." - if (!filter) { - return NodeFilter.FILTER_ACCEPT; - } - - // "Set the active flag." - // - // "Let result be the return value of invoking filter." - // - // "Unset the active flag." - // - // "If an exception was thrown, re-throw the exception." - // TODO Test me - // - // "Return result." - return filter(node); -} - -function testTraverseChildren(type, walker, root, whatToShow, filter) { - // TODO We don't test .currentNode other than the root - walker.currentNode = root; - assert_equals(walker.currentNode, root, "Setting .currentNode"); - - var expectedReturn = null; - var expectedCurrentNode = root; - - // "To traverse children of type type, run these steps: - // - // "Let node be the value of the currentNode attribute." - var node = walker.currentNode; - - // "Set node to node's first child if type is first, and node's last child - // if type is last." - node = type == "first" ? node.firstChild : node.lastChild; - - // "Main: While node is not null, run these substeps:" - while (node) { - // "Filter node and let result be the return value." - var result = filterNode(node, whatToShow, filter); - - // "If result is FILTER_ACCEPT, then set the currentNode attribute to - // node and return node." - if (result == NodeFilter.FILTER_ACCEPT) { - expectedCurrentNode = expectedReturn = node; - break; - } - - // "If result is FILTER_SKIP, run these subsubsteps:" - if (result == NodeFilter.FILTER_SKIP) { - // "Let child be node's first child if type is first, and node's - // last child if type is last." - var child = type == "first" ? node.firstChild : node.lastChild; - - // "If child is not null, set node to child and goto Main." - if (child) { - node = child; - continue; - } - } - - // "While node is not null, run these subsubsteps:" - while (node) { - // "Let sibling be node's next sibling if type is first, and node's - // previous sibling if type is last." - var sibling = type == "first" ? node.nextSibling - : node.previousSibling; - - // "If sibling is not null, set node to sibling and goto Main." - if (sibling) { - node = sibling; - break; - } - - // "Let parent be node's parent." - var parent = node.parentNode; - - // "If parent is null, parent is root, or parent is currentNode - // attribute's value, return null." - if (!parent || parent == root || parent == walker.currentNode) { - expectedReturn = node = null; - break; - } else { - // "Otherwise, set node to parent." - node = parent; - } - } - } - - if (type == "first") { - assert_equals(walker.firstChild(), expectedReturn, ".firstChild()"); - assert_equals(walker.currentNode, expectedCurrentNode, - ".currentNode after .firstChild()"); - } else { - assert_equals(walker.lastChild(), expectedReturn, ".lastChild()"); - assert_equals(walker.currentNode, expectedCurrentNode, - ".currentNode after .lastChild()"); - } -} - -function testTraverseSiblings(type, walker, root, whatToShow, filter) { - // TODO We don't test .currentNode other than the root's first or last child - if (!root.firstChild) { - // Nothing much to test - - walker.currentNode = root; - assert_equals(walker.currentNode, root, "Setting .currentNode"); - - if (type == "next") { - assert_equals(walker.nextSibling(), null, ".nextSibling()"); - assert_equals(walker.currentNode, root, - ".currentNode after .nextSibling()") - } else { - assert_equals(walker.previousSibling(), null, ".previousSibling()"); - assert_equals(walker.currentNode, root, - ".currentNode after .previousSibling()") - } - return; - } - - if (type == "next") { - walker.currentNode = root.firstChild; - assert_equals(walker.currentNode, root.firstChild, - "Setting .currentNode"); - } else { - walker.currentNode = root.lastChild; - assert_equals(walker.currentNode, root.lastChild, - "Setting .currentNode"); - } - - var expectedReturn = null; - var expectedCurrentNode = type == "next" ? root.firstChild : root.lastChild; - - // "To traverse siblings of type type run these steps:" - (function() { - // "Let node be the value of the currentNode attribute." - var node = type == "next" ? root.firstChild : root.lastChild; - - // "If node is root, return null. - // - // "Run these substeps: - do { - // "Let sibling be node's next sibling if type is next, and node's - // previous sibling if type is previous." - var sibling = type == "next" ? node.nextSibling : - node.previousSibling; - - // "While sibling is not null, run these subsubsteps:" - while (sibling) { - // "Set node to sibling." - node = sibling; - - // "Filter node and let result be the return value." - var result = filterNode(node, whatToShow, filter); - - // "If result is FILTER_ACCEPT, then set the currentNode - // attribute to node and return node." - if (result == NodeFilter.FILTER_ACCEPT) { - expectedCurrentNode = expectedReturn = node; - return; - } - - // "Set sibling to node's first child if type is next, and - // node's last child if type is previous." - sibling = type == "next" ? node.firstChild : node.lastChild; - - // "If result is FILTER_REJECT or sibling is null, then set - // sibling to node's next sibling if type is next, and node's - // previous sibling if type is previous." - if (result == NodeFilter.FILTER_REJECT || !sibling) { - sibling = type == "next" ? node.nextSibling : - node.previousSibling; - } - } - - // "Set node to its parent." - node = node.parentNode; - - // "If node is null or is root, return null. - if (!node || node == root) { - return; - } - // "Filter node and if the return value is FILTER_ACCEPT, then - // return null." - if (filterNode(node, whatToShow, filter)) { - return; - } - - // "Run these substeps again." - } while (true); - })(); - - if (type == "next") { - assert_equals(walker.nextSibling(), expectedReturn, ".nextSibling()"); - assert_equals(walker.currentNode, expectedCurrentNode, - ".currentNode after .nextSibling()"); - } else { - assert_equals(walker.previousSibling(), expectedReturn, ".previousSibling()"); - assert_equals(walker.currentNode, expectedCurrentNode, - ".currentNode after .previousSibling()"); - } -} - -function testWalker(root, whatToShow, filter) { - var walker = document.createTreeWalker(root, whatToShow, filter); - - assert_equals(walker.root, root, ".root"); - assert_equals(walker.whatToShow, whatToShow, ".whatToShow"); - assert_equals(walker.filter, filter, ".filter"); - assert_equals(walker.currentNode, root, ".currentNode"); - - var expectedReturn = null; - var expectedCurrentNode = walker.currentNode; - // "The parentNode() method must run these steps:" - // - // "Let node be the value of the currentNode attribute." - var node = walker.currentNode; - - // "While node is not null and is not root, run these substeps:" - while (node && node != root) { - // "Let node be node's parent." - node = node.parentNode; - - // "If node is not null and filtering node returns FILTER_ACCEPT, then - // set the currentNode attribute to node, return node." - if (node && filterNode(node, whatToShow, filter) == - NodeFilter.FILTER_ACCEPT) { - expectedCurrentNode = expectedReturn = node; - } - } - assert_equals(walker.parentNode(), expectedReturn, ".parentNode()"); - assert_equals(walker.currentNode, expectedCurrentNode, - ".currentNode after .parentNode()"); - - testTraverseChildren("first", walker, root, whatToShow, filter); - testTraverseChildren("last", walker, root, whatToShow, filter); - - testTraverseSiblings("next", walker, root, whatToShow, filter); - testTraverseSiblings("previous", walker, root, whatToShow, filter); -} - -var whatToShows = [ - "0", - "0xFFFFFFFF", - "NodeFilter.SHOW_ELEMENT", - "NodeFilter.SHOW_ATTRIBUTE", - "NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_DOCUMENT", -]; - -var callbacks = [ - "null", - "(function(node) { return true })", - "(function(node) { return false })", - "(function(node) { return node.nodeName[0] == '#' })", -]; - -var tests = []; -for (var i = 0; i < testNodes.length; i++) { - for (var j = 0; j < whatToShows.length; j++) { - for (var k = 0; k < callbacks.length; k++) { - tests.push([ - "document.createTreeWalker(" + testNodes[i] + - ", " + whatToShows[j] + ", " + callbacks[k] + ")", - eval(testNodes[i]), eval(whatToShows[j]), eval(callbacks[k]) - ]); - } - } -} -generate_tests(testWalker, tests); - -testDiv.style.display = "none"; -</script> diff --git a/testing/web-platform/tests/dom/traversal/traversal-support.js b/testing/web-platform/tests/dom/traversal/traversal-support.js deleted file mode 100644 index 0d5d8ad74..000000000 --- a/testing/web-platform/tests/dom/traversal/traversal-support.js +++ /dev/null @@ -1,10 +0,0 @@ -// |expected| should be an object indicating the expected type of node. -function assert_node(actual, expected) -{ - assert_true(actual instanceof expected.type, - 'Node type mismatch: actual = ' + actual.nodeType + ', expected = ' + expected.nodeType); - if (typeof(expected.id) !== 'undefined') - assert_equals(actual.id, expected.id); - if (typeof(expected.nodeValue) !== 'undefined') - assert_equals(actual.nodeValue, expected.nodeValue); -} diff --git a/testing/web-platform/tests/dom/traversal/unfinished/001.xml b/testing/web-platform/tests/dom/traversal/unfinished/001.xml deleted file mode 100644 index 08bce72fc..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/001.xml +++ /dev/null @@ -1,53 +0,0 @@ -<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 deleted file mode 100644 index bf3489688..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/002.xml +++ /dev/null @@ -1,54 +0,0 @@ -<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 deleted file mode 100644 index 268e6bb4d..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/003.xml +++ /dev/null @@ -1,58 +0,0 @@ -<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 deleted file mode 100644 index 618978f02..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/004.xml +++ /dev/null @@ -1,49 +0,0 @@ -<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 deleted file mode 100644 index 643e2f1cd..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/005.xml +++ /dev/null @@ -1,57 +0,0 @@ -<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 deleted file mode 100644 index c2302af83..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/006.xml +++ /dev/null @@ -1,47 +0,0 @@ -<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 deleted file mode 100644 index 98b212e4e..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/007.xml +++ /dev/null @@ -1,54 +0,0 @@ -<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 deleted file mode 100644 index 41d7008ae..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/008.xml +++ /dev/null @@ -1,48 +0,0 @@ -<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 deleted file mode 100644 index c3006ecbd..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/009.xml +++ /dev/null @@ -1,55 +0,0 @@ -<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 deleted file mode 100644 index 63263a5fd..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/010.xml +++ /dev/null @@ -1,64 +0,0 @@ -<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 deleted file mode 100644 index cecdf98b0..000000000 --- a/testing/web-platform/tests/dom/traversal/unfinished/TODO +++ /dev/null @@ -1 +0,0 @@ -Check what happens when a NodeFilter turns a number not in the range 1..3
\ No newline at end of file |