Implement overridePreference for boolean preferences in WebKitTestRunner
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 17:10:28 +0000 (17:10 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 17:10:28 +0000 (17:10 +0000)
commite7fa89172df3ca7557301d730e66214464c4c9da
tree27450f191952ab6463cbf0caf8958a08fb87a85b
parent07ce1c62f7445a08c01ef0339801723becaa78a9
Implement overridePreference for boolean preferences in WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=77033

Reviewed by Alexey Proskuryakov.

Source/WebKit2:

Implement a way to WebKitTestRunner override preferences for the pages
loaded. Follows the same approach taken by
overrideXSSAuditorEnabledForTestRunner() from r66551, but generalizing to many
preferences.

Preferences are stored in the UI process using WebPreferencesStore, and when
there's a change, this data is sent to Web process, triggering
WebPage::preferencesDidChange(), which take a WebPreferencesStore and apply it's
data to the WebCore::Settings object.

The overridePreference() is executed on the Web process, and set the preferences
without communicating to the UI process. The overriden preferences are stored in
a static map and WebPreferencesStore query this map before returning the values
of each preference. This static map is used only on the Web process.

To clear the overrides we need to clear the map. Since WTR only sets preferences
when resetting the page, we hook the clearing at WebPage::preferencesDidChange().
A WKPreferences private function was exposed to WTR force the update, in case
there's no effective change at UI process (all the properties remains the same).

This clearing could be improved by creating a proper message instead of hooking
at WebPage::preferencesDidChange().

* Shared/WebPreferencesStore.cpp:
(WebKit::WebPreferencesStore::decode):
(WebKit::WebPreferencesStore::overrideBoolValueForKey):
(WebKit::WebPreferencesStore::removeTestRunnerOverrides):
(WebKit::WebPreferencesStore::getBoolValueForKey):
* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesResetTestRunnerOverrides):
* UIProcess/API/C/WKPreferencesPrivate.h:
* UIProcess/WebPreferences.h:
(WebKit::WebPreferences::forceUpdate):
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleOverrideBoolPreferenceForTestRunner):
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
(WebKit::InjectedBundle::overrideXSSAuditorEnabledForTestRunner):
* WebProcess/InjectedBundle/InjectedBundle.h:

Tools:

For now overridePreference supports boolean values.

* WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::setXSSAuditorEnabled):
(WTR::LayoutTestController::overridePreference):
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues): Reset the overrides
explicitly and properly disable the use of PageCache when resetting the
state. Tests that use PageCache can now enable it via overridePreference.

LayoutTests:

* platform/wk2/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/wk2/Skipped
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.cpp
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
Source/WebKit2/UIProcess/WebPreferences.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
Tools/WebKitTestRunner/TestController.cpp