void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled) { const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); if (preference == "WebKitTabToLinksPreferenceKey") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::tabsToLinksKey(), enabled); for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); webPage->setTabToLinksEnabled(enabled); } } if (preference == "WebKit2AsynchronousPluginInitializationEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledKey(), enabled); for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); webPage->setAsynchronousPluginInitializationEnabled(enabled); } } if (preference == "WebKit2AsynchronousPluginInitializationEnabledForAllPlugins") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey(), enabled); for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); webPage->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled); } } if (preference == "WebKit2ArtificialPluginInitializationDelayEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey(), enabled); for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); webPage->setArtificialPluginInitializationDelayEnabled(enabled); } } #if ENABLE(CSS_REGIONS) if (preference == "WebKitCSSRegionsEnabled") RuntimeEnabledFeatures::setCSSRegionsEnabled(enabled); #endif // 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(WebKitCanvasUsesAcceleratedDrawing, CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing) \ macro(WebKitCSSCustomFilterEnabled, CSSCustomFilterEnabled, cssCustomFilterEnabled) \ macro(WebKitCSSGridLayoutEnabled, CSSGridLayoutEnabled, cssGridLayoutEnabled) \ macro(WebKitFrameFlatteningEnabled, FrameFlatteningEnabled, frameFlatteningEnabled) \ macro(WebKitJavaEnabled, JavaEnabled, javaEnabled) \ macro(WebKitJavaScriptEnabled, ScriptEnabled, javaScriptEnabled) \ 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) \ macro(WebKitShouldRespectImageOrientation, ShouldRespectImageOrientation, shouldRespectImageOrientation) \ macro(WebKitEnableCaretBrowsing, CaretBrowsingEnabled, caretBrowsingEnabled) \ macro(WebKitDisplayImagesKey, LoadsImagesAutomatically, loadsImagesAutomatically) 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) #undef OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES #undef FOR_EACH_OVERRIDE_BOOL_PREFERENCE }