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/location.h" | 10 #include "base/location.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "extensions/common/extension_urls.h" | 15 #include "extensions/common/extension_urls.h" |
16 #include "extensions/renderer/dispatcher.h" | 16 #include "extensions/renderer/dispatcher.h" |
17 #include "extensions/renderer/process_info_native_handler.h" | 17 #include "extensions/renderer/process_info_native_handler.h" |
18 #include "gin/converter.h" | 18 #include "gin/converter.h" |
19 #include "gin/dictionary.h" | 19 #include "gin/dictionary.h" |
20 #include "gin/modules/console.h" | 20 #include "gin/modules/console.h" |
21 #include "mojo/edk/js/core.h" | 21 #include "third_party/WebKit/public/web/WebMojoBindings.h" |
22 #include "mojo/edk/js/handle.h" | 22 |
23 #include "mojo/edk/js/support.h" | 23 namespace gin { |
24 #include "mojo/public/cpp/bindings/interface_request.h" | 24 template <> |
25 #include "mojo/public/cpp/system/core.h" | 25 struct Converter<mojo::Handle> { |
| 26 static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, mojo::Handle val) { |
| 27 return blink::WebMojoBindings::wrap(isolate->GetCurrentContext(), |
| 28 mojo::MakeScopedHandle(val)); |
| 29 } |
| 30 }; |
| 31 } // namespace gin |
26 | 32 |
27 namespace extensions { | 33 namespace extensions { |
28 namespace { | 34 namespace { |
29 | 35 |
30 // Natives for the implementation of the unit test version of chrome.test. Calls | 36 // Natives for the implementation of the unit test version of chrome.test. Calls |
31 // the provided |quit_closure| when either notifyPass or notifyFail is called. | 37 // the provided |quit_closure| when either notifyPass or notifyFail is called. |
32 class TestNatives : public gin::Wrappable<TestNatives> { | 38 class TestNatives : public gin::Wrappable<TestNatives> { |
33 public: | 39 public: |
34 static gin::Handle<TestNatives> Create(v8::Isolate* isolate, | 40 static gin::Handle<TestNatives> Create(v8::Isolate* isolate, |
35 const base::Closure& quit_closure) { | 41 const base::Closure& quit_closure) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 "event_natives", | 155 "event_natives", |
150 "exports.$set('AttachEvent', function() {});" | 156 "exports.$set('AttachEvent', function() {});" |
151 "exports.$set('DetachEvent', function() {});" | 157 "exports.$set('DetachEvent', function() {});" |
152 "exports.$set('AttachFilteredEvent', function() {});" | 158 "exports.$set('AttachFilteredEvent', function() {});" |
153 "exports.$set('AttachFilteredEvent', function() {});" | 159 "exports.$set('AttachFilteredEvent', function() {});" |
154 "exports.$set('MatchAgainstEventFilter', function() { return [] });"); | 160 "exports.$set('MatchAgainstEventFilter', function() { return [] });"); |
155 | 161 |
156 gin::ModuleRegistry::From(env()->context()->v8_context()) | 162 gin::ModuleRegistry::From(env()->context()->v8_context()) |
157 ->AddBuiltinModule(env()->isolate(), gin::Console::kModuleName, | 163 ->AddBuiltinModule(env()->isolate(), gin::Console::kModuleName, |
158 gin::Console::GetModule(env()->isolate())); | 164 gin::Console::GetModule(env()->isolate())); |
159 gin::ModuleRegistry::From(env()->context()->v8_context()) | |
160 ->AddBuiltinModule(env()->isolate(), mojo::edk::js::Core::kModuleName, | |
161 mojo::edk::js::Core::GetModule(env()->isolate())); | |
162 gin::ModuleRegistry::From(env()->context()->v8_context()) | |
163 ->AddBuiltinModule(env()->isolate(), mojo::edk::js::Support::kModuleName, | |
164 mojo::edk::js::Support::GetModule(env()->isolate())); | |
165 gin::Handle<TestInterfaceProvider> interface_provider = | 165 gin::Handle<TestInterfaceProvider> interface_provider = |
166 TestInterfaceProvider::Create(env()->isolate()); | 166 TestInterfaceProvider::Create(env()->isolate()); |
167 interface_provider_ = interface_provider.get(); | 167 interface_provider_ = interface_provider.get(); |
168 gin::ModuleRegistry::From(env()->context()->v8_context()) | 168 gin::ModuleRegistry::From(env()->context()->v8_context()) |
169 ->AddBuiltinModule(env()->isolate(), | 169 ->AddBuiltinModule(env()->isolate(), |
170 "content/public/renderer/frame_interfaces", | 170 "content/public/renderer/frame_interfaces", |
171 interface_provider.ToV8()); | 171 interface_provider.ToV8()); |
172 } | 172 } |
173 | 173 |
174 void ApiTestEnvironment::InitializeEnvironment() { | 174 void ApiTestEnvironment::InitializeEnvironment() { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 test_env_.reset(new ApiTestEnvironment(env())); | 242 test_env_.reset(new ApiTestEnvironment(env())); |
243 } | 243 } |
244 | 244 |
245 void ApiTestBase::RunTest(const std::string& file_name, | 245 void ApiTestBase::RunTest(const std::string& file_name, |
246 const std::string& test_name) { | 246 const std::string& test_name) { |
247 ExpectNoAssertionsMade(); | 247 ExpectNoAssertionsMade(); |
248 test_env_->RunTest(file_name, test_name); | 248 test_env_->RunTest(file_name, test_name); |
249 } | 249 } |
250 | 250 |
251 } // namespace extensions | 251 } // namespace extensions |
OLD | NEW |