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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 <script>
6 var callbackWasTriggered = false;
7
8 var callback = function(node) {
9 callbackWasTriggered = true;
10 return NodeFilter.FILTER_ACCEPT;
11 };
12 var nodeIterator = document.createNodeIterator(document, NodeFilter.SHOW_ELE MENT, callback, false);
13
14 var callbackObservation = internals.observeGC(callback);
15 var nodeFilterObservation = internals.observeGC(nodeIterator.filter);
16 var nodeIteratorObservation = internals.observeGC(nodeIterator);
17
18 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.
19 gc();
20 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.
21 shouldBeTrue("!callbackObservation.wasCollected", "The callback should not b e collected while nodeIterator is alive");
22
23 nodeIterator.nextNode();
24 shouldBeTrue("callbackWasTriggered", "The callback should be triggered when iterated");
25
26 nodeIterator = null;
27 gc();
28 shouldBeTrue("nodeIteratorObservation.wasCollected", "The nodeIterator shoul d 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.
29 shouldBeTrue("nodeFilterObservation.wasCollected", "The NodeFilter wrapper s hould be collected when nodeIterator is collected");
30 shouldBeTrue("callbackObservation.wasCollected", "The callback should be col lected 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.
31 </script>
32 <script src="../../js/resources/js-test-post.js"></script>
33 </body>
34 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698