OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); | 145 BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); |
146 BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); | 146 BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); |
147 BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebV
iews); | 147 BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebV
iews); |
148 BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrows
ingEnabled); | 148 BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrows
ingEnabled); |
149 BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDa
shboardCompatibilityMode); | 149 BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDa
shboardCompatibilityMode); |
150 | 150 |
151 BindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled
); | 151 BindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled
); |
152 BindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScr
iptInIsolatedWorld); | 152 BindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScr
iptInIsolatedWorld); |
153 BindMethod("overridePreference", &LayoutTestController::overridePreference); | 153 BindMethod("overridePreference", &LayoutTestController::overridePreference); |
154 BindMethod("setAllowUniversalAccessFromFileURLs", &LayoutTestController::setAl
lowUniversalAccessFromFileURLs); | 154 BindMethod("setAllowUniversalAccessFromFileURLs", &LayoutTestController::setAl
lowUniversalAccessFromFileURLs); |
155 BindMethod("setAllowFileAccessFromFileURLs", &LayoutTestController::setAllowFi
leAccessFromFileURLs); | |
156 BindMethod("setTimelineProfilingEnabled", &LayoutTestController::setTimelinePr
ofilingEnabled); | 155 BindMethod("setTimelineProfilingEnabled", &LayoutTestController::setTimelinePr
ofilingEnabled); |
157 BindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspe
ctor); | 156 BindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspe
ctor); |
158 BindMethod("forceRedSelectionColors", &LayoutTestController::forceRedSelection
Colors); | 157 BindMethod("forceRedSelectionColors", &LayoutTestController::forceRedSelection
Colors); |
159 | 158 |
160 // The fallback method is called when an unknown method is invoked. | 159 // The fallback method is called when an unknown method is invoked. |
161 BindFallbackMethod(&LayoutTestController::fallbackMethod); | 160 BindFallbackMethod(&LayoutTestController::fallbackMethod); |
162 | 161 |
163 // Shared properties. | 162 // Shared properties. |
164 // globalFlag is used by a number of layout tests in | 163 // globalFlag is used by a number of layout tests in |
165 // LayoutTests\http\tests\security\dataURL. | 164 // LayoutTests\http\tests\security\dataURL. |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 void LayoutTestController::setAllowUniversalAccessFromFileURLs( | 892 void LayoutTestController::setAllowUniversalAccessFromFileURLs( |
894 const CppArgumentList& args, CppVariant* result) { | 893 const CppArgumentList& args, CppVariant* result) { |
895 if (args.size() > 0 && args[0].isBool()) { | 894 if (args.size() > 0 && args[0].isBool()) { |
896 WebPreferences* prefs = shell_->GetWebPreferences(); | 895 WebPreferences* prefs = shell_->GetWebPreferences(); |
897 prefs->allow_universal_access_from_file_urls = args[0].value.boolValue; | 896 prefs->allow_universal_access_from_file_urls = args[0].value.boolValue; |
898 prefs->Apply(shell_->webView()); | 897 prefs->Apply(shell_->webView()); |
899 } | 898 } |
900 result->SetNull(); | 899 result->SetNull(); |
901 } | 900 } |
902 | 901 |
903 void LayoutTestController::setAllowFileAccessFromFileURLs( | |
904 const CppArgumentList& args, CppVariant* result) { | |
905 if (args.size() > 0 && args[0].isBool()) { | |
906 WebPreferences* prefs = shell_->GetWebPreferences(); | |
907 prefs->allow_file_access_from_file_urls = args[0].value.boolValue; | |
908 prefs->Apply(shell_->webView()); | |
909 } | |
910 result->SetNull(); | |
911 } | |
912 | |
913 // Need these conversions because the format of the value for booleans | 902 // Need these conversions because the format of the value for booleans |
914 // may vary - for example, on mac "1" and "0" are used for boolean. | 903 // may vary - for example, on mac "1" and "0" are used for boolean. |
915 bool LayoutTestController::CppVariantToBool(const CppVariant& value) { | 904 bool LayoutTestController::CppVariantToBool(const CppVariant& value) { |
916 if (value.isBool()) | 905 if (value.isBool()) |
917 return value.ToBoolean(); | 906 return value.ToBoolean(); |
918 else if (value.isInt32()) | 907 else if (value.isInt32()) |
919 return 0 != value.ToInt32(); | 908 return 0 != value.ToInt32(); |
920 else if (value.isString()) { | 909 else if (value.isString()) { |
921 std::string valueString = value.ToString(); | 910 std::string valueString = value.ToString(); |
922 if (valueString == "true" || valueString == "1") | 911 if (valueString == "true" || valueString == "1") |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 } | 1163 } |
1175 | 1164 |
1176 void LayoutTestController::addUserScript(const CppArgumentList& args, | 1165 void LayoutTestController::addUserScript(const CppArgumentList& args, |
1177 CppVariant* result) { | 1166 CppVariant* result) { |
1178 result->SetNull(); | 1167 result->SetNull(); |
1179 if (args.size() < 1 || !args[0].isString() || !args[1].isBool()) | 1168 if (args.size() < 1 || !args[0].isString() || !args[1].isBool()) |
1180 return; | 1169 return; |
1181 shell_->webView()->addUserScript(WebString::fromUTF8(args[0].ToString()), | 1170 shell_->webView()->addUserScript(WebString::fromUTF8(args[0].ToString()), |
1182 args[1].ToBoolean()); | 1171 args[1].ToBoolean()); |
1183 } | 1172 } |
OLD | NEW |