diff --git a/testing/web-platform/tests/dom/events/EventListener-handleEvent.html b/testing/web-platform/tests/dom/events/EventListener-handleEvent.html index 6630f273fff4..1eb80ccb15f0 100644 --- a/testing/web-platform/tests/dom/events/EventListener-handleEvent.html +++ b/testing/web-platform/tests/dom/events/EventListener-handleEvent.html @@ -5,13 +5,12 @@
-
diff --git a/testing/web-platform/tests/dom/traversal/TreeWalker-acceptNode-filter.html b/testing/web-platform/tests/dom/traversal/TreeWalker-acceptNode-filter.html index 1446f40f68dd..e2110aff3b3d 100644 --- a/testing/web-platform/tests/dom/traversal/TreeWalker-acceptNode-filter.html +++ b/testing/web-platform/tests/dom/traversal/TreeWalker-acceptNode-filter.html @@ -8,6 +8,7 @@ Test adapted from https://dxr.mozilla.org/chromium/source/src/third_party/WebKit +
@@ -102,26 +103,15 @@ 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' }); }, '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" }; @@ -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" };