| 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/WebSecurityPolicy.h" |
| 21 #include "webkit/api/public/WebURL.h" | 22 #include "webkit/api/public/WebURL.h" |
| 22 #include "webkit/api/public/WebView.h" | 23 #include "webkit/api/public/WebView.h" |
| 23 #include "webkit/glue/dom_operations.h" | 24 #include "webkit/glue/dom_operations.h" |
| 24 #include "webkit/glue/webpreferences.h" | 25 #include "webkit/glue/webpreferences.h" |
| 25 #include "webkit/tools/test_shell/simple_database_system.h" | 26 #include "webkit/tools/test_shell/simple_database_system.h" |
| 26 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 27 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 27 #include "webkit/tools/test_shell/test_navigation_controller.h" | 28 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 28 #include "webkit/tools/test_shell/test_shell.h" | 29 #include "webkit/tools/test_shell/test_shell.h" |
| 29 | 30 |
| 30 using std::string; | 31 using std::string; |
| 31 using std::wstring; | 32 using std::wstring; |
| 32 | 33 |
| 33 using WebKit::WebConsoleMessage; | 34 using WebKit::WebConsoleMessage; |
| 34 using WebKit::WebScriptSource; | 35 using WebKit::WebScriptSource; |
| 36 using WebKit::WebSecurityPolicy; |
| 35 using WebKit::WebString; | 37 using WebKit::WebString; |
| 36 | 38 |
| 37 TestShell* LayoutTestController::shell_ = NULL; | 39 TestShell* LayoutTestController::shell_ = NULL; |
| 38 // Most of these flags need to be cleared in Reset() so that they get turned | 40 // Most of these flags need to be cleared in Reset() so that they get turned |
| 39 // off between each test run. | 41 // off between each test run. |
| 40 bool LayoutTestController::dump_as_text_ = false; | 42 bool LayoutTestController::dump_as_text_ = false; |
| 41 bool LayoutTestController::dump_editing_callbacks_ = false; | 43 bool LayoutTestController::dump_editing_callbacks_ = false; |
| 42 bool LayoutTestController::dump_frame_load_callbacks_ = false; | 44 bool LayoutTestController::dump_frame_load_callbacks_ = false; |
| 43 bool LayoutTestController::dump_resource_load_callbacks_ = false; | 45 bool LayoutTestController::dump_resource_load_callbacks_ = false; |
| 44 bool LayoutTestController::dump_back_forward_list_ = false; | 46 bool LayoutTestController::dump_back_forward_list_ = false; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 dump_title_changes_ = false; | 434 dump_title_changes_ = false; |
| 433 accepts_editing_ = true; | 435 accepts_editing_ = true; |
| 434 wait_until_done_ = false; | 436 wait_until_done_ = false; |
| 435 can_open_windows_ = false; | 437 can_open_windows_ = false; |
| 436 should_add_file_to_pasteboard_ = false; | 438 should_add_file_to_pasteboard_ = false; |
| 437 stop_provisional_frame_loads_ = false; | 439 stop_provisional_frame_loads_ = false; |
| 438 globalFlag_.Set(false); | 440 globalFlag_.Set(false); |
| 439 webHistoryItemCount_.Set(0); | 441 webHistoryItemCount_.Set(0); |
| 440 | 442 |
| 441 SimpleResourceLoaderBridge::SetAcceptAllCookies(false); | 443 SimpleResourceLoaderBridge::SetAcceptAllCookies(false); |
| 442 WebKit::resetOriginAccessWhiteLists(); | 444 WebSecurityPolicy::resetOriginAccessWhiteLists(); |
| 443 | 445 |
| 444 setlocale(LC_ALL, ""); | 446 setlocale(LC_ALL, ""); |
| 445 | 447 |
| 446 if (close_remaining_windows_) { | 448 if (close_remaining_windows_) { |
| 447 // Iterate through the window list and close everything except the original | 449 // Iterate through the window list and close everything except the original |
| 448 // shell. We don't want to delete elements as we're iterating, so we copy | 450 // shell. We don't want to delete elements as we're iterating, so we copy |
| 449 // to a temp vector first. | 451 // to a temp vector first. |
| 450 WindowList* windows = TestShell::windowList(); | 452 WindowList* windows = TestShell::windowList(); |
| 451 std::vector<gfx::NativeWindow> windows_to_delete; | 453 std::vector<gfx::NativeWindow> windows_to_delete; |
| 452 for (WindowList::iterator i = windows->begin(); i != windows->end(); ++i) { | 454 for (WindowList::iterator i = windows->begin(); i != windows->end(); ++i) { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 result->SetNull(); | 964 result->SetNull(); |
| 963 | 965 |
| 964 if (args.size() != 4 || !args[0].isString() || !args[1].isString() || | 966 if (args.size() != 4 || !args[0].isString() || !args[1].isString() || |
| 965 !args[2].isString() || !args[3].isBool()) | 967 !args[2].isString() || !args[3].isBool()) |
| 966 return; | 968 return; |
| 967 | 969 |
| 968 WebKit::WebURL url(GURL(args[0].ToString())); | 970 WebKit::WebURL url(GURL(args[0].ToString())); |
| 969 if (!url.isValid()) | 971 if (!url.isValid()) |
| 970 return; | 972 return; |
| 971 | 973 |
| 972 WebKit::whiteListAccessFromOrigin(url, | 974 WebSecurityPolicy::whiteListAccessFromOrigin(url, |
| 973 WebString::fromUTF8(args[1].ToString()), | 975 WebString::fromUTF8(args[1].ToString()), |
| 974 WebString::fromUTF8(args[2].ToString()), | 976 WebString::fromUTF8(args[2].ToString()), |
| 975 args[3].ToBoolean()); | 977 args[3].ToBoolean()); |
| 976 } | 978 } |
| 977 | 979 |
| 978 void LayoutTestController::clearAllDatabases( | 980 void LayoutTestController::clearAllDatabases( |
| 979 const CppArgumentList& args, CppVariant* result) { | 981 const CppArgumentList& args, CppVariant* result) { |
| 980 result->SetNull(); | 982 result->SetNull(); |
| 981 SimpleDatabaseSystem::GetInstance()->ClearAllDatabases(); | 983 SimpleDatabaseSystem::GetInstance()->ClearAllDatabases(); |
| 982 } | 984 } |
| 983 | 985 |
| 984 void LayoutTestController::setPOSIXLocale(const CppArgumentList& args, | 986 void LayoutTestController::setPOSIXLocale(const CppArgumentList& args, |
| 985 CppVariant* result) { | 987 CppVariant* result) { |
| 986 result->SetNull(); | 988 result->SetNull(); |
| 987 if (args.size() == 1 && args[0].isString()) { | 989 if (args.size() == 1 && args[0].isString()) { |
| 988 std::string new_locale = args[0].ToString(); | 990 std::string new_locale = args[0].ToString(); |
| 989 setlocale(LC_ALL, new_locale.c_str()); | 991 setlocale(LC_ALL, new_locale.c_str()); |
| 990 } | 992 } |
| 991 } | 993 } |
| 992 | 994 |
| 993 void LayoutTestController::LogErrorToConsole(const std::string& text) { | 995 void LayoutTestController::LogErrorToConsole(const std::string& text) { |
| 994 shell_->delegate()->didAddMessageToConsole( | 996 shell_->delegate()->didAddMessageToConsole( |
| 995 WebConsoleMessage(WebConsoleMessage::LevelError, | 997 WebConsoleMessage(WebConsoleMessage::LevelError, |
| 996 WebString::fromUTF8(text)), | 998 WebString::fromUTF8(text)), |
| 997 WebString(), 0); | 999 WebString(), 0); |
| 998 } | 1000 } |
| OLD | NEW |