summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html')
-rw-r--r--testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html111
1 files changed, 111 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html b/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html
new file mode 100644
index 000000000..0e3b81a27
--- /dev/null
+++ b/testing/web-platform/tests/dom/traversal/TreeWalker-traversal-skip.html
@@ -0,0 +1,111 @@
+<!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>