Title: [242388] branches/safari-607-branch
Revision
242388
Author
kocsen_ch...@apple.com
Date
2019-03-04 13:53:55 -0800 (Mon, 04 Mar 2019)

Log Message

Cherry-pick r242302. rdar://problem/48572673

    Add setters on WKWebsiteDataStore for sourceApplicationBundleIdentifier and sourceApplicationSecondaryIdentifier
    https://bugs.webkit.org/show_bug.cgi?id=195229
    <rdar://problem/48520362>

    Reviewed by Chris Dumez.

    Source/WebKit:

    Just like _setBoundInterfaceIdentifier, we need a way to set these properties after instantiation of a WKWebsiteDataStore,
    but we need to make sure we don't set it after the parameters have been copied to the NetworkProcess.

    Functionality verified by manual testing.  See radar.
    Added an API test that verifies the setter restrictions work as expected.

    * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
    (-[WKWebsiteDataStore _sourceApplicationBundleIdentifier]):
    (-[WKWebsiteDataStore _setSourceApplicationBundleIdentifier:]):
    (-[WKWebsiteDataStore _sourceApplicationSecondaryIdentifier]):
    (-[WKWebsiteDataStore _setSourceApplicationSecondaryIdentifier:]):
    * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
    * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
    (WebKit::toPKPaymentRequest):
    * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
    (WebKit::WebsiteDataStore::parameters):
    * UIProcess/WebsiteData/WebsiteDataStore.cpp:
    (WebKit::WebsiteDataStore::WebsiteDataStore):
    (WebKit::WebsiteDataStore::setSourceApplicationSecondaryIdentifier):
    (WebKit::WebsiteDataStore::setSourceApplicationBundleIdentifier):
    * UIProcess/WebsiteData/WebsiteDataStore.h:
    (WebKit::WebsiteDataStore::sourceApplicationBundleIdentifier):
    (WebKit::WebsiteDataStore::sourceApplicationSecondaryIdentifier):

    Tools:

    * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
    (TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242302 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/ChangeLog	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog	2019-03-04 21:53:55 UTC (rev 242388)
@@ -1,3 +1,78 @@
+2019-03-04  Kocsen Chung  <kocsen_ch...@apple.com>
+
+        Cherry-pick r242302. rdar://problem/48572673
+
+    Add setters on WKWebsiteDataStore for sourceApplicationBundleIdentifier and sourceApplicationSecondaryIdentifier
+    https://bugs.webkit.org/show_bug.cgi?id=195229
+    <rdar://problem/48520362>
+    
+    Reviewed by Chris Dumez.
+    
+    Source/WebKit:
+    
+    Just like _setBoundInterfaceIdentifier, we need a way to set these properties after instantiation of a WKWebsiteDataStore,
+    but we need to make sure we don't set it after the parameters have been copied to the NetworkProcess.
+    
+    Functionality verified by manual testing.  See radar.
+    Added an API test that verifies the setter restrictions work as expected.
+    
+    * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+    (-[WKWebsiteDataStore _sourceApplicationBundleIdentifier]):
+    (-[WKWebsiteDataStore _setSourceApplicationBundleIdentifier:]):
+    (-[WKWebsiteDataStore _sourceApplicationSecondaryIdentifier]):
+    (-[WKWebsiteDataStore _setSourceApplicationSecondaryIdentifier:]):
+    * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+    * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+    (WebKit::toPKPaymentRequest):
+    * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+    (WebKit::WebsiteDataStore::parameters):
+    * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+    (WebKit::WebsiteDataStore::WebsiteDataStore):
+    (WebKit::WebsiteDataStore::setSourceApplicationSecondaryIdentifier):
+    (WebKit::WebsiteDataStore::setSourceApplicationBundleIdentifier):
+    * UIProcess/WebsiteData/WebsiteDataStore.h:
+    (WebKit::WebsiteDataStore::sourceApplicationBundleIdentifier):
+    (WebKit::WebsiteDataStore::sourceApplicationSecondaryIdentifier):
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+    (TEST):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242302 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-03-01  Alex Christensen  <achristen...@webkit.org>
+
+            Add setters on WKWebsiteDataStore for sourceApplicationBundleIdentifier and sourceApplicationSecondaryIdentifier
+            https://bugs.webkit.org/show_bug.cgi?id=195229
+            <rdar://problem/48520362>
+
+            Reviewed by Chris Dumez.
+
+            Just like _setBoundInterfaceIdentifier, we need a way to set these properties after instantiation of a WKWebsiteDataStore,
+            but we need to make sure we don't set it after the parameters have been copied to the NetworkProcess.
+
+            Functionality verified by manual testing.  See radar.
+            Added an API test that verifies the setter restrictions work as expected.
+
+            * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+            (-[WKWebsiteDataStore _sourceApplicationBundleIdentifier]):
+            (-[WKWebsiteDataStore _setSourceApplicationBundleIdentifier:]):
+            (-[WKWebsiteDataStore _sourceApplicationSecondaryIdentifier]):
+            (-[WKWebsiteDataStore _setSourceApplicationSecondaryIdentifier:]):
+            * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+            * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+            (WebKit::toPKPaymentRequest):
+            * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+            (WebKit::WebsiteDataStore::parameters):
+            * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+            (WebKit::WebsiteDataStore::WebsiteDataStore):
+            (WebKit::WebsiteDataStore::setSourceApplicationSecondaryIdentifier):
+            (WebKit::WebsiteDataStore::setSourceApplicationBundleIdentifier):
+            * UIProcess/WebsiteData/WebsiteDataStore.h:
+            (WebKit::WebsiteDataStore::sourceApplicationBundleIdentifier):
+            (WebKit::WebsiteDataStore::sourceApplicationSecondaryIdentifier):
+
 2019-03-04  Babak Shafiei  <bshaf...@apple.com>
 
         Cherry-pick r242355. rdar://problem/48563894

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2019-03-04 21:53:55 UTC (rev 242388)
@@ -318,6 +318,28 @@
     _websiteDataStore->websiteDataStore().setProxyConfiguration((__bridge CFDictionaryRef)configuration);
 }
 
+- (NSString *)_sourceApplicationBundleIdentifier
+{
+    return _websiteDataStore->websiteDataStore().sourceApplicationBundleIdentifier();
+}
+
+- (void)_setSourceApplicationBundleIdentifier:(NSString *)identifier
+{
+    if (!_websiteDataStore->websiteDataStore().setSourceApplicationBundleIdentifier(identifier))
+        [NSException raise:NSGenericException format:@"_setSourceApplicationBundleIdentifier cannot be called after networking has begun"];
+}
+
+- (NSString *)_sourceApplicationSecondaryIdentifier
+{
+    return _websiteDataStore->websiteDataStore().sourceApplicationSecondaryIdentifier();
+}
+
+- (void)_setSourceApplicationSecondaryIdentifier:(NSString *)identifier
+{
+    if (!_websiteDataStore->websiteDataStore().setSourceApplicationSecondaryIdentifier(identifier))
+        [NSException raise:NSGenericException format:@"_setSourceApplicationSecondaryIdentifier cannot be called after networking has begun"];
+}
+
 - (NSDictionary *)_proxyConfiguration
 {
     return (__bridge NSDictionary *)_websiteDataStore->websiteDataStore().proxyConfiguration();

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h	2019-03-04 21:53:55 UTC (rev 242388)
@@ -55,6 +55,8 @@
 @property (nonatomic, setter=_setBoundInterfaceIdentifier:) NSString *_boundInterfaceIdentifier WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
 @property (nonatomic, setter=_setAllowsCellularAccess:) BOOL _allowsCellularAccess WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
 @property (nonatomic, setter=_setProxyConfiguration:) NSDictionary *_proxyConfiguration WK_API_AVAILABLE(macosx(10.14), ios(12.0));
+@property (nonatomic, copy, setter=_setSourceApplicationBundleIdentifier:) NSString *_sourceApplicationBundleIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, copy, setter=_setSourceApplicationSecondaryIdentifier:) NSString *_sourceApplicationSecondaryIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 - (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value WK_API_AVAILABLE(macosx(10.13), ios(11.0));
 - (void)_setResourceLoadStatisticsTestingCallback:(nullable void (^)(WKWebsiteDataStore *, NSString *))callback WK_API_AVAILABLE(macosx(10.13), ios(11.0));

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2019-03-04 21:53:55 UTC (rev 242388)
@@ -506,13 +506,13 @@
 #endif
 
     // FIXME: Instead of using respondsToSelector, this should use a proper #if version check.
-    auto& configuration = webPageProxy.websiteDataStore().configuration();
+    auto& websiteDataStore = webPageProxy.websiteDataStore();
 
-    if (!configuration.sourceApplicationBundleIdentifier().isEmpty() && [result respondsToSelector:@selector(setSourceApplicationBundleIdentifier:)])
-        [result setSourceApplicationBundleIdentifier:configuration.sourceApplicationBundleIdentifier()];
+    if (!websiteDataStore.sourceApplicationBundleIdentifier().isEmpty() && [result respondsToSelector:@selector(setSourceApplicationBundleIdentifier:)])
+        [result setSourceApplicationBundleIdentifier:websiteDataStore.sourceApplicationBundleIdentifier()];
 
-    if (!configuration.sourceApplicationSecondaryIdentifier().isEmpty() && [result respondsToSelector:@selector(setSourceApplicationSecondaryIdentifier:)])
-        [result setSourceApplicationSecondaryIdentifier:configuration.sourceApplicationSecondaryIdentifier()];
+    if (!websiteDataStore.sourceApplicationSecondaryIdentifier().isEmpty() && [result respondsToSelector:@selector(setSourceApplicationSecondaryIdentifier:)])
+        [result setSourceApplicationSecondaryIdentifier:websiteDataStore.sourceApplicationSecondaryIdentifier()];
 
 #if PLATFORM(IOS_FAMILY)
     if (!webPageProxy.process().processPool().configuration().ctDataConnectionServiceType().isEmpty() && [result respondsToSelector:@selector(setCTDataConnectionServiceType:)])

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-03-04 21:53:55 UTC (rev 242388)
@@ -492,6 +492,9 @@
     if (m_websiteDataStore) {
         parameters.defaultDataStoreParameters.pendingCookies = copyToVector(m_websiteDataStore->websiteDataStore().pendingCookies());
         m_websiteDataStore->websiteDataStore().clearPendingCookies();
+        parameters.defaultDataStoreParameters.networkSessionParameters.sourceApplicationBundleIdentifier = m_websiteDataStore->websiteDataStore().sourceApplicationBundleIdentifier();
+        parameters.defaultDataStoreParameters.networkSessionParameters.sourceApplicationSecondaryIdentifier = m_websiteDataStore->websiteDataStore().sourceApplicationSecondaryIdentifier();
+        m_websiteDataStore->websiteDataStore().finalizeApplicationIdentifiers();
     }
 
     parameters.cacheModel = cacheModel();

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2019-03-04 21:53:55 UTC (rev 242388)
@@ -89,13 +89,14 @@
         m_boundInterfaceIdentifier,
         m_allowsCellularAccess,
         m_proxyConfiguration,
-        m_configuration->sourceApplicationBundleIdentifier(),
-        m_configuration->sourceApplicationSecondaryIdentifier(),
+        m_sourceApplicationBundleIdentifier,
+        m_sourceApplicationSecondaryIdentifier,
         shouldLogCookieInformation,
         Seconds { [defaults integerForKey:WebKitNetworkLoadThrottleLatencyMillisecondsDefaultsKey] / 1000. },
         WTFMove(httpProxy),
         WTFMove(httpsProxy),
     };
+    finalizeApplicationIdentifiers();
 
     auto cookieFile = resolvedCookieStorageFile();
 
@@ -107,8 +108,8 @@
     }
 
     parameters.uiProcessCookieStorageIdentifier = m_uiProcessCookieStorageIdentifier;
-    parameters.networkSessionParameters.sourceApplicationBundleIdentifier = m_configuration->sourceApplicationBundleIdentifier();
-    parameters.networkSessionParameters.sourceApplicationSecondaryIdentifier = m_configuration->sourceApplicationSecondaryIdentifier();
+    parameters.networkSessionParameters.sourceApplicationBundleIdentifier = m_sourceApplicationBundleIdentifier;
+    parameters.networkSessionParameters.sourceApplicationSecondaryIdentifier = m_sourceApplicationSecondaryIdentifier;
 
     parameters.pendingCookies = copyToVector(m_pendingCookies);
 

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-03-04 21:53:55 UTC (rev 242388)
@@ -95,6 +95,8 @@
     , m_storageManager(StorageManager::create(m_configuration->localStorageDirectory()))
     , m_deviceIdHashSaltStorage(DeviceIdHashSaltStorage::create(isPersistent() ? m_configuration->deviceIdHashSaltsStorageDirectory() : String()))
     , m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore"))
+    , m_sourceApplicationBundleIdentifier(m_configuration->sourceApplicationBundleIdentifier())
+    , m_sourceApplicationSecondaryIdentifier(m_configuration->sourceApplicationSecondaryIdentifier())
 #if ENABLE(WEB_AUTHN)
     , m_authenticatorManager(makeUniqueRef<AuthenticatorManager>())
 #endif
@@ -1711,4 +1713,20 @@
         m_resourceLoadStatistics->didCreateNetworkProcess();
 }
 
+bool WebsiteDataStore::setSourceApplicationSecondaryIdentifier(String&& identifier)
+{
+    if (!m_allowedToSetApplicationIdentifiers)
+        return false;
+    m_sourceApplicationSecondaryIdentifier = WTFMove(identifier);
+    return true;
 }
+
+bool WebsiteDataStore::setSourceApplicationBundleIdentifier(String&& identifier)
+{
+    if (!m_allowedToSetApplicationIdentifiers)
+        return false;
+    m_sourceApplicationBundleIdentifier = WTFMove(identifier);
+    return true;
+}
+
+}

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (242387 => 242388)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2019-03-04 21:53:55 UTC (rev 242388)
@@ -158,7 +158,15 @@
 
     void setBoundInterfaceIdentifier(String&& identifier) { m_boundInterfaceIdentifier = WTFMove(identifier); }
     const String& boundInterfaceIdentifier() { return m_boundInterfaceIdentifier; }
+
+    const String& sourceApplicationBundleIdentifier() const { return m_sourceApplicationBundleIdentifier; }
+    bool setSourceApplicationBundleIdentifier(String&&);
+
+    const String& sourceApplicationSecondaryIdentifier() const { return m_sourceApplicationSecondaryIdentifier; }
+    bool setSourceApplicationSecondaryIdentifier(String&&);
     
+    void finalizeApplicationIdentifiers() { m_allowedToSetApplicationIdentifiers = false; }
+    
     void setAllowsCellularAccess(AllowsCellularAccess allows) { m_allowsCellularAccess = allows; }
     AllowsCellularAccess allowsCellularAccess() { return m_allowsCellularAccess; }
 
@@ -248,6 +256,9 @@
 
     String m_boundInterfaceIdentifier;
     AllowsCellularAccess m_allowsCellularAccess { AllowsCellularAccess::Yes };
+    String m_sourceApplicationBundleIdentifier;
+    String m_sourceApplicationSecondaryIdentifier;
+    bool m_allowedToSetApplicationIdentifiers { true };
 
 #if HAVE(SEC_KEY_PROXY)
     Vector<Ref<SecKeyProxyStore>> m_secKeyProxyStores;

Modified: branches/safari-607-branch/Tools/ChangeLog (242387 => 242388)


--- branches/safari-607-branch/Tools/ChangeLog	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Tools/ChangeLog	2019-03-04 21:53:55 UTC (rev 242388)
@@ -1,3 +1,57 @@
+2019-03-04  Kocsen Chung  <kocsen_ch...@apple.com>
+
+        Cherry-pick r242302. rdar://problem/48572673
+
+    Add setters on WKWebsiteDataStore for sourceApplicationBundleIdentifier and sourceApplicationSecondaryIdentifier
+    https://bugs.webkit.org/show_bug.cgi?id=195229
+    <rdar://problem/48520362>
+    
+    Reviewed by Chris Dumez.
+    
+    Source/WebKit:
+    
+    Just like _setBoundInterfaceIdentifier, we need a way to set these properties after instantiation of a WKWebsiteDataStore,
+    but we need to make sure we don't set it after the parameters have been copied to the NetworkProcess.
+    
+    Functionality verified by manual testing.  See radar.
+    Added an API test that verifies the setter restrictions work as expected.
+    
+    * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+    (-[WKWebsiteDataStore _sourceApplicationBundleIdentifier]):
+    (-[WKWebsiteDataStore _setSourceApplicationBundleIdentifier:]):
+    (-[WKWebsiteDataStore _sourceApplicationSecondaryIdentifier]):
+    (-[WKWebsiteDataStore _setSourceApplicationSecondaryIdentifier:]):
+    * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+    * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+    (WebKit::toPKPaymentRequest):
+    * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+    (WebKit::WebsiteDataStore::parameters):
+    * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+    (WebKit::WebsiteDataStore::WebsiteDataStore):
+    (WebKit::WebsiteDataStore::setSourceApplicationSecondaryIdentifier):
+    (WebKit::WebsiteDataStore::setSourceApplicationBundleIdentifier):
+    * UIProcess/WebsiteData/WebsiteDataStore.h:
+    (WebKit::WebsiteDataStore::sourceApplicationBundleIdentifier):
+    (WebKit::WebsiteDataStore::sourceApplicationSecondaryIdentifier):
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+    (TEST):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242302 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-03-01  Alex Christensen  <achristen...@webkit.org>
+
+            Add setters on WKWebsiteDataStore for sourceApplicationBundleIdentifier and sourceApplicationSecondaryIdentifier
+            https://bugs.webkit.org/show_bug.cgi?id=195229
+            <rdar://problem/48520362>
+
+            Reviewed by Chris Dumez.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+            (TEST):
+
 2019-02-28  Andy Estes  <aes...@apple.com>
 
         [watchOS] Disable Parental Controls content filtering

Modified: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (242387 => 242388)


--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2019-03-04 21:52:32 UTC (rev 242387)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2019-03-04 21:53:55 UTC (rev 242388)
@@ -28,6 +28,8 @@
 #import "PlatformUtilities.h"
 #import "Test.h"
 #import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesRef.h>
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
@@ -448,4 +450,29 @@
     [webView _test_waitForDidFinishNavigation];
 }
 
+TEST(WebKit, ApplicationIdentifiers)
+{
+    auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+    [websiteDataStoreConfiguration setSourceApplicationBundleIdentifier:@"testidentifier"];
+
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto websiteDataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()] autorelease];
+    EXPECT_TRUE([websiteDataStore._sourceApplicationBundleIdentifier isEqualToString:@"testidentifier"]);
+    [websiteDataStore _setSourceApplicationBundleIdentifier:@"otheridentifier"];
+
+    [webViewConfiguration setWebsiteDataStore:websiteDataStore];
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+    
+    RetainPtr<NSException> exception;
+    @try {
+        [websiteDataStore _setSourceApplicationBundleIdentifier:@"settingShouldFailNow"];
+    } @catch(NSException *caught) {
+        exception = caught;
+    }
+    EXPECT_TRUE([[exception reason] isEqualToString:@"_setSourceApplicationBundleIdentifier cannot be called after networking has begun"]);
+    EXPECT_TRUE([websiteDataStore._sourceApplicationBundleIdentifier isEqualToString:@"otheridentifier"]);
+    EXPECT_TRUE([[websiteDataStoreConfiguration sourceApplicationBundleIdentifier] isEqualToString:@"testidentifier"]);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to