| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 scoped_ptr<NativeHandler>(new LoggingNativeHandler(context_.get()))); | 150 scoped_ptr<NativeHandler>(new LoggingNativeHandler(context_.get()))); |
| 151 module_system->RegisterNativeHandler( | 151 module_system->RegisterNativeHandler( |
| 152 "utils", | 152 "utils", |
| 153 scoped_ptr<NativeHandler>(new UtilsNativeHandler(context_.get()))); | 153 scoped_ptr<NativeHandler>(new UtilsNativeHandler(context_.get()))); |
| 154 module_system->SetExceptionHandlerForTest( | 154 module_system->SetExceptionHandlerForTest( |
| 155 scoped_ptr<ModuleSystem::ExceptionHandler>(new FailsOnException)); | 155 scoped_ptr<ModuleSystem::ExceptionHandler>(new FailsOnException)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 ModuleSystemTestEnvironment::~ModuleSystemTestEnvironment() { | 158 ModuleSystemTestEnvironment::~ModuleSystemTestEnvironment() { |
| 159 if (context_->is_valid()) | 159 if (context_->is_valid()) |
| 160 ShutdownModuleSystem(); | 160 context_->v8_context()->Exit(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ModuleSystemTestEnvironment::RegisterModule(const std::string& name, | 163 void ModuleSystemTestEnvironment::RegisterModule(const std::string& name, |
| 164 const std::string& code) { | 164 const std::string& code) { |
| 165 source_map_->RegisterModule(name, code); | 165 source_map_->RegisterModule(name, code); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ModuleSystemTestEnvironment::RegisterModule(const std::string& name, | 168 void ModuleSystemTestEnvironment::RegisterModule(const std::string& name, |
| 169 int resource_id) { | 169 int resource_id) { |
| 170 const std::string& code = ResourceBundle::GetSharedInstance() | 170 const std::string& code = ResourceBundle::GetSharedInstance() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 189 std::string test_js; | 189 std::string test_js; |
| 190 ASSERT_TRUE(base::ReadFileToString(test_js_file_path, &test_js)); | 190 ASSERT_TRUE(base::ReadFileToString(test_js_file_path, &test_js)); |
| 191 source_map_->RegisterModule(module_name, test_js); | 191 source_map_->RegisterModule(module_name, test_js); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void ModuleSystemTestEnvironment::ShutdownGin() { | 194 void ModuleSystemTestEnvironment::ShutdownGin() { |
| 195 context_holder_.reset(); | 195 context_holder_.reset(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void ModuleSystemTestEnvironment::ShutdownModuleSystem() { | 198 void ModuleSystemTestEnvironment::ShutdownModuleSystem() { |
| 199 CHECK(context_->is_valid()); | |
| 200 context_->v8_context()->Exit(); | 199 context_->v8_context()->Exit(); |
| 201 context_->Invalidate(); | 200 context_->Invalidate(); |
| 202 } | 201 } |
| 203 | 202 |
| 204 v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal( | 203 v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal( |
| 205 const std::string& name) { | 204 const std::string& name) { |
| 206 v8::EscapableHandleScope handle_scope(isolate_); | 205 v8::EscapableHandleScope handle_scope(isolate_); |
| 207 v8::Local<v8::Object> object = v8::Object::New(isolate_); | 206 v8::Local<v8::Object> object = v8::Object::New(isolate_); |
| 208 isolate_->GetCurrentContext()->Global()->Set( | 207 isolate_->GetCurrentContext()->Global()->Set( |
| 209 v8::String::NewFromUtf8(isolate_, name.c_str()), object); | 208 v8::String::NewFromUtf8(isolate_, name.c_str()), object); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 246 |
| 248 void ModuleSystemTest::ExpectNoAssertionsMade() { | 247 void ModuleSystemTest::ExpectNoAssertionsMade() { |
| 249 should_assertions_be_made_ = false; | 248 should_assertions_be_made_ = false; |
| 250 } | 249 } |
| 251 | 250 |
| 252 void ModuleSystemTest::RunResolvedPromises() { | 251 void ModuleSystemTest::RunResolvedPromises() { |
| 253 isolate_->RunMicrotasks(); | 252 isolate_->RunMicrotasks(); |
| 254 } | 253 } |
| 255 | 254 |
| 256 } // namespace extensions | 255 } // namespace extensions |
| OLD | NEW |