| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "third_party/WebKit/public/web/WebSettings.h" | 40 #include "third_party/WebKit/public/web/WebSettings.h" |
| 41 #include "third_party/WebKit/public/web/WebSurroundingText.h" | 41 #include "third_party/WebKit/public/web/WebSurroundingText.h" |
| 42 #include "third_party/WebKit/public/web/WebView.h" | 42 #include "third_party/WebKit/public/web/WebView.h" |
| 43 #include "third_party/skia/include/core/SkCanvas.h" | 43 #include "third_party/skia/include/core/SkCanvas.h" |
| 44 | 44 |
| 45 #if defined(__linux__) || defined(ANDROID) | 45 #if defined(__linux__) || defined(ANDROID) |
| 46 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" | 46 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 using namespace blink; | 49 using namespace blink; |
| 50 using namespace WebTestRunner; | 50 |
| 51 namespace content { |
| 51 | 52 |
| 52 namespace { | 53 namespace { |
| 53 | 54 |
| 54 WebString V8StringToWebString(v8::Handle<v8::String> v8_str) { | 55 WebString V8StringToWebString(v8::Handle<v8::String> v8_str) { |
| 55 int length = v8_str->Utf8Length() + 1; | 56 int length = v8_str->Utf8Length() + 1; |
| 56 scoped_ptr<char[]> chars(new char[length]); | 57 scoped_ptr<char[]> chars(new char[length]); |
| 57 v8_str->WriteUtf8(chars.get(), length); | 58 v8_str->WriteUtf8(chars.get(), length); |
| 58 return WebString::fromUTF8(chars.get()); | 59 return WebString::fromUTF8(chars.get()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 class HostMethodTask : | 62 class HostMethodTask : public WebMethodTask<TestRunner> { |
| 62 public ::WebTestRunner::WebMethodTask<content::TestRunner> { | |
| 63 public: | 63 public: |
| 64 typedef void (content::TestRunner::*CallbackMethodType)(); | 64 typedef void (TestRunner::*CallbackMethodType)(); |
| 65 HostMethodTask(content::TestRunner* object, CallbackMethodType callback) | 65 HostMethodTask(TestRunner* object, CallbackMethodType callback) |
| 66 : WebMethodTask<content::TestRunner>(object), callback_(callback) {} | 66 : WebMethodTask<TestRunner>(object), callback_(callback) {} |
| 67 | 67 |
| 68 virtual void runIfValid() OVERRIDE { | 68 virtual void runIfValid() OVERRIDE { |
| 69 (m_object->*callback_)(); | 69 (m_object->*callback_)(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 CallbackMethodType callback_; | 73 CallbackMethodType callback_; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace | 76 } // namespace |
| 77 | 77 |
| 78 namespace content { | 78 class InvokeCallbackTask : public WebMethodTask<TestRunner> { |
| 79 | |
| 80 class InvokeCallbackTask : public WebMethodTask<content::TestRunner> { | |
| 81 public: | 79 public: |
| 82 InvokeCallbackTask(content::TestRunner* object, | 80 InvokeCallbackTask(TestRunner* object, v8::Handle<v8::Function> callback) |
| 83 v8::Handle<v8::Function> callback) | 81 : WebMethodTask<TestRunner>(object), |
| 84 : WebMethodTask<content::TestRunner>(object), | |
| 85 callback_(blink::mainThreadIsolate(), callback) {} | 82 callback_(blink::mainThreadIsolate(), callback) {} |
| 86 | 83 |
| 87 virtual void runIfValid() OVERRIDE { | 84 virtual void runIfValid() OVERRIDE { |
| 88 v8::Isolate* isolate = blink::mainThreadIsolate(); | 85 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 89 v8::HandleScope handle_scope(isolate); | 86 v8::HandleScope handle_scope(isolate); |
| 90 WebFrame* frame = m_object->web_view_->mainFrame(); | 87 WebFrame* frame = m_object->web_view_->mainFrame(); |
| 91 | 88 |
| 92 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 89 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
| 93 if (context.IsEmpty()) | 90 if (context.IsEmpty()) |
| 94 return; | 91 return; |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 close_remaining_windows_(false), | 1343 close_remaining_windows_(false), |
| 1347 work_queue_(this), | 1344 work_queue_(this), |
| 1348 disable_notify_done_(false), | 1345 disable_notify_done_(false), |
| 1349 web_history_item_count_(0), | 1346 web_history_item_count_(0), |
| 1350 intercept_post_message_(false), | 1347 intercept_post_message_(false), |
| 1351 test_interfaces_(interfaces), | 1348 test_interfaces_(interfaces), |
| 1352 delegate_(NULL), | 1349 delegate_(NULL), |
| 1353 web_view_(NULL), | 1350 web_view_(NULL), |
| 1354 page_overlay_(NULL), | 1351 page_overlay_(NULL), |
| 1355 web_permissions_(new WebPermissions()), | 1352 web_permissions_(new WebPermissions()), |
| 1356 notification_presenter_(new content::NotificationPresenter()), | 1353 notification_presenter_(new NotificationPresenter()), |
| 1357 weak_factory_(this) {} | 1354 weak_factory_(this) {} |
| 1358 | 1355 |
| 1359 TestRunner::~TestRunner() {} | 1356 TestRunner::~TestRunner() {} |
| 1360 | 1357 |
| 1361 void TestRunner::Install(WebFrame* frame) { | 1358 void TestRunner::Install(WebFrame* frame) { |
| 1362 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1359 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
| 1363 } | 1360 } |
| 1364 | 1361 |
| 1365 void TestRunner::SetDelegate(WebTestDelegate* delegate) { | 1362 void TestRunner::SetDelegate(WebTestDelegate* delegate) { |
| 1366 delegate_ = delegate; | 1363 delegate_ = delegate; |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 } | 2589 } |
| 2593 | 2590 |
| 2594 void TestRunner::DidLosePointerLockInternal() { | 2591 void TestRunner::DidLosePointerLockInternal() { |
| 2595 bool was_locked = pointer_locked_; | 2592 bool was_locked = pointer_locked_; |
| 2596 pointer_locked_ = false; | 2593 pointer_locked_ = false; |
| 2597 if (was_locked) | 2594 if (was_locked) |
| 2598 web_view_->didLosePointerLock(); | 2595 web_view_->didLosePointerLock(); |
| 2599 } | 2596 } |
| 2600 | 2597 |
| 2601 } // namespace content | 2598 } // namespace content |
| OLD | NEW |