Distinguish between an empty WKAppBoundDomains array and a missing entry
authorkatherine_cheney@apple.com <katherine_cheney@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Apr 2020 01:13:23 +0000 (01:13 +0000)
committerkatherine_cheney@apple.com <katherine_cheney@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Apr 2020 01:13:23 +0000 (01:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=210628
<rdar://problem/61909669>

Reviewed by Brent Fulgham.

Currently we treat a missing WKAppBoundDomains key the same as an empty
key, which is incorrect. Having the key present, even with no entries,
should opt an app into app-bound domain behavior.

* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::initializeAppBoundDomains):
(WebKit::WebsiteDataStore::beginAppBoundDomainCheck):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm

index 46ca365..65f9fe3 100644 (file)
@@ -1,3 +1,19 @@
+2020-04-16  Kate Cheney  <katherine_cheney@apple.com>
+
+        Distinguish between an empty WKAppBoundDomains array and a missing entry
+        https://bugs.webkit.org/show_bug.cgi?id=210628
+        <rdar://problem/61909669>
+
+        Reviewed by Brent Fulgham.
+
+        Currently we treat a missing WKAppBoundDomains key the same as an empty
+        key, which is incorrect. Having the key present, even with no entries,
+        should opt an app into app-bound domain behavior.
+
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::initializeAppBoundDomains):
+        (WebKit::WebsiteDataStore::beginAppBoundDomainCheck):
+
 2020-04-16  Brent Fulgham  <bfulgham@apple.com>
 
         Add a new 'limitNavigationsToAppBoundDomains' property to WKWebViewConfiguration 
index 5fbf562..87dd885 100644 (file)
@@ -75,6 +75,7 @@ static WorkQueue& appBoundDomainQueue()
 }
 
 static std::atomic<bool> hasInitializedAppBoundDomains = false;
+static std::atomic<bool> keyExists = false;
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 WebCore::ThirdPartyCookieBlockingMode WebsiteDataStore::thirdPartyCookieBlockingMode() const
@@ -409,6 +410,7 @@ void WebsiteDataStore::initializeAppBoundDomains(ForceReinitialization forceRein
             return;
         
         NSArray<NSString *> *domains = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"WKAppBoundDomains"];
+        keyExists = domains ? true : false;
         
         RunLoop::main().dispatch([isInAppBrowserPrivacyEnabled, forceReinitialization, domains = retainPtr(domains)] {
             if (forceReinitialization == ForceReinitialization::Yes)
@@ -465,7 +467,7 @@ void WebsiteDataStore::beginAppBoundDomainCheck(const URL& requestURL, WebFrameP
     }
 
     ensureAppBoundDomains([domain = WebCore::RegistrableDomain(requestURL), listener = makeRef(listener)] (auto& domains) mutable {
-        if (domains.isEmpty()) {
+        if (domains.isEmpty() && !keyExists) {
             listener->didReceiveAppBoundDomainResult(WTF::nullopt);
             return;
         }