summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 22:22:10 +0000
committerdimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 22:22:10 +0000
commit55426bf3a6f25700f23cebbbca35b4a5bc6e9305 (patch)
treeb9a74901e9dd4351c5a3df1f375bae5ad3a830f2 /webkit
parent336e0c3e32bad84ae1daff33431b3d4aa9cf14c7 (diff)
downloadchromium_src-55426bf3a6f25700f23cebbbca35b4a5bc6e9305.zip
chromium_src-55426bf3a6f25700f23cebbbca35b4a5bc6e9305.tar.gz
chromium_src-55426bf3a6f25700f23cebbbca35b4a5bc6e9305.tar.bz2
Make chanegs in layoutTestController reflecting recent upstream change http://trac.webkit.org/changeset/47039
TEST=LayoutTests/fast/harness will be enabled BUG=19064 Review URL: http://codereview.chromium.org/164532 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/layout_tests/test_expectations.txt4
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc108
-rw-r--r--webkit/tools/test_shell/layout_test_controller.h6
3 files changed, 114 insertions, 4 deletions
diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt
index 40140de..323b454 100644
--- a/webkit/tools/layout_tests/test_expectations.txt
+++ b/webkit/tools/layout_tests/test_expectations.txt
@@ -2836,10 +2836,6 @@ BUG18995 LINUX WIN : LayoutTests/editing/pasteboard/select-element-1.html = FAIL
// Fallout from webkit roll 47010:47034
BUG19028 MAC : LayoutTests/fast/dom/Window/window-open-parent-no-parent.html = PASS CRASH
-// Fallout from webkit 47034:47041
-BUG19064 : LayoutTests/fast/harness/override-preferences.html = FAIL
-BUG19064 : LayoutTests/fast/harness/override-preferences-2.html = FAIL
-
// Fallout from webkit 47041:47189
BUG19247 : LayoutTests/fast/events/set-event-in-another-frame.html = FAIL
BUG19248 : LayoutTests/fast/js/const.html = FAIL
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index f80262b..63e6c63 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -138,6 +138,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) {
BindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled);
BindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScriptInIsolatedWorld);
+ BindMethod("overridePreference", &LayoutTestController::overridePreference);
// The fallback method is called when an unknown method is invoked.
BindFallbackMethod(&LayoutTestController::fallbackMethod);
@@ -808,6 +809,113 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(
result->SetNull();
}
+// Need these conversions because the format of the value for overridePreference
+// may vary - for example, on mac "1" and "0" are used for boolean.
+bool LayoutTestController::CppVariantToBool(const CppVariant& value) {
+ if (value.isBool())
+ return value.ToBoolean();
+ else if (value.isInt32())
+ return 0 != value.ToInt32();
+ else if (value.isString()) {
+ std::string valueString = value.ToString();
+ if (valueString == "true")
+ return true;
+ if (valueString == "false")
+ return false;
+ }
+ shell_->delegate()->AddMessageToConsole(shell_->webView(),
+ L"Invalid value for preference. Expected boolean value.", 0, L"");
+ return false;
+}
+
+int32 LayoutTestController::CppVariantToInt32(const CppVariant& value) {
+ if (value.isInt32())
+ return value.ToInt32();
+ else if (value.isString()) {
+ int number;
+ if (StringToInt(value.ToString(), &number))
+ return number;
+ }
+ shell_->delegate()->AddMessageToConsole(shell_->webView(),
+ L"Invalid value for preference. Expected integer value.", 0, L"");
+ return 0;
+}
+
+std::wstring LayoutTestController::CppVariantToWstring(
+ const CppVariant& value) {
+ if (value.isString())
+ return UTF8ToWide(value.ToString());
+ shell_->delegate()->AddMessageToConsole(shell_->webView(),
+ L"Invalid value for preference. Expected string value.", 0, L"");
+ return std::wstring();
+}
+
+void LayoutTestController::overridePreference(
+ const CppArgumentList& args, CppVariant* result) {
+ if (args.size() == 2 && args[0].isString()) {
+ std::string key = args[0].ToString();
+ CppVariant value = args[1];
+ WebPreferences* preferences = shell_->GetWebPreferences();
+ if (key == "WebKitStandardFont")
+ preferences->standard_font_family = CppVariantToWstring(value);
+ else if (key == "WebKitFixedFont")
+ preferences->fixed_font_family = CppVariantToWstring(value);
+ else if (key == "WebKitSerifFont")
+ preferences->serif_font_family = CppVariantToWstring(value);
+ else if (key == "WebKitSansSerifFont")
+ preferences->sans_serif_font_family = CppVariantToWstring(value);
+ else if (key == "WebKitCursiveFont")
+ preferences->cursive_font_family = CppVariantToWstring(value);
+ else if (key == "WebKitFantasyFont")
+ preferences->fantasy_font_family = CppVariantToWstring(value);
+ else if (key == "WebKitDefaultFontSize")
+ preferences->default_font_size = CppVariantToInt32(value);
+ else if (key == "WebKitDefaultFixedFontSize")
+ preferences->default_fixed_font_size = CppVariantToInt32(value);
+ else if (key == "WebKitMinimumFontSize")
+ preferences->minimum_font_size = CppVariantToInt32(value);
+ else if (key == "WebKitMinimumLogicalFontSize")
+ preferences->minimum_logical_font_size = CppVariantToInt32(value);
+ else if (key == "WebKitDefaultTextEncodingName")
+ preferences->default_encoding = CppVariantToWstring(value);
+ else if (key == "WebKitJavaScriptEnabled")
+ preferences->javascript_enabled = CppVariantToBool(value);
+ else if (key == "WebKitWebSecurityEnabled")
+ preferences->web_security_enabled = CppVariantToBool(value);
+ else if (key == "WebKitJavaScriptCanOpenWindowsAutomatically")
+ preferences->javascript_can_open_windows_automatically =
+ CppVariantToBool(value);
+ else if (key == "WebKitDisplayImagesKey")
+ preferences->loads_images_automatically = CppVariantToBool(value);
+ else if (key == "WebKitPluginsEnabled")
+ preferences->plugins_enabled = CppVariantToBool(value);
+ else if (key == "WebKitDOMPasteAllowedPreferenceKey")
+ preferences->dom_paste_enabled = CppVariantToBool(value);
+ else if (key == "WebKitDeveloperExtrasEnabledPreferenceKey")
+ preferences->developer_extras_enabled = CppVariantToBool(value);
+ else if (key == "WebKitShrinksStandaloneImagesToFit")
+ preferences->shrinks_standalone_images_to_fit = CppVariantToBool(value);
+ else if (key == "WebKitTextAreasAreResizable")
+ preferences->text_areas_are_resizable = CppVariantToBool(value);
+ else if (key == "WebKitJavaEnabled")
+ preferences->java_enabled = CppVariantToBool(value);
+ else if (key == "WebKitUsesPageCachePreferenceKey")
+ preferences->uses_page_cache = CppVariantToBool(value);
+ else if (key == "WebKitXSSAuditorEnabled")
+ preferences->xss_auditor_enabled = CppVariantToBool(value);
+ else if (key == "WebKitLocalStorageEnabledPreferenceKey")
+ preferences->local_storage_enabled = CppVariantToBool(value);
+ else {
+ std::wstring message(L"Invalid name for preference: ");
+ message.append(ASCIIToWide(key));
+ shell_->delegate()->AddMessageToConsole(shell_->webView(),
+ message, 0, L"");
+ }
+ shell_->webView()->SetPreferences(*preferences);
+ }
+ result->SetNull();
+}
+
void LayoutTestController::fallbackMethod(
const CppArgumentList& args, CppVariant* result) {
std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestController");
diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h
index 151e6fe..c16f185 100644
--- a/webkit/tools/test_shell/layout_test_controller.h
+++ b/webkit/tools/test_shell/layout_test_controller.h
@@ -182,6 +182,7 @@ class LayoutTestController : public CppBoundClass {
void setXSSAuditorEnabled(const CppArgumentList& args, CppVariant* result);
void evaluateScriptInIsolatedWorld(const CppArgumentList& args, CppVariant* result);
+ void overridePreference(const CppArgumentList& args, CppVariant* result);
// The fallback method is called when a nonexistent method is called on
// the layout test controller object.
@@ -269,6 +270,11 @@ class LayoutTestController : public CppBoundClass {
bool frozen_;
};
+ // Support for overridePreference.
+ bool CppVariantToBool(const CppVariant&);
+ int32 CppVariantToInt32(const CppVariant&);
+ std::wstring CppVariantToWstring(const CppVariant&);
+
// Non-owning pointer. The LayoutTestController is owned by the host.
static TestShell* shell_;