Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: webkit/tools/test_shell/layout_test_controller.cc

Issue 192004: Change the default cookie policy to be closer to the default in WebKit's Dump... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/WebFrame.h" 17 #include "webkit/api/public/WebFrame.h"
18 #include "webkit/api/public/WebKit.h" 18 #include "webkit/api/public/WebKit.h"
19 #include "webkit/api/public/WebScriptSource.h" 19 #include "webkit/api/public/WebScriptSource.h"
20 #include "webkit/api/public/WebURL.h" 20 #include "webkit/api/public/WebURL.h"
21 #include "webkit/glue/dom_operations.h" 21 #include "webkit/glue/dom_operations.h"
22 #include "webkit/glue/webpreferences.h" 22 #include "webkit/glue/webpreferences.h"
23 #include "webkit/glue/webview.h" 23 #include "webkit/glue/webview.h"
24 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
24 #include "webkit/tools/test_shell/test_navigation_controller.h" 25 #include "webkit/tools/test_shell/test_navigation_controller.h"
25 #include "webkit/tools/test_shell/test_shell.h" 26 #include "webkit/tools/test_shell/test_shell.h"
26 27
27 using std::string; 28 using std::string;
28 using std::wstring; 29 using std::wstring;
29 30
30 using WebKit::WebScriptSource; 31 using WebKit::WebScriptSource;
31 using WebKit::WebString; 32 using WebKit::WebString;
32 33
33 #if defined(OS_WIN) 34 #if defined(OS_WIN)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 BindMethod("queueReload", &LayoutTestController::queueReload); 93 BindMethod("queueReload", &LayoutTestController::queueReload);
93 BindMethod("queueLoadingScript", &LayoutTestController::queueLoadingScript); 94 BindMethod("queueLoadingScript", &LayoutTestController::queueLoadingScript);
94 BindMethod("queueNonLoadingScript", &LayoutTestController::queueNonLoadingScri pt); 95 BindMethod("queueNonLoadingScript", &LayoutTestController::queueNonLoadingScri pt);
95 BindMethod("queueLoad", &LayoutTestController::queueLoad); 96 BindMethod("queueLoad", &LayoutTestController::queueLoad);
96 BindMethod("queueBackNavigation", &LayoutTestController::queueBackNavigation); 97 BindMethod("queueBackNavigation", &LayoutTestController::queueBackNavigation);
97 BindMethod("queueForwardNavigation", &LayoutTestController::queueForwardNaviga tion); 98 BindMethod("queueForwardNavigation", &LayoutTestController::queueForwardNaviga tion);
98 BindMethod("windowCount", &LayoutTestController::windowCount); 99 BindMethod("windowCount", &LayoutTestController::windowCount);
99 BindMethod("setCanOpenWindows", &LayoutTestController::setCanOpenWindows); 100 BindMethod("setCanOpenWindows", &LayoutTestController::setCanOpenWindows);
100 BindMethod("setCloseRemainingWindowsWhenComplete", &LayoutTestController::setC loseRemainingWindowsWhenComplete); 101 BindMethod("setCloseRemainingWindowsWhenComplete", &LayoutTestController::setC loseRemainingWindowsWhenComplete);
101 BindMethod("objCIdentityIsEqual", &LayoutTestController::objCIdentityIsEqual); 102 BindMethod("objCIdentityIsEqual", &LayoutTestController::objCIdentityIsEqual);
103 BindMethod("setAlwaysAcceptCookies", &LayoutTestController::setAlwaysAcceptCoo kies);
102 BindMethod("setWindowIsKey", &LayoutTestController::setWindowIsKey); 104 BindMethod("setWindowIsKey", &LayoutTestController::setWindowIsKey);
103 BindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyC yclesThroughElements); 105 BindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyC yclesThroughElements);
104 BindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleShe etLocation); 106 BindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleShe etLocation);
105 BindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleShee tEnabled); 107 BindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleShee tEnabled);
106 BindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource); 108 BindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource);
107 BindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteb oardOnDrag); 109 BindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteb oardOnDrag);
108 BindMethod("execCommand", &LayoutTestController::execCommand); 110 BindMethod("execCommand", &LayoutTestController::execCommand);
109 BindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled); 111 BindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled);
110 BindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingE nabled); 112 BindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingE nabled);
111 BindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvi sionalFrameLoads); 113 BindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvi sionalFrameLoads);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 dump_window_status_changes_ = false; 423 dump_window_status_changes_ = false;
422 dump_title_changes_ = false; 424 dump_title_changes_ = false;
423 accepts_editing_ = true; 425 accepts_editing_ = true;
424 wait_until_done_ = false; 426 wait_until_done_ = false;
425 can_open_windows_ = false; 427 can_open_windows_ = false;
426 should_add_file_to_pasteboard_ = false; 428 should_add_file_to_pasteboard_ = false;
427 stop_provisional_frame_loads_ = false; 429 stop_provisional_frame_loads_ = false;
428 globalFlag_.Set(false); 430 globalFlag_.Set(false);
429 webHistoryItemCount_.Set(0); 431 webHistoryItemCount_.Set(0);
430 432
433 SimpleResourceLoaderBridge::SetAcceptAllCookies(false);
431 WebKit::resetOriginAccessWhiteLists(); 434 WebKit::resetOriginAccessWhiteLists();
432 435
433 if (close_remaining_windows_) { 436 if (close_remaining_windows_) {
434 // Iterate through the window list and close everything except the original 437 // Iterate through the window list and close everything except the original
435 // shell. We don't want to delete elements as we're iterating, so we copy 438 // shell. We don't want to delete elements as we're iterating, so we copy
436 // to a temp vector first. 439 // to a temp vector first.
437 WindowList* windows = TestShell::windowList(); 440 WindowList* windows = TestShell::windowList();
438 std::vector<gfx::NativeWindow> windows_to_delete; 441 std::vector<gfx::NativeWindow> windows_to_delete;
439 for (WindowList::iterator i = windows->begin(); i != windows->end(); ++i) { 442 for (WindowList::iterator i = windows->begin(); i != windows->end(); ++i) {
440 if (*i != shell_->mainWnd()) 443 if (*i != shell_->mainWnd())
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 495 }
493 496
494 void LayoutTestController::setCloseRemainingWindowsWhenComplete( 497 void LayoutTestController::setCloseRemainingWindowsWhenComplete(
495 const CppArgumentList& args, CppVariant* result) { 498 const CppArgumentList& args, CppVariant* result) {
496 if (args.size() > 0 && args[0].isBool()) { 499 if (args.size() > 0 && args[0].isBool()) {
497 close_remaining_windows_ = args[0].value.boolValue; 500 close_remaining_windows_ = args[0].value.boolValue;
498 } 501 }
499 result->SetNull(); 502 result->SetNull();
500 } 503 }
501 504
505 void LayoutTestController::setAlwaysAcceptCookies(
506 const CppArgumentList& args, CppVariant* result) {
507 if (args.size() > 0) {
508 SimpleResourceLoaderBridge::SetAcceptAllCookies(CppVariantToBool(args[0]));
509 }
510 result->SetNull();
511 }
512
502 void LayoutTestController::setWindowIsKey( 513 void LayoutTestController::setWindowIsKey(
503 const CppArgumentList& args, CppVariant* result) { 514 const CppArgumentList& args, CppVariant* result) {
504 if (args.size() > 0 && args[0].isBool()) { 515 if (args.size() > 0 && args[0].isBool()) {
505 shell_->SetFocus(shell_->webViewHost(), args[0].value.boolValue); 516 shell_->SetFocus(shell_->webViewHost(), args[0].value.boolValue);
506 } 517 }
507 result->SetNull(); 518 result->SetNull();
508 } 519 }
509 520
510 void LayoutTestController::setUserStyleSheetEnabled( 521 void LayoutTestController::setUserStyleSheetEnabled(
511 const CppArgumentList& args, CppVariant* result) { 522 const CppArgumentList& args, CppVariant* result) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 816
806 void LayoutTestController::evaluateScriptInIsolatedWorld( 817 void LayoutTestController::evaluateScriptInIsolatedWorld(
807 const CppArgumentList& args, CppVariant* result) { 818 const CppArgumentList& args, CppVariant* result) {
808 if (args.size() > 0 && args[0].isString()) { 819 if (args.size() > 0 && args[0].isString()) {
809 WebScriptSource source(WebString::fromUTF8(args[0].ToString())); 820 WebScriptSource source(WebString::fromUTF8(args[0].ToString()));
810 shell_->webView()->GetMainFrame()->executeScriptInNewWorld(&source, 1, 1); 821 shell_->webView()->GetMainFrame()->executeScriptInNewWorld(&source, 1, 1);
811 } 822 }
812 result->SetNull(); 823 result->SetNull();
813 } 824 }
814 825
815 // Need these conversions because the format of the value for overridePreference 826 // Need these conversions because the format of the value for booleans
816 // may vary - for example, on mac "1" and "0" are used for boolean. 827 // may vary - for example, on mac "1" and "0" are used for boolean.
817 bool LayoutTestController::CppVariantToBool(const CppVariant& value) { 828 bool LayoutTestController::CppVariantToBool(const CppVariant& value) {
818 if (value.isBool()) 829 if (value.isBool())
819 return value.ToBoolean(); 830 return value.ToBoolean();
820 else if (value.isInt32()) 831 else if (value.isInt32())
821 return 0 != value.ToInt32(); 832 return 0 != value.ToInt32();
822 else if (value.isString()) { 833 else if (value.isString()) {
823 std::string valueString = value.ToString(); 834 std::string valueString = value.ToString();
824 if (valueString == "true") 835 if (valueString == "true")
825 return true; 836 return true;
826 if (valueString == "false") 837 if (valueString == "false")
827 return false; 838 return false;
828 } 839 }
829 shell_->delegate()->AddMessageToConsole(shell_->webView(), 840 shell_->delegate()->AddMessageToConsole(shell_->webView(),
830 L"Invalid value for preference. Expected boolean value.", 0, L""); 841 L"Invalid value. Expected boolean value.", 0, L"");
831 return false; 842 return false;
832 } 843 }
833 844
834 int32 LayoutTestController::CppVariantToInt32(const CppVariant& value) { 845 int32 LayoutTestController::CppVariantToInt32(const CppVariant& value) {
835 if (value.isInt32()) 846 if (value.isInt32())
836 return value.ToInt32(); 847 return value.ToInt32();
837 else if (value.isString()) { 848 else if (value.isString()) {
838 int number; 849 int number;
839 if (StringToInt(value.ToString(), &number)) 850 if (StringToInt(value.ToString(), &number))
840 return number; 851 return number;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 952
942 WebKit::WebURL url(GURL(args[0].ToString())); 953 WebKit::WebURL url(GURL(args[0].ToString()));
943 if (!url.isValid()) 954 if (!url.isValid())
944 return; 955 return;
945 956
946 WebKit::whiteListAccessFromOrigin(url, 957 WebKit::whiteListAccessFromOrigin(url,
947 WebString::fromUTF8(args[1].ToString()), 958 WebString::fromUTF8(args[1].ToString()),
948 WebString::fromUTF8(args[2].ToString()), 959 WebString::fromUTF8(args[2].ToString()),
949 args[3].ToBoolean()); 960 args[3].ToBoolean());
950 } 961 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/layout_test_controller.h ('k') | webkit/tools/test_shell/simple_resource_loader_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698