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

Unified Diff: LayoutTests/fast/dom/NodeIterator/NodeIterator-dont-overcollect.html

Issue 21274004: Fix Document leak from NodeFilter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add TreeWalker leak test Created 7 years, 5 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/NodeIterator/NodeIterator-dont-overcollect.html
diff --git a/LayoutTests/fast/dom/NodeIterator/NodeIterator-dont-overcollect.html b/LayoutTests/fast/dom/NodeIterator/NodeIterator-dont-overcollect.html
new file mode 100644
index 0000000000000000000000000000000000000000..7f9b0c7773df88a1f597248b4fcc031cda7cef3f
--- /dev/null
+++ b/LayoutTests/fast/dom/NodeIterator/NodeIterator-dont-overcollect.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+ var callbackWasTriggered = false;
+
+ var callback = function(node) {
+ callbackWasTriggered = true;
+ return NodeFilter.FILTER_ACCEPT;
+ };
+ var nodeIterator = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, callback, false);
+
+ var callbackObservation = internals.observeGC(callback);
+ var nodeFilterObservation = internals.observeGC(nodeIterator.filter);
+ var nodeIteratorObservation = internals.observeGC(nodeIterator);
+
+ callback = null;
dominicc (has gone to gerrit) 2013/08/01 04:51:12 For style, I would put this line right after creat
kouhei (in TOK) 2013/08/01 05:09:58 Done.
kouhei (in TOK) 2013/08/01 05:09:58 Done.
+ gc();
+ shouldBeTrue("!nodeFilterObservation.wasCollected", "The NodeFilter wrapper should not be collected while nodeIterator is alive");
dominicc (has gone to gerrit) 2013/08/01 04:51:12 shouldBeTrue("! -> shouldBeFalse("
dominicc (has gone to gerrit) 2013/08/01 04:51:12 Use single quotes for JavaScript string literals.
kouhei (in TOK) 2013/08/01 05:09:58 Done.
+ shouldBeTrue("!callbackObservation.wasCollected", "The callback should not be collected while nodeIterator is alive");
+
+ nodeIterator.nextNode();
+ shouldBeTrue("callbackWasTriggered", "The callback should be triggered when iterated");
+
+ nodeIterator = null;
+ gc();
+ shouldBeTrue("nodeIteratorObservation.wasCollected", "The nodeIterator should be collected.");
dominicc (has gone to gerrit) 2013/08/01 04:51:12 I think shouldBeTrue just takes one arg. If you we
kouhei (in TOK) 2013/08/01 05:09:58 Done.
+ shouldBeTrue("nodeFilterObservation.wasCollected", "The NodeFilter wrapper should be collected when nodeIterator is collected");
+ shouldBeTrue("callbackObservation.wasCollected", "The callback should be collected when nodeIterator is collected");
haraken 2013/08/01 03:44:15 I don't fully understand how internals.observeGC w
dominicc (has gone to gerrit) 2013/08/01 04:51:12 Because line 18 sets it to null.
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698