| 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" |
| 11 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 12 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 12 #include "content/shell/renderer/test_runner/mock_web_push_client.h" | 13 #include "content/shell/renderer/test_runner/mock_web_push_client.h" |
| 13 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" | 14 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" |
| 14 #include "content/shell/renderer/test_runner/notification_presenter.h" | 15 #include "content/shell/renderer/test_runner/notification_presenter.h" |
| 15 #include "content/shell/renderer/test_runner/test_interfaces.h" | 16 #include "content/shell/renderer/test_runner/test_interfaces.h" |
| 16 #include "content/shell/renderer/test_runner/web_permissions.h" | 17 #include "content/shell/renderer/test_runner/web_permissions.h" |
| 17 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 18 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
| 18 #include "gin/arguments.h" | 19 #include "gin/arguments.h" |
| 19 #include "gin/array_buffer.h" | 20 #include "gin/array_buffer.h" |
| 20 #include "gin/handle.h" | 21 #include "gin/handle.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 307 |
| 307 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); | 308 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); |
| 308 }; | 309 }; |
| 309 | 310 |
| 310 gin::WrapperInfo TestRunnerBindings::kWrapperInfo = { | 311 gin::WrapperInfo TestRunnerBindings::kWrapperInfo = { |
| 311 gin::kEmbedderNativeGin}; | 312 gin::kEmbedderNativeGin}; |
| 312 | 313 |
| 313 // static | 314 // static |
| 314 void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner, | 315 void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner, |
| 315 WebFrame* frame) { | 316 WebFrame* frame) { |
| 316 v8::Isolate* isolate = blink::mainThreadIsolate(); | 317 std::vector<std::string> names; |
| 317 v8::HandleScope handle_scope(isolate); | 318 names.push_back("testRunner"); |
| 318 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 319 names.push_back("layoutTestController"); |
| 319 if (context.IsEmpty()) | 320 return InstallAsWindowProperties( |
| 320 return; | 321 new TestRunnerBindings(runner), frame, names); |
| 321 | |
| 322 v8::Context::Scope context_scope(context); | |
| 323 | |
| 324 gin::Handle<TestRunnerBindings> bindings = | |
| 325 gin::CreateHandle(isolate, new TestRunnerBindings(runner)); | |
| 326 if (bindings.IsEmpty()) | |
| 327 return; | |
| 328 v8::Handle<v8::Object> global = context->Global(); | |
| 329 v8::Handle<v8::Value> v8_bindings = bindings.ToV8(); | |
| 330 global->Set(gin::StringToV8(isolate, "testRunner"), v8_bindings); | |
| 331 global->Set(gin::StringToV8(isolate, "layoutTestController"), v8_bindings); | |
| 332 } | 322 } |
| 333 | 323 |
| 334 TestRunnerBindings::TestRunnerBindings(base::WeakPtr<TestRunner> runner) | 324 TestRunnerBindings::TestRunnerBindings(base::WeakPtr<TestRunner> runner) |
| 335 : runner_(runner) {} | 325 : runner_(runner) {} |
| 336 | 326 |
| 337 TestRunnerBindings::~TestRunnerBindings() {} | 327 TestRunnerBindings::~TestRunnerBindings() {} |
| 338 | 328 |
| 339 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( | 329 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( |
| 340 v8::Isolate* isolate) { | 330 v8::Isolate* isolate) { |
| 341 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate) | 331 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate) |
| (...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2923 } | 2913 } |
| 2924 | 2914 |
| 2925 void TestRunner::DidLosePointerLockInternal() { | 2915 void TestRunner::DidLosePointerLockInternal() { |
| 2926 bool was_locked = pointer_locked_; | 2916 bool was_locked = pointer_locked_; |
| 2927 pointer_locked_ = false; | 2917 pointer_locked_ = false; |
| 2928 if (was_locked) | 2918 if (was_locked) |
| 2929 web_view_->didLosePointerLock(); | 2919 web_view_->didLosePointerLock(); |
| 2930 } | 2920 } |
| 2931 | 2921 |
| 2932 } // namespace content | 2922 } // namespace content |
| OLD | NEW |