OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/renderer/module_system_test.h" | 5 #include "extensions/renderer/module_system_test.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 const std::string& name) { | 202 const std::string& name) { |
203 v8::EscapableHandleScope handle_scope(isolate_); | 203 v8::EscapableHandleScope handle_scope(isolate_); |
204 v8::Local<v8::Object> object = v8::Object::New(isolate_); | 204 v8::Local<v8::Object> object = v8::Object::New(isolate_); |
205 isolate_->GetCurrentContext()->Global()->Set( | 205 isolate_->GetCurrentContext()->Global()->Set( |
206 v8::String::NewFromUtf8(isolate_, name.c_str()), object); | 206 v8::String::NewFromUtf8(isolate_, name.c_str()), object); |
207 return handle_scope.Escape(object); | 207 return handle_scope.Escape(object); |
208 } | 208 } |
209 | 209 |
210 ModuleSystemTest::ModuleSystemTest() | 210 ModuleSystemTest::ModuleSystemTest() |
211 : isolate_(v8::Isolate::GetCurrent()), | 211 : isolate_(v8::Isolate::GetCurrent()), |
212 env_(CreateEnvironment()), | 212 env_(CreateEnvironment()), |
not at google - send to devlin
2014/08/28 15:42:04
As a nit, I wonder if env_ should be initialised i
Sam McNally
2014/08/29 01:13:21
Done.
| |
213 should_assertions_be_made_(true) { | 213 should_assertions_be_made_(true) { |
214 } | 214 } |
215 | 215 |
216 ModuleSystemTest::~ModuleSystemTest() { | 216 ModuleSystemTest::~ModuleSystemTest() { |
217 } | 217 } |
218 | 218 |
219 void ModuleSystemTest::TearDown() { | 219 void ModuleSystemTest::TearDown() { |
220 // All tests must assert at least once unless otherwise specified. | 220 // All tests must assert at least once unless otherwise specified. |
221 EXPECT_EQ(should_assertions_be_made_, | 221 EXPECT_EQ(should_assertions_be_made_, |
222 env_->assert_natives()->assertion_made()); | 222 env_->assert_natives()->assertion_made()); |
223 EXPECT_FALSE(env_->assert_natives()->failed()); | 223 EXPECT_FALSE(env_->assert_natives()->failed()); |
224 env_.reset(); | |
225 v8::HeapStatistics stats; | |
226 isolate_->GetHeapStatistics(&stats); | |
227 size_t old_heap_size = 0; | |
228 // Run the GC until the heap size reaches a steady state to ensure that | |
229 // all the garbage is collected. | |
230 while (stats.used_heap_size() != old_heap_size) { | |
231 old_heap_size = stats.used_heap_size(); | |
232 isolate_->RequestGarbageCollectionForTesting( | |
233 v8::Isolate::kFullGarbageCollection); | |
234 isolate_->GetHeapStatistics(&stats); | |
235 } | |
not at google - send to devlin
2014/08/28 15:42:04
Yikes :(
| |
224 } | 236 } |
225 | 237 |
226 scoped_ptr<ModuleSystemTestEnvironment> ModuleSystemTest::CreateEnvironment() { | 238 scoped_ptr<ModuleSystemTestEnvironment> ModuleSystemTest::CreateEnvironment() { |
227 return make_scoped_ptr(new ModuleSystemTestEnvironment(isolate_)); | 239 return make_scoped_ptr(new ModuleSystemTestEnvironment(isolate_)); |
228 } | 240 } |
229 | 241 |
230 void ModuleSystemTest::ExpectNoAssertionsMade() { | 242 void ModuleSystemTest::ExpectNoAssertionsMade() { |
231 should_assertions_be_made_ = false; | 243 should_assertions_be_made_ = false; |
232 } | 244 } |
233 | 245 |
234 void ModuleSystemTest::RunResolvedPromises() { | 246 void ModuleSystemTest::RunResolvedPromises() { |
235 isolate_->RunMicrotasks(); | 247 isolate_->RunMicrotasks(); |
236 } | 248 } |
237 | 249 |
238 } // namespace extensions | 250 } // namespace extensions |
OLD | NEW |