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/api_test_base.h" | 5 #include "extensions/renderer/api_test_base.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "extensions/common/extension_urls.h" | 11 #include "extensions/common/extension_urls.h" |
12 #include "extensions/renderer/dispatcher.h" | 12 #include "extensions/renderer/dispatcher.h" |
13 #include "extensions/renderer/process_info_native_handler.h" | 13 #include "extensions/renderer/process_info_native_handler.h" |
14 #include "gin/converter.h" | 14 #include "gin/converter.h" |
15 #include "gin/dictionary.h" | 15 #include "gin/dictionary.h" |
| 16 #include "mojo/edk/js/core.h" |
| 17 #include "mojo/edk/js/handle.h" |
| 18 #include "mojo/edk/js/support.h" |
16 #include "mojo/public/cpp/bindings/interface_request.h" | 19 #include "mojo/public/cpp/bindings/interface_request.h" |
17 #include "mojo/public/cpp/system/core.h" | 20 #include "mojo/public/cpp/system/core.h" |
18 #include "third_party/mojo/src/mojo/edk/js/core.h" | |
19 #include "third_party/mojo/src/mojo/edk/js/handle.h" | |
20 #include "third_party/mojo/src/mojo/edk/js/support.h" | |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Natives for the implementation of the unit test version of chrome.test. Calls | 25 // Natives for the implementation of the unit test version of chrome.test. Calls |
26 // the provided |quit_closure| when either notifyPass or notifyFail is called. | 26 // the provided |quit_closure| when either notifyPass or notifyFail is called. |
27 class TestNatives : public gin::Wrappable<TestNatives> { | 27 class TestNatives : public gin::Wrappable<TestNatives> { |
28 public: | 28 public: |
29 static gin::Handle<TestNatives> Create(v8::Isolate* isolate, | 29 static gin::Handle<TestNatives> Create(v8::Isolate* isolate, |
30 const base::Closure& quit_closure) { | 30 const base::Closure& quit_closure) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 "function() { return [] });"); | 148 "function() { return [] });"); |
149 env()->OverrideNativeHandler( | 149 env()->OverrideNativeHandler( |
150 "event_natives", | 150 "event_natives", |
151 "exports.$set('AttachEvent', function() {});" | 151 "exports.$set('AttachEvent', function() {});" |
152 "exports.$set('DetachEvent', function() {});" | 152 "exports.$set('DetachEvent', function() {});" |
153 "exports.$set('AttachFilteredEvent', function() {});" | 153 "exports.$set('AttachFilteredEvent', function() {});" |
154 "exports.$set('AttachFilteredEvent', function() {});" | 154 "exports.$set('AttachFilteredEvent', function() {});" |
155 "exports.$set('MatchAgainstEventFilter', function() { return [] });"); | 155 "exports.$set('MatchAgainstEventFilter', function() { return [] });"); |
156 | 156 |
157 gin::ModuleRegistry::From(env()->context()->v8_context()) | 157 gin::ModuleRegistry::From(env()->context()->v8_context()) |
158 ->AddBuiltinModule(env()->isolate(), | 158 ->AddBuiltinModule(env()->isolate(), mojo::edk::js::Core::kModuleName, |
159 mojo::js::Core::kModuleName, | 159 mojo::edk::js::Core::GetModule(env()->isolate())); |
160 mojo::js::Core::GetModule(env()->isolate())); | |
161 gin::ModuleRegistry::From(env()->context()->v8_context()) | 160 gin::ModuleRegistry::From(env()->context()->v8_context()) |
162 ->AddBuiltinModule(env()->isolate(), | 161 ->AddBuiltinModule(env()->isolate(), mojo::edk::js::Support::kModuleName, |
163 mojo::js::Support::kModuleName, | 162 mojo::edk::js::Support::GetModule(env()->isolate())); |
164 mojo::js::Support::GetModule(env()->isolate())); | |
165 gin::Handle<TestServiceProvider> service_provider = | 163 gin::Handle<TestServiceProvider> service_provider = |
166 TestServiceProvider::Create(env()->isolate()); | 164 TestServiceProvider::Create(env()->isolate()); |
167 service_provider_ = service_provider.get(); | 165 service_provider_ = service_provider.get(); |
168 gin::ModuleRegistry::From(env()->context()->v8_context()) | 166 gin::ModuleRegistry::From(env()->context()->v8_context()) |
169 ->AddBuiltinModule(env()->isolate(), | 167 ->AddBuiltinModule(env()->isolate(), |
170 "content/public/renderer/service_provider", | 168 "content/public/renderer/service_provider", |
171 service_provider.ToV8()); | 169 service_provider.ToV8()); |
172 } | 170 } |
173 | 171 |
174 void ApiTestEnvironment::InitializeEnvironment() { | 172 void ApiTestEnvironment::InitializeEnvironment() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 test_env_.reset(new ApiTestEnvironment(env())); | 231 test_env_.reset(new ApiTestEnvironment(env())); |
234 } | 232 } |
235 | 233 |
236 void ApiTestBase::RunTest(const std::string& file_name, | 234 void ApiTestBase::RunTest(const std::string& file_name, |
237 const std::string& test_name) { | 235 const std::string& test_name) { |
238 ExpectNoAssertionsMade(); | 236 ExpectNoAssertionsMade(); |
239 test_env_->RunTest(file_name, test_name); | 237 test_env_->RunTest(file_name, test_name); |
240 } | 238 } |
241 | 239 |
242 } // namespace extensions | 240 } // namespace extensions |
OLD | NEW |