Title: [265740] trunk
Revision
265740
Author
[email protected]
Date
2020-08-15 15:53:41 -0700 (Sat, 15 Aug 2020)

Log Message

Live Web Content processes do not respect accent color if dynamically changed to "multicolor"
https://bugs.webkit.org/show_bug.cgi?id=215523
<rdar://problem/63941133>

Reviewed by Wenson Hsieh.

Source/WebKit:

* UIProcess/Cocoa/PreferenceObserver.mm:
(-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::setPreferenceValue):
The NSUserDefaults syncing mechanism does not propagate defaults that are
deleted or changed to nil.

Allow nil, and fix up an assert that would fire for the same reason.

Tools:

* TestWebKitAPI/Tests/WebKit/PreferenceChanges.mm:
(deleteTestDefaults):
(TEST):
Fix some minor style issues with these tests.
Fix a bug where these tests would leak state between themselves by leaving defaults behind.
Change the NSUserDefaults key name so that it is abundantly obvious where it comes from when you see it in your defaults.
Leave a FIXME for the future that these tests should probably not be writing to the real persistent defaults.
Add a test that ensures that the observer correctly respects deletion of a default.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (265739 => 265740)


--- trunk/Source/WebKit/ChangeLog	2020-08-15 20:26:21 UTC (rev 265739)
+++ trunk/Source/WebKit/ChangeLog	2020-08-15 22:53:41 UTC (rev 265740)
@@ -1,3 +1,20 @@
+2020-08-15  Tim Horton  <[email protected]>
+
+        Live Web Content processes do not respect accent color if dynamically changed to "multicolor"
+        https://bugs.webkit.org/show_bug.cgi?id=215523
+        <rdar://problem/63941133>
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/Cocoa/PreferenceObserver.mm:
+        (-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::setPreferenceValue):
+        The NSUserDefaults syncing mechanism does not propagate defaults that are
+        deleted or changed to nil.
+
+        Allow nil, and fix up an assert that would fire for the same reason.
+
 2020-08-14  Alex Christensen  <[email protected]>
 
         Revert r263551

Modified: trunk/Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm (265739 => 265740)


--- trunk/Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm	2020-08-15 20:26:21 UTC (rev 265739)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm	2020-08-15 22:53:41 UTC (rev 265740)
@@ -73,11 +73,15 @@
 
         auto globalValue = adoptCF(CFPreferencesCopyValue((__bridge CFStringRef)key, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
         auto domainValue = adoptCF(CFPreferencesCopyValue((__bridge CFStringRef)key, (__bridge CFStringRef)m_suiteName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
-        
-        if (globalValue && [newValue isEqual:(__bridge id)globalValue.get()])
+
+        auto preferenceValuesAreEqual = [] (id a, id b) {
+            return a == b || [a isEqual:b];
+        };
+
+        if (preferenceValuesAreEqual((__bridge id)globalValue.get(), newValue))
             [m_observer preferenceDidChange:nil key:key encodedValue:encodedString];
 
-        if (domainValue && [newValue isEqual:(__bridge id)domainValue.get()])
+        if (preferenceValuesAreEqual((__bridge id)domainValue.get(), newValue))
             [m_observer preferenceDidChange:m_suiteName key:key encodedValue:encodedString];
     }
 }

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (265739 => 265740)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-08-15 20:26:21 UTC (rev 265739)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-08-15 22:53:41 UTC (rev 265740)
@@ -937,7 +937,10 @@
 {
     if (domain.isEmpty()) {
         CFPreferencesSetValue(key.createCFString().get(), (__bridge CFPropertyListRef)value, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-        ASSERT([[[NSUserDefaults standardUserDefaults] objectForKey:key] isEqual:value]);
+#if ASSERT_ENABLED
+        id valueAfterSetting = [[NSUserDefaults standardUserDefaults] objectForKey:key];
+        ASSERT(valueAfterSetting == value || [valueAfterSetting isEqual:value]);
+#endif
     } else
         CFPreferencesSetValue(key.createCFString().get(), (__bridge CFPropertyListRef)value, domain.createCFString().get(), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
 }

Modified: trunk/Tools/ChangeLog (265739 => 265740)


--- trunk/Tools/ChangeLog	2020-08-15 20:26:21 UTC (rev 265739)
+++ trunk/Tools/ChangeLog	2020-08-15 22:53:41 UTC (rev 265740)
@@ -1,3 +1,20 @@
+2020-08-15  Tim Horton  <[email protected]>
+
+        Live Web Content processes do not respect accent color if dynamically changed to "multicolor"
+        https://bugs.webkit.org/show_bug.cgi?id=215523
+        <rdar://problem/63941133>
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/Tests/WebKit/PreferenceChanges.mm:
+        (deleteTestDefaults):
+        (TEST):
+        Fix some minor style issues with these tests.
+        Fix a bug where these tests would leak state between themselves by leaving defaults behind.
+        Change the NSUserDefaults key name so that it is abundantly obvious where it comes from when you see it in your defaults.
+        Leave a FIXME for the future that these tests should probably not be writing to the real persistent defaults.
+        Add a test that ensures that the observer correctly respects deletion of a default.
+
 2020-08-14  Jonathan Bedard  <[email protected]>
 
         [webkitcorepy] Add a NullHandler to logger

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/PreferenceChanges.mm (265739 => 265740)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/PreferenceChanges.mm	2020-08-15 20:26:21 UTC (rev 265739)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/PreferenceChanges.mm	2020-08-15 22:53:41 UTC (rev 265740)
@@ -25,6 +25,9 @@
 
 #import "config.h"
 
+// FIXME: These tests touch the user's *actual* global and AVFoundation defaults domains.
+// We should find a way to get the same test coverage using volatile domains or swizzling or something.
+
 #if WK_HAVE_C_SPI
 
 #import "PlatformUtilities.h"
@@ -47,10 +50,15 @@
 }
 @end
 
-static const CFStringRef testKey = CFSTR("testkey");
-static const CFStringRef globalDomain = CFSTR("kCFPreferencesAnyApplication");
+static const CFStringRef globalDomain = kCFPreferencesAnyApplication;
 static const CFStringRef testDomain = CFSTR("com.apple.avfoundation");
 
+#define TEST_KEY() ((CFStringRef)[NSString stringWithFormat:@"TestWebKitAPI_TestKey_%s", ::testing::UnitTest::GetInstance()->current_test_info()->name()])
+#define CLEAR_DEFAULTS() { \
+    CFPreferencesSetValue(TEST_KEY(), nil, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); \
+    CFPreferencesSetAppValue(TEST_KEY(), nil, testDomain); \
+}
+
 static void waitForPreferenceSynchronization()
 {
     __block bool didSynchronize = false;
@@ -62,57 +70,67 @@
 
 TEST(WebKit, PreferenceObserver)
 {
+    CLEAR_DEFAULTS();
+
     receivedPreferenceNotification = false;
 
-    CFPreferencesSetAppValue(testKey, CFSTR("1"), testDomain);
+    CFPreferencesSetAppValue(TEST_KEY(), CFSTR("1"), testDomain);
 
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
 
-    CFPreferencesSetAppValue(testKey, CFSTR("2"), testDomain);
+    CFPreferencesSetAppValue(TEST_KEY(), CFSTR("2"), testDomain);
 
     TestWebKitAPI::Util::run(&receivedPreferenceNotification);
+
+    CLEAR_DEFAULTS();
 }
 
 TEST(WebKit, PreferenceObserverArray)
 {
+    CLEAR_DEFAULTS();
+
     receivedPreferenceNotification = false;
 
     NSArray *array = @[@1, @2, @3];
 
     auto userDefaults = adoptNS([[NSUserDefaults alloc] initWithSuiteName:(NSString *)testDomain]);
-    [userDefaults.get() setObject:array forKey:(NSString *)testKey];
+    [userDefaults setObject:array forKey:(NSString *)TEST_KEY()];
 
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
 
     NSArray *changedArray = @[@3, @2, @1];
-    [userDefaults.get() setObject:changedArray forKey:(NSString *)testKey];
+    [userDefaults setObject:changedArray forKey:(NSString *)TEST_KEY()];
 
     TestWebKitAPI::Util::run(&receivedPreferenceNotification);
+
+    CLEAR_DEFAULTS();
 }
 
 TEST(WebKit, PreferenceChanges)
 {
-    CFPreferencesSetAppValue(testKey, CFSTR("0"), testDomain);
+    CLEAR_DEFAULTS();
 
+    CFPreferencesSetAppValue(TEST_KEY(), CFSTR("0"), testDomain);
+
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
     
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
-    configuration.get().processPool = (WKProcessPool *)context.get();
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
     [webView synchronouslyLoadTestPageNamed:@"simple"];
 
     receivedPreferenceNotification = false;
 
-    CFPreferencesSetAppValue(testKey, CFSTR("1"), testDomain);
+    CFPreferencesSetAppValue(TEST_KEY(), CFSTR("1"), testDomain);
 
-    EXPECT_EQ(1, CFPreferencesGetAppIntegerValue(testKey, testDomain, nullptr));
+    EXPECT_EQ(1, CFPreferencesGetAppIntegerValue(TEST_KEY(), testDomain, nullptr));
 
     TestWebKitAPI::Util::run(&receivedPreferenceNotification);
 
     auto preferenceValue = [&] {
         waitForPreferenceSynchronization();
-        NSString *js = [NSString stringWithFormat:@"window.internals.readPreferenceInteger(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)testKey];
+        NSString *js = [NSString stringWithFormat:@"window.internals.readPreferenceInteger(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)TEST_KEY()];
         return [webView stringByEvaluatingJavaScript:js].intValue;
     };
 
@@ -120,36 +138,40 @@
 
     receivedPreferenceNotification = false;
 
-    CFPreferencesSetAppValue(testKey, CFSTR("2"), testDomain);
+    CFPreferencesSetAppValue(TEST_KEY(), CFSTR("2"), testDomain);
 
     TestWebKitAPI::Util::run(&receivedPreferenceNotification);
 
     EXPECT_EQ(preferenceValue(), 2);
+
+    CLEAR_DEFAULTS();
 }
 
 TEST(WebKit, GlobalPreferenceChangesUsingDefaultsWrite)
 {
-    system([NSString stringWithFormat:@"defaults write %@ %@ 0", (__bridge id)globalDomain, (__bridge id)testKey].UTF8String);
+    CLEAR_DEFAULTS();
+
+    system([NSString stringWithFormat:@"defaults write %@ %@ 0", (__bridge id)globalDomain, (__bridge id)TEST_KEY()].UTF8String);
     
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
     
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
-    configuration.get().processPool = (WKProcessPool *)context.get();
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
     [webView synchronouslyLoadTestPageNamed:@"simple"];
 
     receivedPreferenceNotification = false;
 
-    system([NSString stringWithFormat:@"defaults write %@ %@ 1", (__bridge id)globalDomain, (__bridge id)testKey].UTF8String);
+    system([NSString stringWithFormat:@"defaults write %@ %@ 1", (__bridge id)globalDomain, (__bridge id)TEST_KEY()].UTF8String);
 
-    EXPECT_EQ(1, CFPreferencesGetAppIntegerValue(testKey, globalDomain, nullptr));
+    EXPECT_EQ(1, CFPreferencesGetAppIntegerValue(TEST_KEY(), globalDomain, nullptr));
 
     TestWebKitAPI::Util::run(&receivedPreferenceNotification);
 
     auto preferenceValue = [&] {
         waitForPreferenceSynchronization();
-        NSString *js = [NSString stringWithFormat:@"window.internals.readPreferenceInteger(\"%@\",\"%@\")", (NSString *)globalDomain, (NSString *)testKey];
+        NSString *js = [NSString stringWithFormat:@"window.internals.readPreferenceInteger(\"%@\",\"%@\")", (NSString *)globalDomain, (NSString *)TEST_KEY()];
         return [webView stringByEvaluatingJavaScript:js].intValue;
     };
 
@@ -157,30 +179,34 @@
 
     receivedPreferenceNotification = false;
 
-    system([NSString stringWithFormat:@"defaults write %@ %@ 2", (__bridge id)globalDomain, (__bridge id)testKey].UTF8String);
+    system([NSString stringWithFormat:@"defaults write %@ %@ 2", (__bridge id)globalDomain, (__bridge id)TEST_KEY()].UTF8String);
 
     TestWebKitAPI::Util::run(&receivedPreferenceNotification);
 
     EXPECT_EQ(preferenceValue(), 2);
+
+    CLEAR_DEFAULTS();
 }
 
 TEST(WebKit, PreferenceChangesArray)
 {
+    CLEAR_DEFAULTS();
+
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
 
     NSArray *array = @[@1, @2, @3];
 
     auto userDefaults = adoptNS([[NSUserDefaults alloc] initWithSuiteName:(NSString *)testDomain]);
-    [userDefaults.get() setObject:array forKey:(NSString *)testKey];
+    [userDefaults setObject:array forKey:(NSString *)TEST_KEY()];
 
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
-    configuration.get().processPool = (WKProcessPool *)context.get();
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
 
     auto preferenceValue = [&] {
         waitForPreferenceSynchronization();
-        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)testKey];
+        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)TEST_KEY()];
         return [webView stringByEvaluatingJavaScript:js];
     };
 
@@ -187,7 +213,7 @@
     preferenceValue();
 
     NSArray *changedArray = @[@3, @2, @1];
-    [userDefaults.get() setObject:changedArray forKey:(NSString *)testKey];
+    [userDefaults setObject:changedArray forKey:(NSString *)TEST_KEY()];
 
     auto encodedString = preferenceValue();
     auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:encodedString options:0]);
@@ -197,10 +223,14 @@
     ASSERT_TRUE(!err);
     ASSERT_TRUE(object);
     ASSERT_TRUE([object isEqual:changedArray]);
+
+    CLEAR_DEFAULTS();
 }
 
 TEST(WebKit, PreferenceChangesDictionary)
 {
+    CLEAR_DEFAULTS();
+
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
 
     NSDictionary *dict = @{
@@ -209,16 +239,16 @@
     };
 
     auto userDefaults = adoptNS([[NSUserDefaults alloc] initWithSuiteName:(NSString *)testDomain]);
-    [userDefaults.get() setObject:dict forKey:(NSString *)testKey];
+    [userDefaults setObject:dict forKey:(NSString *)TEST_KEY()];
 
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
-    configuration.get().processPool = (WKProcessPool *)context.get();
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
 
     auto preferenceValue = [&] {
         waitForPreferenceSynchronization();
-        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)testKey];
+        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)TEST_KEY()];
         return [webView stringByEvaluatingJavaScript:js];
     };
 
@@ -229,7 +259,7 @@
         @"b" : @2,
         @"c" : @3,
     };
-    [userDefaults.get() setObject:changedDict forKey:(NSString *)testKey];
+    [userDefaults setObject:changedDict forKey:(NSString *)TEST_KEY()];
 
     auto encodedString = preferenceValue();
     auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:encodedString options:0]);
@@ -239,25 +269,29 @@
     ASSERT_TRUE(!err);
     ASSERT_TRUE(object);
     ASSERT_TRUE([object isEqual:changedDict]);
+
+    CLEAR_DEFAULTS();
 }
 
 TEST(WebKit, PreferenceChangesData)
 {
+    CLEAR_DEFAULTS();
+
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
 
     NSData *data = "" dataWithBytes:"abc" length:3];
 
     auto userDefaults = adoptNS([[NSUserDefaults alloc] initWithSuiteName:(NSString *)testDomain]);
-    [userDefaults.get() setObject:data forKey:(NSString *)testKey];
+    [userDefaults setObject:data forKey:(NSString *)TEST_KEY()];
 
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
-    configuration.get().processPool = (WKProcessPool *)context.get();
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
 
     auto preferenceValue = [&] {
         waitForPreferenceSynchronization();
-        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)testKey];
+        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)TEST_KEY()];
         return [webView stringByEvaluatingJavaScript:js];
     };
 
@@ -264,7 +298,7 @@
     preferenceValue();
 
     NSData *changedData = [NSData dataWithBytes:"abcd" length:4];
-    [userDefaults.get() setObject:changedData forKey:(NSString *)testKey];
+    [userDefaults setObject:changedData forKey:(NSString *)TEST_KEY()];
 
     auto encodedString = preferenceValue();
     auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:encodedString options:0]);
@@ -274,25 +308,29 @@
     ASSERT_TRUE(!err);
     ASSERT_TRUE(object);
     ASSERT_TRUE([object isEqual:changedData]);
+
+    CLEAR_DEFAULTS();
 }
 
 TEST(WebKit, PreferenceChangesDate)
 {
+    CLEAR_DEFAULTS();
+
     auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
 
     NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0];
 
     auto userDefaults = adoptNS([[NSUserDefaults alloc] initWithSuiteName:(NSString *)testDomain]);
-    [userDefaults.get() setObject:date forKey:(NSString *)testKey];
+    [userDefaults setObject:date forKey:(NSString *)TEST_KEY()];
 
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
-    configuration.get().processPool = (WKProcessPool *)context.get();
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
 
     auto preferenceValue = [&] {
         waitForPreferenceSynchronization();
-        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)testKey];
+        NSString *js = [NSString stringWithFormat:@"window.internals.encodedPreferenceValue(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)TEST_KEY()];
         return [webView stringByEvaluatingJavaScript:js];
     };
 
@@ -299,7 +337,7 @@
     preferenceValue();
 
     NSDate *changedDate = [NSDate dateWithTimeIntervalSinceNow:10];
-    [userDefaults.get() setObject:changedDate forKey:(NSString *)testKey];
+    [userDefaults setObject:changedDate forKey:(NSString *)TEST_KEY()];
 
     auto encodedString = preferenceValue();
     auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:encodedString options:0]);
@@ -309,8 +347,40 @@
     ASSERT_TRUE(!err);
     ASSERT_TRUE(object);
     ASSERT_TRUE([object isEqual:changedDate]);
+
+    CLEAR_DEFAULTS();
 }
 
+TEST(WebKit, PreferenceChangesNil)
+{
+    CLEAR_DEFAULTS();
+
+    auto observer = adoptNS([[WKTestPreferenceObserver alloc] init]);
+
+    auto userDefaults = adoptNS([[NSUserDefaults alloc] initWithSuiteName:(NSString *)testDomain]);
+    [userDefaults setObject:@1 forKey:(NSString *)TEST_KEY()];
+
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+
+    auto preferenceValue = [&] {
+        waitForPreferenceSynchronization();
+        NSString *js = [NSString stringWithFormat:@"window.internals.readPreferenceInteger(\"%@\",\"%@\")", (NSString *)testDomain, (NSString *)TEST_KEY()];
+        return [webView stringByEvaluatingJavaScript:js].intValue;
+    };
+
+    EXPECT_EQ(1, preferenceValue());
+
+    [userDefaults setObject:nil forKey:(NSString *)TEST_KEY()];
+
+    EXPECT_EQ(0, preferenceValue());
+
+    CLEAR_DEFAULTS();
+}
+
 static IMP sharedInstanceMethodOriginal = nil;
 static bool sharedInstanceCalled = false;
 
@@ -331,7 +401,7 @@
 
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
-    configuration.get().processPool = (WKProcessPool *)context.get();
+    [configuration setProcessPool:(WKProcessPool *)context.get()];
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
 
     [webView synchronouslyLoadTestPageNamed:@"simple"];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to