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

Unified Diff: extensions/renderer/module_system_test.cc

Issue 502893002: Fix some leaks and failures under valgrind in JS extensions unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetUp Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/module_system_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/module_system_test.cc
diff --git a/extensions/renderer/module_system_test.cc b/extensions/renderer/module_system_test.cc
index 4f4675e625610be86972476ac2dca54fd4e68d07..aa6480f65837bd88d213bb9ba54f84950475b701 100644
--- a/extensions/renderer/module_system_test.cc
+++ b/extensions/renderer/module_system_test.cc
@@ -209,18 +209,33 @@ v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal(
ModuleSystemTest::ModuleSystemTest()
: isolate_(v8::Isolate::GetCurrent()),
- env_(CreateEnvironment()),
should_assertions_be_made_(true) {
}
ModuleSystemTest::~ModuleSystemTest() {
}
+void ModuleSystemTest::SetUp() {
+ env_ = CreateEnvironment();
+}
+
void ModuleSystemTest::TearDown() {
// All tests must assert at least once unless otherwise specified.
EXPECT_EQ(should_assertions_be_made_,
env_->assert_natives()->assertion_made());
EXPECT_FALSE(env_->assert_natives()->failed());
+ env_.reset();
+ v8::HeapStatistics stats;
+ isolate_->GetHeapStatistics(&stats);
+ size_t old_heap_size = 0;
+ // Run the GC until the heap size reaches a steady state to ensure that
+ // all the garbage is collected.
+ while (stats.used_heap_size() != old_heap_size) {
+ old_heap_size = stats.used_heap_size();
+ isolate_->RequestGarbageCollectionForTesting(
+ v8::Isolate::kFullGarbageCollection);
+ isolate_->GetHeapStatistics(&stats);
+ }
}
scoped_ptr<ModuleSystemTestEnvironment> ModuleSystemTest::CreateEnvironment() {
« no previous file with comments | « extensions/renderer/module_system_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698