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

Unified Diff: LayoutTests/resources/js-test.js

Issue 220203005: Oilpan: introduce sticky forcedForTesting flag to ensure that a precise (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments. Created 6 years, 9 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/resources/js-test.js
diff --git a/LayoutTests/resources/js-test.js b/LayoutTests/resources/js-test.js
index 791b728108f45d6ac91bd9866ee353671718505a..485d3f6895cc9637f4df002af77c20a111bfb3f8 100644
--- a/LayoutTests/resources/js-test.js
+++ b/LayoutTests/resources/js-test.js
@@ -649,6 +649,30 @@ function shouldHaveHadError(message)
testFailed("expectError() not called before shouldHaveHadError()");
}
+// With Oilpan tests that rely on garbage collection need to go through
+// the event loop in order to get precise garbage collections. Oilpan
+// uses conservative stack scanning when not at the event loop and that
+// can artificially keep objects alive. Therefore, tests that need to check
+// that something is dead need to use this asynchronous collectGarbage
+// function.
+function collectGarbage(callback) {
+ // Perform multiple GCs to break sequences of Oilpan Persistent handles
+ // or RefPtrs that will keep objects alive until the next GC.
+ // FIXME: Oilpan: Once everything is moved to the oilpan heap we can
+ // reduce the number of garbage collections.
+ GCController.collect();
+ setTimeout(function() {
+ GCController.collect();
+ setTimeout(function() {
+ GCController.collect();
+ setTimeout(function() {
+ GCController.collect();
+ setTimeout(callback, 0);
+ }, 0);
+ }, 0);
+ }, 0);
+}
+
function gc() {
if (typeof GCController !== "undefined")
GCController.collectAll();

Powered by Google App Engine
This is Rietveld 408576698