Title: [106005] trunk
Revision
106005
Author
[email protected]
Date
2012-01-26 09:10:28 -0800 (Thu, 26 Jan 2012)

Log Message

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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106004 => 106005)


--- trunk/LayoutTests/ChangeLog	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/LayoutTests/ChangeLog	2012-01-26 17:10:28 UTC (rev 106005)
@@ -1,3 +1,12 @@
+2012-01-26  Caio Marcelo de Oliveira Filho  <[email protected]>
+
+        Implement overridePreference for boolean preferences in WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=77033
+
+        Reviewed by Alexey Proskuryakov.
+
+        * platform/wk2/Skipped:
+
 2012-01-26  Balazs Kelemen  <[email protected]>
 
         [Qt][WK2] Still failing tests after moving to ICU

Modified: trunk/LayoutTests/platform/wk2/Skipped (106004 => 106005)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-01-26 17:10:28 UTC (rev 106005)
@@ -192,7 +192,6 @@
 css3/filters/custom-filter.html
 fast/canvas/webgl/framebuffer-object-attachment.html
 fast/canvas/webgl/gl-vertex-attrib-zero-issues.html
-fast/events/pagehide-timeout.html
 fast/canvas/webgl/gl-getshadersource.html
 fast/canvas/webgl/tex-sub-image-2d-bad-args.html
 fast/canvas/webgl/WebGLContextEvent.html
@@ -287,46 +286,11 @@
 fast/canvas/webgl/viewport-unchanged-upon-resize.html
 fast/canvas/webgl/webgl-array-invalid-ranges.html
 fast/canvas/webgl/webgl-specific.html
-fast/dom/Geolocation/no-page-cache.html
-fast/dom/Window/timer-resume-on-navigation-back.html
-fast/events/onunload-back-to-page-cache.html
-fast/events/pageshow-pagehide-on-back-cached-with-frames.html
-fast/events/pageshow-pagehide-on-back-cached.html
-fast/events/tab-focus-anchor.html
-fast/frames/frame-crash-with-page-cache.html
 fast/harness/override-preferences-2.html
-fast/harness/override-preferences.html
-fast/harness/page-cache-crash-on-data-urls.html
-fast/harness/use-page-cache.html
-fast/history/timed-refresh-in-cached-frame.html
 fast/images/animated-gif-restored-from-bfcache.html
-fast/loader/frames-with-unload-handlers-in-page-cache.html
-fast/loader/input-element-page-cache-crash.html
-fast/loader/scroll-position-restored-on-back.html
-fast/loader/stateobjects/popstate-fires-with-page-cache.html
-fast/loader/unschedule-relayout-after-unload.html
-fast/parser/noscript-with-_javascript_-disabled.html
-fast/parser/noscript-with-_javascript_-enabled.html
 fast/repaint/no-caret-repaint-in-non-content-editable-element.html
 fast/text/zero-font-size.html
 fast/text/international/locale-sensitive-fonts.html
-http/tests/appcache/disabled.html
-css3/filters/custom-filter-shader-cache.html
-css3/filters/effect-blur.html
-css3/filters/effect-brightness.html
-css3/filters/effect-contrast.html
-css3/filters/effect-custom-combined-missing.html
-css3/filters/effect-custom-parameters.html
-css3/filters/effect-drop-shadow.html
-css3/filters/effect-grayscale.html
-css3/filters/effect-hue-rotate.html
-css3/filters/effect-invert.html
-css3/filters/effect-opacity.html
-css3/filters/effect-saturate.html
-css3/filters/effect-sepia.html
-css3/filters/missing-custom-filter-shader.html
-css3/filters/effect-custom.html
-css3/filters/effect-custom-disabled.html
 css3/filters/effect-combined.html
 css3/filters/filter-repaint.html
 

Modified: trunk/Source/WebKit2/ChangeLog (106004 => 106005)


--- trunk/Source/WebKit2/ChangeLog	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/ChangeLog	2012-01-26 17:10:28 UTC (rev 106005)
@@ -1,3 +1,52 @@
+2012-01-26  Caio Marcelo de Oliveira Filho  <[email protected]>
+
+        Implement overridePreference for boolean preferences in WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=77033
+
+        Reviewed by Alexey Proskuryakov.
+
+        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:
+
 2012-01-26  Carlos Garcia Campos  <[email protected]>
 
         [GTK][WK2] Primary clipboard should be updated with the current selection in X11 platforms

Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp (106004 => 106005)


--- trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp	2012-01-26 17:10:28 UTC (rev 106005)
@@ -48,8 +48,7 @@
 } // namespace WebPreferencesKey
 
 
-static bool hasXSSAuditorEnabledTestRunnerOverride;
-static bool xssAuditorEnabledTestRunnerOverride;
+static HashMap<String, bool> boolTestRunnerOverridesMap;
 
 WebPreferencesStore::WebPreferencesStore()
 {
@@ -73,22 +72,17 @@
         return false;
     if (!decoder->decode(result.m_doubleValues))
         return false;
-
-    if (hasXSSAuditorEnabledTestRunnerOverride)
-        result.m_boolValues.set(WebPreferencesKey::xssAuditorEnabledKey(), xssAuditorEnabledTestRunnerOverride);
-
     return true;
 }
 
-void WebPreferencesStore::overrideXSSAuditorEnabledForTestRunner(bool enabled)
+void WebPreferencesStore::overrideBoolValueForKey(const String& key, bool value)
 {
-    hasXSSAuditorEnabledTestRunnerOverride = true;
-    xssAuditorEnabledTestRunnerOverride = enabled;
+    boolTestRunnerOverridesMap.set(key, value);
 }
 
 void WebPreferencesStore::removeTestRunnerOverrides()
 {
-    hasXSSAuditorEnabledTestRunnerOverride = false;
+    boolTestRunnerOverridesMap.clear();
 }
 
 
@@ -185,6 +179,10 @@
 
 bool WebPreferencesStore::getBoolValueForKey(const String& key) const
 {
+    // FIXME: Extend overriding to other key types used from LayoutTestController.
+    HashMap<String, bool>::const_iterator it = boolTestRunnerOverridesMap.find(key);
+    if (it != boolTestRunnerOverridesMap.end())
+        return it->second;
     return valueForKey(m_boolValues, key);
 }
 

Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.h (106004 => 106005)


--- trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2012-01-26 17:10:28 UTC (rev 106005)
@@ -214,7 +214,8 @@
     bool setDoubleValueForKey(const String& key, double value);
     double getDoubleValueForKey(const String& key) const;
 
-    static void overrideXSSAuditorEnabledForTestRunner(bool);
+    // For WebKitTestRunner usage.
+    static void overrideBoolValueForKey(const String& key, bool value);
     static void removeTestRunnerOverrides();
 
     HashMap<String, String> m_stringValues;

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (106004 => 106005)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-01-26 17:10:28 UTC (rev 106005)
@@ -731,3 +731,10 @@
 {
     return toImpl(preferencesRef)->notificationsEnabled();
 }
+
+void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef)
+{
+    // Currently we reset the overrides on the web process when preferencesDidChange() is called. Since WTR preferences
+    // are usually always the same (in the UI process), they are not sent to web process, not triggering the reset.
+    toImpl(preferencesRef)->forceUpdate();
+}

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h (106004 => 106005)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2012-01-26 17:10:28 UTC (rev 106005)
@@ -160,6 +160,8 @@
 WK_EXPORT void WKPreferencesSetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef);
 
+WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPreferences.h (106004 => 106005)


--- trunk/Source/WebKit2/UIProcess/WebPreferences.h	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/UIProcess/WebPreferences.h	2012-01-26 17:10:28 UTC (rev 106005)
@@ -69,6 +69,9 @@
 
 #undef DECLARE_PREFERENCE_GETTER_AND_SETTERS
 
+    // Exposed for WebKitTestRunner use only.
+    void forceUpdate() { update(); }
+
 private:
     WebPreferences();
     WebPreferences(const String& identifier);

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp (106004 => 106005)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2012-01-26 17:10:28 UTC (rev 106005)
@@ -126,9 +126,9 @@
     toImpl(bundleRef)->removeAllUserContent(toImpl(pageGroupRef));
 }
 
-void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled)
+void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef preference, bool enabled)
 {
-    toImpl(bundleRef)->overrideXSSAuditorEnabledForTestRunner(toImpl(pageGroupRef), enabled);
+    toImpl(bundleRef)->overrideBoolPreferenceForTestRunner(toImpl(pageGroupRef), toImpl(preference)->string(), enabled);
 }
 
 void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h (106004 => 106005)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2012-01-26 17:10:28 UTC (rev 106005)
@@ -64,7 +64,8 @@
 WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle, WKBundlePageGroupRef pageGroup);
 
 // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use.
-WK_EXPORT void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
+WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled);
+
 WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
 WK_EXPORT void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
 WK_EXPORT void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (106004 => 106005)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2012-01-26 17:10:28 UTC (rev 106005)
@@ -31,6 +31,7 @@
 #include "InjectedBundleMessageKinds.h"
 #include "InjectedBundleScriptWorld.h"
 #include "InjectedBundleUserMessageCoders.h"
+#include "LayerTreeHost.h"
 #include "WKAPICast.h"
 #include "WKBundleAPICast.h"
 #include "WebApplicationCacheManager.h"
@@ -117,10 +118,52 @@
     PageGroup::removeAllVisitedLinks();
 }
 
+void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled)
+{
+    const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
+
+    // FIXME: Need an explicit way to set "WebKitTabToLinksPreferenceKey" directly in WebPage.
+
+    // Map the names used in LayoutTests with the names used in WebCore::Settings and WebPreferencesStore.
+#define FOR_EACH_OVERRIDE_BOOL_PREFERENCE(macro) \
+    macro(WebKitAcceleratedCompositingEnabled, AcceleratedCompositingEnabled, acceleratedCompositingEnabled) \
+    macro(WebKitCSSCustomFilterEnabled, CSSCustomFilterEnabled, cssCustomFilterEnabled) \
+    macro(WebKitJavaEnabled, JavaEnabled, javaEnabled) \
+    macro(WebKitJavaScriptEnabled, ScriptEnabled, _javascript_Enabled) \
+    macro(WebKitLoadSiteIconsKey, LoadsSiteIconsIgnoringImageLoadingSetting, loadsSiteIconsIgnoringImageLoadingPreference) \
+    macro(WebKitOfflineWebApplicationCacheEnabled, OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled) \
+    macro(WebKitPageCacheSupportsPluginsPreferenceKey, PageCacheSupportsPlugins, pageCacheSupportsPlugins) \
+    macro(WebKitPluginsEnabled, PluginsEnabled, pluginsEnabled) \
+    macro(WebKitUsesPageCachePreferenceKey, UsesPageCache, usesPageCache) \
+    macro(WebKitWebAudioEnabled, WebAudioEnabled, webAudioEnabled) \
+    macro(WebKitWebGLEnabled, WebGLEnabled, webGLEnabled) \
+    macro(WebKitXSSAuditorEnabled, XSSAuditorEnabled, xssAuditorEnabled)
+
+    if (preference == "WebKitAcceleratedCompositingEnabled")
+        enabled = enabled && LayerTreeHost::supportsAcceleratedCompositing();
+
+#define OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(TestRunnerName, SettingsName, WebPreferencesName) \
+    if (preference == #TestRunnerName) { \
+        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::WebPreferencesName##Key(), enabled); \
+        for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) \
+            (*iter)->settings()->set##SettingsName(enabled); \
+        return; \
+    }
+
+    FOR_EACH_OVERRIDE_BOOL_PREFERENCE(OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES)
+
+#if ENABLE(WEB_SOCKETS)
+    OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES("WebKitHixie76WebSocketProtocolEnabled", UseHixie76WebSocketProtocol, hixie76WebSocketProtocolEnabled)
+#endif
+
+#undef OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES
+#undef FOR_EACH_OVERRIDE_BOOL_PREFERENCE
+}
+
 void InjectedBundle::overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled)
 {
     // Override the preference for all future pages.
-    WebPreferencesStore::overrideXSSAuditorEnabledForTestRunner(enabled);
+    WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::xssAuditorEnabledKey(), enabled);
 
     // Change the setting for existing ones.
     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h (106004 => 106005)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h	2012-01-26 17:10:28 UTC (rev 106005)
@@ -97,6 +97,7 @@
     void setShouldTrackVisitedLinks(bool);
     void removeAllVisitedLinks();
     void activateMacFontAscentHack();
+    void overrideBoolPreferenceForTestRunner(WebPageGroupProxy*, const String& preference, bool enabled);
     void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled);
     void setAllowUniversalAccessFromFileURLs(WebPageGroupProxy*, bool);
     void setAllowFileAccessFromFileURLs(WebPageGroupProxy*, bool);

Modified: trunk/Tools/ChangeLog (106004 => 106005)


--- trunk/Tools/ChangeLog	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Tools/ChangeLog	2012-01-26 17:10:28 UTC (rev 106005)
@@ -1,3 +1,22 @@
+2012-01-26  Caio Marcelo de Oliveira Filho  <[email protected]>
+
+        Implement overridePreference for boolean preferences in WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=77033
+
+        Reviewed by Alexey Proskuryakov.
+
+        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.
+
 2012-01-26  Alexander Færøy  <[email protected]>
 
         [Qt] Support opening multiple URL's from the command line in the Qt MiniBrowser

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl (106004 => 106005)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2012-01-26 17:10:28 UTC (rev 106005)
@@ -133,7 +133,10 @@
         void setBackingScaleFactor(in double backingScaleFactor, in object callback);
 
         void setWindowIsKey(in boolean isKey);
-        
+
+        // FIXME: handle non-boolean preferences.
+        void overridePreference(in DOMString preference, in boolean value);
+
         readonly attribute DOMString platformName;
     };
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp (106004 => 106005)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2012-01-26 17:10:28 UTC (rev 106005)
@@ -350,7 +350,8 @@
 
 void LayoutTestController::setXSSAuditorEnabled(bool enabled)
 {
-    WKBundleOverrideXSSAuditorEnabledForTestRunner(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), true);
+    WKRetainPtr<WKStringRef> key(AdoptWK, WKStringCreateWithUTF8CString("WebKitXSSAuditorEnabled"));
+    WKBundleOverrideBoolPreferenceForTestRunner(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), key.get(), enabled);
 }
 
 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled)
@@ -613,4 +614,9 @@
     callLayoutTestControllerCallback(SetBackingScaleFactorCallbackID);
 }
 
+void LayoutTestController::overridePreference(JSStringRef preference, bool value)
+{
+    WKBundleOverrideBoolPreferenceForTestRunner(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), toWK(preference).get(), value);
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h (106004 => 106005)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2012-01-26 17:10:28 UTC (rev 106005)
@@ -192,6 +192,8 @@
     void callFocusWebViewCallback();
     void callSetBackingScaleFactorCallback();
 
+    void overridePreference(JSStringRef preference, bool value);
+
     JSRetainPtr<JSStringRef> platformName();
     
 private:

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (106004 => 106005)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2012-01-26 16:07:53 UTC (rev 106004)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2012-01-26 17:10:28 UTC (rev 106005)
@@ -415,6 +415,7 @@
 
     // Reset preferences
     WKPreferencesRef preferences = WKPageGroupGetPreferences(m_pageGroup.get());
+    WKPreferencesResetTestRunnerOverrides(preferences);
     WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
     WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
     WKPreferencesSetXSSAuditorEnabled(preferences, false);
@@ -427,6 +428,7 @@
 #if ENABLE(FULLSCREEN_API)
     WKPreferencesSetFullScreenEnabled(preferences, true);
 #endif
+    WKPreferencesSetPageCacheEnabled(preferences, false);
 
 // [Qt][WK2]REGRESSION(r104881):It broke hundreds of tests
 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=76247
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to