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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 "logging", | 149 "logging", |
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_) | 159 if (context_->is_valid()) |
160 context_->v8_context()->Exit(); | 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) { |
(...skipping 20 matching lines...) Expand all Loading... |
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 context_->v8_context()->Exit(); | 199 context_->v8_context()->Exit(); |
200 context_.reset(); | 200 context_->Invalidate(); |
201 } | 201 } |
202 | 202 |
203 v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal( | 203 v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal( |
204 const std::string& name) { | 204 const std::string& name) { |
205 v8::EscapableHandleScope handle_scope(isolate_); | 205 v8::EscapableHandleScope handle_scope(isolate_); |
206 v8::Local<v8::Object> object = v8::Object::New(isolate_); | 206 v8::Local<v8::Object> object = v8::Object::New(isolate_); |
207 isolate_->GetCurrentContext()->Global()->Set( | 207 isolate_->GetCurrentContext()->Global()->Set( |
208 v8::String::NewFromUtf8(isolate_, name.c_str()), object); | 208 v8::String::NewFromUtf8(isolate_, name.c_str()), object); |
209 return handle_scope.Escape(object); | 209 return handle_scope.Escape(object); |
210 } | 210 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 void ModuleSystemTest::ExpectNoAssertionsMade() { | 247 void ModuleSystemTest::ExpectNoAssertionsMade() { |
248 should_assertions_be_made_ = false; | 248 should_assertions_be_made_ = false; |
249 } | 249 } |
250 | 250 |
251 void ModuleSystemTest::RunResolvedPromises() { | 251 void ModuleSystemTest::RunResolvedPromises() { |
252 isolate_->RunMicrotasks(); | 252 isolate_->RunMicrotasks(); |
253 } | 253 } |
254 | 254 |
255 } // namespace extensions | 255 } // namespace extensions |
OLD | NEW |