Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js

Issue 932633002: Call NodeFilter.acceptNode() with correct this value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js
diff --git a/LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js b/LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js
index 1add65c5dc9ffc3e68b1fdd5acd11d2c1ad26c82..09f926313c3d093bfbc5c7fd997aacb62f63d727 100644
--- a/LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js
+++ b/LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js
@@ -7,7 +7,7 @@ testElement.innerHTML='<div id="A1"><div id="B1"></div><div id="B2"></div></div>
function filter(node)
{
- debug(" filtering node " + node.id);
+ debug(" filtering node " + node.id + " [this=" + this + "]");
if (node.id == "B1")
return NodeFilter.FILTER_SKIP;
return NodeFilter.FILTER_ACCEPT;
@@ -18,10 +18,27 @@ walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, filter,
shouldBe("walker.firstChild(); walker.currentNode.id", "'A1'");
shouldBe("walker.nextNode(); walker.currentNode.id", "'B2'");
+function strictFilter(node)
+{
+ "use strict";
+ debug(" filtering node " + node.id + " [this=" + this + "]");
+ if (node.id == "B1")
+ return NodeFilter.FILTER_SKIP;
+ return NodeFilter.FILTER_ACCEPT;
+}
+
+debug("<br>Testing with strict raw function filter");
+walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, strictFilter, false);
+shouldBe("walker.firstChild(); walker.currentNode.id", "'A1'");
+shouldBe("walker.nextNode(); walker.currentNode.id", "'B2'");
+
debug("<br>Testing with object filter");
walker = document.createTreeWalker(testElement, NodeFilter.SHOW_ELEMENT, {
+ toString : function() {
+ return "custom node filter";
+ },
acceptNode : function(node) {
- debug(" filtering node " + node.id);
+ debug(" filtering node " + node.id + " [this=" + this + "]");
if (node.id == "B1")
return NodeFilter.FILTER_SKIP;
return NodeFilter.FILTER_ACCEPT;
« no previous file with comments | « LayoutTests/fast/dom/TreeWalker/acceptNode-filter-expected.txt ('k') | Source/bindings/core/v8/V8NodeFilterCondition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698