- Revision
- 158199
- Author
- [email protected]
- Date
- 2013-10-29 10:47:46 -0700 (Tue, 29 Oct 2013)
Log Message
[Mac] Rationalize user defaults override code
https://bugs.webkit.org/show_bug.cgi?id=123436
Reviewed by Dan Bernstein.
* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues): Renamed from resetDefaultsToConsistentValues,
because this function only resets WebPreferences now.
(setDefaultsToConsistentValuesForTesting): Moved code for setting the defaults
here, because tests never change them, and they only need to be set once, not
before each test. Removed long obsolete workaround for HIToolbox preferences.
Don't call resetWebPreferencesToConsistentValues, because it will be called before
the first test anyway.
(main): Don't set AppleMagnifiedMode here, moved that to setDefaultsToConsistentValuesForTesting.
(resetWebViewToConsistentStateBeforeTesting): Moved TestRunner::setSerializeHTTPLoads
and setlocale calls out of resetWebPreferencesToConsistentValues().
Added AppleAquaAntiAliasingChanged notification that we had in WK2, because it's
also needed in WK1.
* WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm:
(WTR::InjectedBundle::platformInitialize): Use literal syntax for defaults
dictionary.
* WebKitTestRunner/mac/main.mm:
(setDefaultsToConsistentValuesForTesting): Factored out of main(), and changed to
use NSArgumentDomain for everything.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (158198 => 158199)
--- trunk/Tools/ChangeLog 2013-10-29 17:40:52 UTC (rev 158198)
+++ trunk/Tools/ChangeLog 2013-10-29 17:47:46 UTC (rev 158199)
@@ -1,3 +1,32 @@
+2013-10-29 Alexey Proskuryakov <[email protected]>
+
+ [Mac] Rationalize user defaults override code
+ https://bugs.webkit.org/show_bug.cgi?id=123436
+
+ Reviewed by Dan Bernstein.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (resetWebPreferencesToConsistentValues): Renamed from resetDefaultsToConsistentValues,
+ because this function only resets WebPreferences now.
+ (setDefaultsToConsistentValuesForTesting): Moved code for setting the defaults
+ here, because tests never change them, and they only need to be set once, not
+ before each test. Removed long obsolete workaround for HIToolbox preferences.
+ Don't call resetWebPreferencesToConsistentValues, because it will be called before
+ the first test anyway.
+ (main): Don't set AppleMagnifiedMode here, moved that to setDefaultsToConsistentValuesForTesting.
+ (resetWebViewToConsistentStateBeforeTesting): Moved TestRunner::setSerializeHTTPLoads
+ and setlocale calls out of resetWebPreferencesToConsistentValues().
+ Added AppleAquaAntiAliasingChanged notification that we had in WK2, because it's
+ also needed in WK1.
+
+ * WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm:
+ (WTR::InjectedBundle::platformInitialize): Use literal syntax for defaults
+ dictionary.
+
+ * WebKitTestRunner/mac/main.mm:
+ (setDefaultsToConsistentValuesForTesting): Factored out of main(), and changed to
+ use NSArgumentDomain for everything.
+
2013-10-29 Philippe Normand <[email protected]>
[GTK] enable media-stream in build-webkit
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (158198 => 158199)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2013-10-29 17:40:52 UTC (rev 158198)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2013-10-29 17:47:46 UTC (rev 158199)
@@ -597,60 +597,8 @@
}
// Called before each test.
-static void resetDefaultsToConsistentValues()
+static void resetWebPreferencesToConsistentValues()
{
- static const int NoFontSmoothing = 0;
- static const int BlueTintedAppearance = 1;
-
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults setInteger:4 forKey:@"AppleAntiAliasingThreshold"]; // smallest font size to CG should perform antialiasing on
- [defaults setInteger:NoFontSmoothing forKey:@"AppleFontSmoothing"];
- [defaults setInteger:BlueTintedAppearance forKey:@"AppleAquaColorVariant"];
- [defaults setObject:@"0.709800 0.835300 1.000000" forKey:@"AppleHighlightColor"];
- [defaults setObject:@"0.500000 0.500000 0.500000" forKey:@"AppleOtherHighlightColor"];
- [defaults setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"];
- [defaults setBool:YES forKey:WebKitEnableFullDocumentTeardownPreferenceKey];
- [defaults setBool:YES forKey:WebKitFullScreenEnabledPreferenceKey];
- [defaults setBool:YES forKey:@"UseWebKitWebInspector"];
-
- [defaults setObject:[NSDictionary dictionaryWithObjectsAndKeys:
- @"notational", @"notationl",
- @"message", @"mesage",
- @"would", @"wouldn",
- @"welcome", @"wellcome",
- @"hello\nworld", @"hellolfworld",
- nil] forKey:@"NSTestCorrectionDictionary"];
-
- // Scrollbars are drawn either using AppKit (which uses NSUserDefaults) or using HIToolbox (which uses CFPreferences / kCFPreferencesAnyApplication / kCFPreferencesCurrentUser / kCFPreferencesAnyHost)
- [defaults setObject:@"DoubleMax" forKey:@"AppleScrollBarVariant"];
- RetainPtr<CFTypeRef> initialValue = CFPreferencesCopyValue(CFSTR("AppleScrollBarVariant"), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
- CFPreferencesSetValue(CFSTR("AppleScrollBarVariant"), CFSTR("DoubleMax"), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-#ifndef __LP64__
- // See <rdar://problem/6347388>.
- ThemeScrollBarArrowStyle style;
- GetThemeScrollBarArrowStyle(&style); // Force HIToolbox to read from CFPreferences
-#endif
-
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
- [defaults setBool:NO forKey:@"NSScrollAnimationEnabled"];
-#else
- [defaults setBool:NO forKey:@"AppleScrollAnimationEnabled"];
-#endif
-
- [defaults setBool:NO forKey:@"NSOverlayScrollersEnabled"];
- [defaults setObject:@"Always" forKey:@"AppleShowScrollBars"];
-
- if (initialValue)
- CFPreferencesSetValue(CFSTR("AppleScrollBarVariant"), initialValue.get(), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-
- NSString *path = libraryPathForDumpRenderTree();
- [defaults setObject:[path stringByAppendingPathComponent:@"Databases"] forKey:WebDatabaseDirectoryDefaultsKey];
- [defaults setObject:[path stringByAppendingPathComponent:@"LocalStorage"] forKey:WebStorageDirectoryDefaultsKey];
- [defaults setObject:[path stringByAppendingPathComponent:@"LocalCache"] forKey:WebKitLocalCacheDefaultsKey];
-
- [defaults setBool:NO forKey:@"WebKitKerningAndLigaturesEnabledByDefault"];
-
WebPreferences *preferences = [WebPreferences standardPreferences];
[preferences setAllowUniversalAccessFromFileURLs:YES];
@@ -723,10 +671,6 @@
[preferences setScreenFontSubstitutionEnabled:YES];
[WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
-
- TestRunner::setSerializeHTTPLoads(false);
-
- setlocale(LC_ALL, "");
}
// Called once on DumpRenderTree startup.
@@ -735,13 +679,49 @@
// FIXME: We'd like to start with a clean state for every test, but this function can't be used more than once yet.
[WebPreferences _switchNetworkLoaderToNewTestingSession];
- resetDefaultsToConsistentValues();
+ static const int NoFontSmoothing = 0;
+ static const int BlueTintedAppearance = 1;
- NSString *path = libraryPathForDumpRenderTree();
+ NSString *libraryPath = libraryPathForDumpRenderTree();
+
+ NSDictionary *dict = @{
+ @"AppleMagnifiedMode": @YES,
+ @"AppleAntiAliasingThreshold": @4,
+ @"AppleFontSmoothing": @(NoFontSmoothing),
+ @"AppleAquaColorVariant": @(BlueTintedAppearance),
+ @"AppleHighlightColor": @"0.709800 0.835300 1.000000",
+ @"AppleOtherHighlightColor":@"0.500000 0.500000 0.500000",
+ @"AppleLanguages": @[ @"en" ],
+ WebKitEnableFullDocumentTeardownPreferenceKey: @YES,
+ WebKitFullScreenEnabledPreferenceKey: @YES,
+ @"UseWebKitWebInspector": @YES,
+ @"NSTestCorrectionDictionary": @{
+ @"notationl": @"notational",
+ @"mesage": @"message",
+ @"wouldn": @"would",
+ @"wellcome": @"welcome",
+ @"hellolfworld": @"hello\nworld"
+ },
+ @"WebKitKerningAndLigaturesEnabledByDefault": @NO,
+ @"AppleScrollBarVariant": @"DoubleMax",
+ @"NSScrollAnimationEnabled": @NO,
+ @"NSOverlayScrollersEnabled": @NO,
+ @"AppleShowScrollBars": @"Always",
+ WebDatabaseDirectoryDefaultsKey: [libraryPath stringByAppendingPathComponent:@"Databases"],
+ WebStorageDirectoryDefaultsKey: [libraryPath stringByAppendingPathComponent:@"LocalStorage"],
+ WebKitLocalCacheDefaultsKey: [libraryPath stringByAppendingPathComponent:@"LocalCache"]
+ };
+
+ [[NSUserDefaults standardUserDefaults] setVolatileDomain:dict forName:NSArgumentDomain];
+
+ // Underlying frameworks have already read AppleAntiAliasingThreshold default before we changed it.
+ // A distributed notification is delivered to all applications, but it should be harmless, and it's the only way to update all underlying frameworks anyway.
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"AppleAquaAntiAliasingChanged" object:nil userInfo:nil deliverImmediately:YES];
+
NSURLCache *sharedCache =
[[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024
diskCapacity:0
- diskPath:[path stringByAppendingPathComponent:@"URLCache"]];
+ diskPath:[libraryPath stringByAppendingPathComponent:@"URLCache"]];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
}
@@ -950,11 +930,7 @@
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[DumpRenderTreeApplication sharedApplication]; // Force AppKit to init itself
-
- NSDictionary *defaults = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"AppleMagnifiedMode", nil];
- [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
- [defaults release];
-
+
dumpRenderTree(argc, argv);
[WebCoreStatistics garbageCollectJavaScriptObjects];
[WebCoreStatistics emptyCache]; // Otherwise SVGImages trigger false positives for Frame/Node counts
@@ -1305,8 +1281,12 @@
[[webView window] setAutodisplay:NO];
[webView setTracksRepaints:NO];
- resetDefaultsToConsistentValues();
+ resetWebPreferencesToConsistentValues();
+ TestRunner::setSerializeHTTPLoads(false);
+
+ setlocale(LC_ALL, "");
+
if (gTestRunner) {
WebCoreTestSupport::resetInternalsObject([mainFrame globalContext]);
// in the case that a test using the chrome input field failed, be sure to clean up for the next test
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm (158198 => 158199)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm 2013-10-29 17:40:52 UTC (rev 158198)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm 2013-10-29 17:47:46 UTC (rev 158199)
@@ -42,22 +42,21 @@
static const int NoFontSmoothing = 0;
static const int BlueTintedAppearance = 1;
- NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInteger:4], @"AppleAntiAliasingThreshold",
- [NSNumber numberWithInteger:NoFontSmoothing], @"AppleFontSmoothing",
- [NSNumber numberWithInteger:BlueTintedAppearance], @"AppleAquaColorVariant",
- @"0.709800 0.835300 1.000000", @"AppleHighlightColor",
- @"0.500000 0.500000 0.500000", @"AppleOtherHighlightColor",
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
- [NSNumber numberWithBool:NO], @"NSScrollAnimationEnabled",
-#else
- [NSNumber numberWithBool:NO], @"AppleScrollAnimationEnabled",
-#endif
- [NSNumber numberWithBool:NO], @"NSOverlayScrollersEnabled",
- @"Always", @"AppleShowScrollBars",
- [NSArray arrayWithObject:@"en"], @"AppleLanguages",
- [NSDictionary dictionaryWithObjectsAndKeys:@"notational", @"notationl", nil], @"NSTestCorrectionDictionary",
- nil];
+ NSDictionary *dict = @{
+ @"AppleAntiAliasingThreshold": @4,
+ @"AppleFontSmoothing": @(NoFontSmoothing),
+ @"AppleAquaColorVariant": @(BlueTintedAppearance),
+ @"AppleHighlightColor": @"0.709800 0.835300 1.000000",
+ @"AppleOtherHighlightColor": @"0.500000 0.500000 0.500000",
+ @"NSScrollAnimationEnabled": @NO,
+ @"NSOverlayScrollersEnabled": @NO,
+ @"AppleShowScrollBars": @"Always",
+ @"AppleLanguages": @[ @"en" ],
+ // FIXME: Why does this dictionary not match the one in DumpRenderTree?
+ @"NSTestCorrectionDictionary": @{
+ @"notationl": @"notational"
+ }
+ };
[[NSUserDefaults standardUserDefaults] setVolatileDomain:dict forName:NSArgumentDomain];
Modified: trunk/Tools/WebKitTestRunner/mac/main.mm (158198 => 158199)
--- trunk/Tools/WebKitTestRunner/mac/main.mm 2013-10-29 17:40:52 UTC (rev 158198)
+++ trunk/Tools/WebKitTestRunner/mac/main.mm 2013-10-29 17:47:46 UTC (rev 158199)
@@ -27,19 +27,25 @@
#import "TestController.h"
+static void setDefaultsToConsistentValuesForTesting()
+{
+ NSDictionary *dict = @{
+ @"AppleMagnifiedMode": @YES,
+ @"WebKitKerningAndLigaturesEnabledByDefault": @NO,
+ // FIXME: This is likely insufficient, as tests change (and don't reset) these settings via Internals.
+ @"WebAutomaticQuoteSubstitutionEnabled": @NO,
+ @"WebAutomaticDashSubstitutionEnabled": @NO
+ };
+
+ [[NSUserDefaults standardUserDefaults] setVolatileDomain:dict forName:NSArgumentDomain];
+}
+
int main(int argc, const char* argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
- [[NSUserDefaults standardUserDefaults] setVolatileDomain:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:@"WebKitKerningAndLigaturesEnabledByDefault"] forName:NSArgumentDomain];
-
- NSDictionary *defaults = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"AppleMagnifiedMode", nil];
- [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
- [defaults release];
+ setDefaultsToConsistentValuesForTesting();
- [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebAutomaticQuoteSubstitutionEnabled"];
- [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebAutomaticDashSubstitutionEnabled"];
-
{
WTR::TestController controller(argc, argv);
}