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 "content/shell/renderer/test_runner/test_runner.h" | 5 #include "content/shell/renderer/test_runner/test_runner.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/shell/common/test_runner/test_preferences.h" | 10 #include "content/shell/common/test_runner/test_preferences.h" |
11 #include "content/shell/renderer/binding_helpers.h" | |
12 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" | 11 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" |
13 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" | 12 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" |
14 #include "content/shell/renderer/test_runner/test_interfaces.h" | 13 #include "content/shell/renderer/test_runner/test_interfaces.h" |
15 #include "content/shell/renderer/test_runner/web_content_settings.h" | 14 #include "content/shell/renderer/test_runner/web_content_settings.h" |
16 #include "content/shell/renderer/test_runner/web_test_delegate.h" | 15 #include "content/shell/renderer/test_runner/web_test_delegate.h" |
17 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 16 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
18 #include "gin/arguments.h" | 17 #include "gin/arguments.h" |
19 #include "gin/array_buffer.h" | 18 #include "gin/array_buffer.h" |
20 #include "gin/handle.h" | 19 #include "gin/handle.h" |
21 #include "gin/object_template_builder.h" | 20 #include "gin/object_template_builder.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 319 |
321 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); | 320 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); |
322 }; | 321 }; |
323 | 322 |
324 gin::WrapperInfo TestRunnerBindings::kWrapperInfo = { | 323 gin::WrapperInfo TestRunnerBindings::kWrapperInfo = { |
325 gin::kEmbedderNativeGin}; | 324 gin::kEmbedderNativeGin}; |
326 | 325 |
327 // static | 326 // static |
328 void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner, | 327 void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner, |
329 WebFrame* frame) { | 328 WebFrame* frame) { |
| 329 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 330 v8::HandleScope handle_scope(isolate); |
| 331 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 332 if (context.IsEmpty()) |
| 333 return; |
| 334 |
| 335 v8::Context::Scope context_scope(context); |
| 336 |
| 337 TestRunnerBindings* wrapped = new TestRunnerBindings(runner); |
| 338 gin::Handle<TestRunnerBindings> bindings = |
| 339 gin::CreateHandle(isolate, wrapped); |
| 340 if (bindings.IsEmpty()) |
| 341 return; |
| 342 v8::Local<v8::Object> global = context->Global(); |
| 343 v8::Local<v8::Value> v8_bindings = bindings.ToV8(); |
| 344 |
330 std::vector<std::string> names; | 345 std::vector<std::string> names; |
331 names.push_back("testRunner"); | 346 names.push_back("testRunner"); |
332 names.push_back("layoutTestController"); | 347 names.push_back("layoutTestController"); |
333 return InstallAsWindowProperties( | 348 for (size_t i = 0; i < names.size(); ++i) |
334 new TestRunnerBindings(runner), frame, names); | 349 global->Set(gin::StringToV8(isolate, names[i].c_str()), v8_bindings); |
335 } | 350 } |
336 | 351 |
337 TestRunnerBindings::TestRunnerBindings(base::WeakPtr<TestRunner> runner) | 352 TestRunnerBindings::TestRunnerBindings(base::WeakPtr<TestRunner> runner) |
338 : runner_(runner) {} | 353 : runner_(runner) {} |
339 | 354 |
340 TestRunnerBindings::~TestRunnerBindings() {} | 355 TestRunnerBindings::~TestRunnerBindings() {} |
341 | 356 |
342 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( | 357 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( |
343 v8::Isolate* isolate) { | 358 v8::Isolate* isolate) { |
344 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate) | 359 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate) |
(...skipping 2646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2991 } | 3006 } |
2992 | 3007 |
2993 void TestRunner::DidLosePointerLockInternal() { | 3008 void TestRunner::DidLosePointerLockInternal() { |
2994 bool was_locked = pointer_locked_; | 3009 bool was_locked = pointer_locked_; |
2995 pointer_locked_ = false; | 3010 pointer_locked_ = false; |
2996 if (was_locked) | 3011 if (was_locked) |
2997 web_view_->didLosePointerLock(); | 3012 web_view_->didLosePointerLock(); |
2998 } | 3013 } |
2999 | 3014 |
3000 } // namespace content | 3015 } // namespace content |
OLD | NEW |