Re-sync web-platform-tests/dom/traversal from upstream
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 02:36:47 +0000 (02:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 02:36:47 +0000 (02:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200737

Patch by Alexey Shvayka <shvaikalesh@gmail.com> on 2019-08-14
Reviewed by Ryosuke Niwa.

Re-sync web-platform-tests/dom/traversal from upstream 91adbef87678.

* resources/import-expectations.json:
* web-platform-tests/dom/traversal/*: Updated.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248705 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/resources/import-expectations.json
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/NodeIterator.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-acceptNode-filter.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-basic.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-currentNode.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-previousNodeLastChildReject.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-previousSiblingLastChildSkip.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-traversal-reject.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-traversal-skip-most.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-traversal-skip.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-walking-outside-a-tree.html
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/assert-node.js [moved from LayoutTests/imported/w3c/web-platform-tests/dom/traversal/traversal-support.js with 100% similarity]
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/w3c-import.log [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/w3c-import.log

index 827a48f..413caff 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Alexey Shvayka  <shvaikalesh@gmail.com>
+
+        Re-sync web-platform-tests/dom/traversal from upstream
+        https://bugs.webkit.org/show_bug.cgi?id=200737
+
+        Reviewed by Ryosuke Niwa.
+
+        Re-sync web-platform-tests/dom/traversal from upstream 91adbef87678.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/dom/traversal/*: Updated.
+
 2019-08-13  Alexey Shvayka  <shvaikalesh@gmail.com>
 
         Re-sync web-platform-tests/dom/events from upstream
index 30553a7..664b96a 100644 (file)
     "web-platform-tests/dom/nodes/Element-siblingElement-null.xhtml": "skip", 
     "web-platform-tests/dom/nodes/Node-nodeName.xhtml": "skip", 
     "web-platform-tests/dom/nodes/ParentNode-querySelector-All.xht": "skip", 
+    "web-platform-tests/dom/traversal": "import", 
     "web-platform-tests/dom/traversal/unfinished": "skip", 
     "web-platform-tests/domparsing": "import", 
     "web-platform-tests/domparsing/DOMParser-parseFromString-xml-doctype.html": "skip", 
index 677858d..3db5dec 100644 (file)
@@ -200,20 +200,15 @@ var callbacks = [
   "(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])
-      ]);
+      test(() => {
+        testIterator(eval(testNodes[i]), eval(whatToShows[j]), eval(callbacks[k]));
+      }, "document.createNodeIterator(" + testNodes[i] + ", " + whatToShows[j] + ", " + callbacks[k] + ")");
     }
   }
 }
 
-generate_tests(testIterator, tests);
-
 testDiv.style.display = "none";
 </script>
index c18e70b..72a87af 100644 (file)
@@ -6,7 +6,8 @@ PASS Testing with undefined filter
 PASS Testing with object lacking acceptNode property 
 PASS Testing with object with non-function acceptNode property 
 PASS Testing with function having acceptNode function 
-PASS Testing acceptNode callee 
 PASS Testing with filter function that throws 
+FAIL rethrows errors when getting `acceptNode` assert_throws: function "function () { walker.firstChild(); }" threw object "TypeError: Type error" ("TypeError") expected object "[object Object]" ("test")
+PASS performs `Get` on every traverse 
 PASS Testing with filter object that throws 
 Test JS objects as NodeFilters
index 1446f40..5d521f0 100644 (file)
@@ -7,7 +7,8 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: acceptNode-filter</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
+<link rel="help" href="https://dom.spec.whatwg.org/#callbackdef-nodefilter">
 <div id=log></div>
 </head>
 <body>
@@ -102,10 +103,10 @@ test(function()
     assert_node(walker.currentNode, { type: Element, id: 'root' });
 }, 'Testing with object with non-function acceptNode property');
 
-test(function()
+test(function(t)
 {
     var filter = function() { return NodeFilter.FILTER_ACCEPT; };
-    filter.acceptNode = function(node) { return NodeFilter.FILTER_SKIP; };
+    filter.acceptNode = t.unreached_func("`acceptNode` method should not be called on functions");
     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' });
@@ -113,17 +114,6 @@ test(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) {
@@ -135,6 +125,38 @@ test(function()
     assert_node(walker.currentNode, { type: Element, id: 'root' });
 }, 'Testing with filter function that throws');
 
+test(function() {
+    var testError = { name: "test" };
+    var filter = {
+        get acceptNode() {
+            throw testError;
+        },
+    };
+
+    var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter);
+    assert_throws(testError, function() { walker.firstChild(); });
+    assert_node(walker.currentNode, { type: Element, id: 'root' });
+    assert_throws(testError, function() { walker.nextNode(); });
+    assert_node(walker.currentNode, { type: Element, id: 'root' });
+}, "rethrows errors when getting `acceptNode`");
+
+test(function() {
+    var calls = 0;
+    var walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, {
+        get acceptNode() {
+            calls++;
+            return function() {
+                return NodeFilter.FILTER_ACCEPT;
+            };
+        },
+    });
+
+    assert_equals(calls, 0);
+    walker.nextNode();
+    walker.nextNode();
+    assert_equals(calls, 2);
+}, "performs `Get` on every traverse");
+
 test(function()
 {
     var test_error = { name: "test" };
index d114763..100cb10 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: Basic test</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
index 8a09940..7c5d881 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: currentNode</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
index 236ab80..0147b81 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: previousNodeLastChildReject</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
index 17da4d5..5566564 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: previousSiblingLastChildSkip</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
index 273b332..53b7341 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: traversal-reject</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
index 567ef66..173922c 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: traversal-skip-most</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
index 0e3b81a..8c6f2bf 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit
 <title>TreeWalker: traversal-skip</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="traversal-support.js"></script>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
index ad43345..b99e33e 100644 (file)
@@ -7,7 +7,7 @@ Test adapted from https://github.com/operasoftware/presto-testo/blob/master/core
 <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>
+<script src="support/assert-node.js"></script>
 <div id=log></div>
 </head>
 <body>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/w3c-import.log
new file mode 100644 (file)
index 0000000..41dcce7
--- /dev/null
@@ -0,0 +1,17 @@
+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the WPT github:
+       https://github.com/web-platform-tests/wpt
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/support/assert-node.js
index 12ff12f..4ebe74e 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
@@ -27,4 +27,3 @@ List of files:
 /LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-traversal-skip.html
 /LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-walking-outside-a-tree.html
 /LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker.html
-/LayoutTests/imported/w3c/web-platform-tests/dom/traversal/traversal-support.js