| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file contains the definition for LayoutTestController. | 5 // This file contains the definition for LayoutTestController. |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "webkit/tools/test_shell/layout_test_controller.h" | 9 #include "webkit/tools/test_shell/layout_test_controller.h" |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "webkit/api/public/WebConsoleMessage.h" | 17 #include "webkit/api/public/WebConsoleMessage.h" |
| 18 #include "webkit/api/public/WebFrame.h" | 18 #include "webkit/api/public/WebFrame.h" |
| 19 #include "webkit/api/public/WebKit.h" | 19 #include "webkit/api/public/WebKit.h" |
| 20 #include "webkit/api/public/WebScriptSource.h" | 20 #include "webkit/api/public/WebScriptSource.h" |
| 21 #include "webkit/api/public/WebURL.h" | 21 #include "webkit/api/public/WebURL.h" |
| 22 #include "webkit/glue/dom_operations.h" | 22 #include "webkit/glue/dom_operations.h" |
| 23 #include "webkit/glue/webpreferences.h" | 23 #include "webkit/glue/webpreferences.h" |
| 24 #include "webkit/glue/webview.h" | 24 #include "webkit/glue/webview.h" |
| 25 #include "webkit/tools/test_shell/simple_database_system.h" |
| 25 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 26 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 26 #include "webkit/tools/test_shell/test_navigation_controller.h" | 27 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 27 #include "webkit/tools/test_shell/test_shell.h" | 28 #include "webkit/tools/test_shell/test_shell.h" |
| 28 | 29 |
| 29 using std::string; | 30 using std::string; |
| 30 using std::wstring; | 31 using std::wstring; |
| 31 | 32 |
| 32 using WebKit::WebConsoleMessage; | 33 using WebKit::WebConsoleMessage; |
| 33 using WebKit::WebScriptSource; | 34 using WebKit::WebScriptSource; |
| 34 using WebKit::WebString; | 35 using WebKit::WebString; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 BindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pause
AnimationAtTimeOnElementWithId); | 119 BindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pause
AnimationAtTimeOnElementWithId); |
| 119 BindMethod("pauseTransitionAtTimeOnElementWithId", &LayoutTestController::paus
eTransitionAtTimeOnElementWithId); | 120 BindMethod("pauseTransitionAtTimeOnElementWithId", &LayoutTestController::paus
eTransitionAtTimeOnElementWithId); |
| 120 BindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::e
lementDoesAutoCompleteForElementWithId); | 121 BindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::e
lementDoesAutoCompleteForElementWithId); |
| 121 BindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAn
imations); | 122 BindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAn
imations); |
| 122 BindMethod("disableImageLoading", &LayoutTestController::disableImageLoading); | 123 BindMethod("disableImageLoading", &LayoutTestController::disableImageLoading); |
| 123 BindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEna
bled); | 124 BindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEna
bled); |
| 124 BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDe
legate); | 125 BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDe
legate); |
| 125 BindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelega
te); | 126 BindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelega
te); |
| 126 BindMethod("setWillSendRequestReturnsNullOnRedirect", &LayoutTestController::s
etWillSendRequestReturnsNullOnRedirect); | 127 BindMethod("setWillSendRequestReturnsNullOnRedirect", &LayoutTestController::s
etWillSendRequestReturnsNullOnRedirect); |
| 127 BindMethod("whiteListAccessFromOrigin", &LayoutTestController::whiteListAccess
FromOrigin); | 128 BindMethod("whiteListAccessFromOrigin", &LayoutTestController::whiteListAccess
FromOrigin); |
| 129 BindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases); |
| 128 | 130 |
| 129 // The following are stubs. | 131 // The following are stubs. |
| 130 BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); | 132 BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); |
| 131 BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrame
IsFirstResponder); | 133 BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrame
IsFirstResponder); |
| 132 BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); | 134 BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); |
| 133 BindMethod("display", &LayoutTestController::display); | 135 BindMethod("display", &LayoutTestController::display); |
| 134 BindMethod("testRepaint", &LayoutTestController::testRepaint); | 136 BindMethod("testRepaint", &LayoutTestController::testRepaint); |
| 135 BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHori
zontally); | 137 BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHori
zontally); |
| 136 BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList
); | 138 BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList
); |
| 137 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); | 139 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo
ntroller"); | 941 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo
ntroller"); |
| 940 if (!shell_->layout_test_mode()) { | 942 if (!shell_->layout_test_mode()) { |
| 941 logging::LogMessage("CONSOLE:", 0).stream() << message; | 943 logging::LogMessage("CONSOLE:", 0).stream() << message; |
| 942 } else { | 944 } else { |
| 943 printf("CONSOLE MESSAGE: %S\n", message.c_str()); | 945 printf("CONSOLE MESSAGE: %S\n", message.c_str()); |
| 944 } | 946 } |
| 945 result->SetNull(); | 947 result->SetNull(); |
| 946 } | 948 } |
| 947 | 949 |
| 948 void LayoutTestController::whiteListAccessFromOrigin( | 950 void LayoutTestController::whiteListAccessFromOrigin( |
| 949 const CppArgumentList& args, CppVariant* result) | 951 const CppArgumentList& args, CppVariant* result) { |
| 950 { | |
| 951 result->SetNull(); | 952 result->SetNull(); |
| 952 | 953 |
| 953 if (args.size() != 4 || !args[0].isString() || !args[1].isString() || | 954 if (args.size() != 4 || !args[0].isString() || !args[1].isString() || |
| 954 !args[2].isString() || !args[3].isBool()) | 955 !args[2].isString() || !args[3].isBool()) |
| 955 return; | 956 return; |
| 956 | 957 |
| 957 WebKit::WebURL url(GURL(args[0].ToString())); | 958 WebKit::WebURL url(GURL(args[0].ToString())); |
| 958 if (!url.isValid()) | 959 if (!url.isValid()) |
| 959 return; | 960 return; |
| 960 | 961 |
| 961 WebKit::whiteListAccessFromOrigin(url, | 962 WebKit::whiteListAccessFromOrigin(url, |
| 962 WebString::fromUTF8(args[1].ToString()), | 963 WebString::fromUTF8(args[1].ToString()), |
| 963 WebString::fromUTF8(args[2].ToString()), | 964 WebString::fromUTF8(args[2].ToString()), |
| 964 args[3].ToBoolean()); | 965 args[3].ToBoolean()); |
| 965 } | 966 } |
| 966 | 967 |
| 968 void LayoutTestController::clearAllDatabases( |
| 969 const CppArgumentList& args, CppVariant* result) { |
| 970 result->SetNull(); |
| 971 SimpleDatabaseSystem::GetInstance()->ClearAllDatabases(); |
| 972 } |
| 973 |
| 967 void LayoutTestController::LogErrorToConsole(const std::string& text) { | 974 void LayoutTestController::LogErrorToConsole(const std::string& text) { |
| 968 shell_->delegate()->didAddMessageToConsole( | 975 shell_->delegate()->didAddMessageToConsole( |
| 969 WebConsoleMessage(WebConsoleMessage::LevelError, | 976 WebConsoleMessage(WebConsoleMessage::LevelError, |
| 970 WebString::fromUTF8(text)), | 977 WebString::fromUTF8(text)), |
| 971 WebString(), 0); | 978 WebString(), 0); |
| 972 } | 979 } |
| OLD | NEW |