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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/NodeIterator/NodeIterator-dont-overcollect.html

Issue 1950613005: Fixes tests that use internals.observeGC to work with Ignition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed special wrapper for internals.observeGC. Adds an inner function to pass the object. Created 4 years, 7 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 <script> 5 <script>
6 var callbackWasTriggered = false; 6 var callbackWasTriggered = false;
7 7
8 var callback = function(node) { 8 var callback = function(node) {
9 callbackWasTriggered = true; 9 callbackWasTriggered = true;
10 return NodeFilter.FILTER_ACCEPT; 10 return NodeFilter.FILTER_ACCEPT;
11 }; 11 };
12 var nodeIterator = document.createNodeIterator(document, NodeFilter.SHOW_ELE MENT, callback, false); 12 var nodeIterator = document.createNodeIterator(document, NodeFilter.SHOW_ELE MENT, callback, false);
13 13
14 var callbackObservation = internals.observeGC(callback); 14 // Do not pass the object as a parameter to observeGC function. This may
15 // remain live on this function's stack preventing GC from collecting
16 // it. Accessing the object inside an inner function will prevent any
17 // unneeded references on this function's stack.
18 var callbackObservation = internals.observeGC((() => {return callback;})());
15 callback = null; 19 callback = null;
16 var nodeFilterObservation = internals.observeGC(nodeIterator.filter); 20 var nodeFilterObservation = internals.observeGC((() => {return nodeIterator. filter;})());
17 var nodeIteratorObservation = internals.observeGC(nodeIterator); 21 var nodeIteratorObservation = internals.observeGC((() => {return nodeIterato r;})());
18 22
19 gc(); 23 gc();
20 shouldBeFalse('nodeFilterObservation.wasCollected'); 24 shouldBeFalse('nodeFilterObservation.wasCollected');
21 shouldBeFalse('callbackObservation.wasCollected'); 25 shouldBeFalse('callbackObservation.wasCollected');
22 26
23 nodeIterator.nextNode(); 27 nodeIterator.nextNode();
24 shouldBeTrue('callbackWasTriggered'); 28 shouldBeTrue('callbackWasTriggered');
25 29
26 nodeIterator = null; 30 nodeIterator = null;
27 gc(); 31 gc();
28 shouldBeTrue('nodeIteratorObservation.wasCollected'); 32 shouldBeTrue('nodeIteratorObservation.wasCollected');
29 shouldBeTrue('nodeFilterObservation.wasCollected'); 33 shouldBeTrue('nodeFilterObservation.wasCollected');
30 shouldBeTrue('callbackObservation.wasCollected'); 34 shouldBeTrue('callbackObservation.wasCollected');
31 </script> 35 </script>
32 </body> 36 </body>
33 </html> 37 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698