[ iOS and Mac wk2 ] http/tests/in-app-browser-privacy/ tests failing
authorkatherine_cheney@apple.com <katherine_cheney@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2020 21:56:56 +0000 (21:56 +0000)
committerkatherine_cheney@apple.com <katherine_cheney@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2020 21:56:56 +0000 (21:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209016
<rdar://problem/60329530>

Reviewed by Chris Dumez.

Source/WebKit:

This patch adds a function to re-initialize app bound domains for
in-app-browser-privacy tests, since they are only initialized once
when the WebsiteDataStore is created. This causes issues if the tests
are run in parallel with other tests with different app-bound domains.

* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreReinitializeAppBoundDomains):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::clearAppBoundDomains):
(WebKit::WebsiteDataStore::reinitializeAppBoundDomains):
* UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

Re-initialize the app-bound domains when the correct
TestOptions parameter is set.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions):
(WTR::TestController::reinitializeAppBoundDomains):
* WebKitTestRunner/TestController.h:

LayoutTests:

Use TestOptions to trigger the re-initialization of app-bound domains.

* http/tests/in-app-browser-privacy/app-bound-domain.html:
* http/tests/in-app-browser-privacy/switch-session-on-navigation-to-app-bound-domain.html:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/in-app-browser-privacy/app-bound-domain.html
LayoutTests/http/tests/in-app-browser-privacy/switch-session-on-navigation-to-app-bound-domain.html
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h

index 4fe7da3..6415ab6 100644 (file)
@@ -1,3 +1,16 @@
+2020-03-13  Kate Cheney  <katherine_cheney@apple.com>
+
+        [ iOS and Mac wk2 ] http/tests/in-app-browser-privacy/ tests failing
+        https://bugs.webkit.org/show_bug.cgi?id=209016
+        <rdar://problem/60329530> 
+
+        Reviewed by Chris Dumez.
+
+        Use TestOptions to trigger the re-initialization of app-bound domains.
+
+        * http/tests/in-app-browser-privacy/app-bound-domain.html:
+        * http/tests/in-app-browser-privacy/switch-session-on-navigation-to-app-bound-domain.html:
+
 2020-03-13  Jason Lawrence  <lawrence.j@apple.com>
 
         [ Mac ] fast/animation/request-animation-frame-timestamps.html is flaky failing.
index 5225c5f..3afee9b 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ internal:IsInAppBrowserPrivacyEnabled=true applicationBundleIdentifier=testidentifier ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ internal:IsInAppBrowserPrivacyEnabled=true applicationBundleIdentifier=inAppBrowserPrivacyTestIdentifier ] -->
 <html>
 <head>
     <script src="../../../resources/js-test-pre.js"></script>
index 44c661a..3eb7cf4 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ internal:IsInAppBrowserPrivacyEnabled=true applicationBundleIdentifier=testidentifier ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ internal:IsInAppBrowserPrivacyEnabled=true applicationBundleIdentifier=inAppBrowserPrivacyTestIdentifier ] -->
 <html lang="en">
 <head>
     <meta charset="UTF-8">
index 82fcc30..c0efa5c 100644 (file)
@@ -1,3 +1,24 @@
+2020-03-13  Kate Cheney  <katherine_cheney@apple.com>
+
+        [ iOS and Mac wk2 ] http/tests/in-app-browser-privacy/ tests failing
+        https://bugs.webkit.org/show_bug.cgi?id=209016
+        <rdar://problem/60329530> 
+
+        Reviewed by Chris Dumez.
+
+        This patch adds a function to re-initialize app bound domains for
+        in-app-browser-privacy tests, since they are only initialized once
+        when the WebsiteDataStore is created. This causes issues if the tests
+        are run in parallel with other tests with different app-bound domains.
+
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreReinitializeAppBoundDomains):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::clearAppBoundDomains):
+        (WebKit::WebsiteDataStore::reinitializeAppBoundDomains):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+
 2020-03-13  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, reverting r258391.
index 950d2ef..335fc20 100644 (file)
@@ -725,3 +725,10 @@ void WKWebsiteDataStoreSetInAppBrowserPrivacyEnabled(WKWebsiteDataStoreRef dataS
         completionHandler(context);
     });
 }
+
+void WKWebsiteDataStoreReinitializeAppBoundDomains(WKWebsiteDataStoreRef dataStoreRef)
+{
+#if PLATFORM(COCOA)
+    WebKit::toImpl(dataStoreRef)->reinitializeAppBoundDomains();
+#endif
+}
index d2a5e7a..5802fea 100644 (file)
@@ -164,6 +164,8 @@ WK_EXPORT void WKWebsiteDataStoreResetQuota(WKWebsiteDataStoreRef dataStoreRef,
 typedef void (*WKWebsiteDataStoreSetInAppBrowserPrivacyEnabledFunction)(void* functionContext);
 WK_EXPORT void WKWebsiteDataStoreSetInAppBrowserPrivacyEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetInAppBrowserPrivacyEnabledFunction completionHandler);
 
+WK_EXPORT void WKWebsiteDataStoreReinitializeAppBoundDomains(WKWebsiteDataStoreRef dataStoreRef);
+
 #ifdef __cplusplus
 }
 #endif
index 4df1776..df7594a 100644 (file)
@@ -448,22 +448,25 @@ static HashSet<WebCore::RegistrableDomain>& appBoundDomains()
     return appBoundDomains;
 }
 
-void WebsiteDataStore::initializeAppBoundDomains()
+void WebsiteDataStore::initializeAppBoundDomains(ForceReinitialization forceReinitialization)
 {
     ASSERT(RunLoop::isMain());
 
-    if (hasInitializedAppBoundDomains)
+    if (hasInitializedAppBoundDomains && forceReinitialization != ForceReinitialization::Yes)
         return;
     
     static const auto maxAppBoundDomainCount = 10;
     
-    appBoundDomainQueue().dispatch([] () mutable {
-        if (hasInitializedAppBoundDomains)
+    appBoundDomainQueue().dispatch([forceReinitialization] () mutable {
+        if (hasInitializedAppBoundDomains && forceReinitialization != ForceReinitialization::Yes)
             return;
         
         NSArray<NSString *> *domains = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"WKAppBoundDomains"];
         
-        RunLoop::main().dispatch([domains = retainPtr(domains)] {
+        RunLoop::main().dispatch([forceReinitialization , domains = retainPtr(domains)] {
+            if (forceReinitialization == ForceReinitialization::Yes)
+                appBoundDomains().clear();
+
             for (NSString *domain in domains.get()) {
                 URL url { URL(), domain };
                 if (!url.isValid())
@@ -512,4 +515,10 @@ void WebsiteDataStore::appBoundDomainsForTesting(CompletionHandler<void(const Ha
     });
 }
 
+void WebsiteDataStore::reinitializeAppBoundDomains()
+{
+    hasInitializedAppBoundDomains = false;
+    initializeAppBoundDomains(ForceReinitialization::Yes);
+}
+
 }
index af2a9ec..d63b447 100644 (file)
@@ -286,9 +286,12 @@ public:
     void beginAppBoundDomainCheck(WebCore::RegistrableDomain&&, WebFramePolicyListenerProxy&);
     void appBoundDomainsForTesting(CompletionHandler<void(const HashSet<WebCore::RegistrableDomain>&)>&&) const;
     void ensureAppBoundDomains(CompletionHandler<void(const HashSet<WebCore::RegistrableDomain>&)>&&) const;
+    void reinitializeAppBoundDomains();
 
 private:
-    void initializeAppBoundDomains();
+    enum class ForceReinitialization : bool { No, Yes };
+    void initializeAppBoundDomains(ForceReinitialization = ForceReinitialization::No);
+
     void fetchDataAndApply(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, RefPtr<WorkQueue>&&, Function<void(Vector<WebsiteDataRecord>)>&& apply);
 
     void platformInitialize();
index 18baa56..bf5299b 100644 (file)
@@ -1,5 +1,21 @@
 2020-03-13  Kate Cheney  <katherine_cheney@apple.com>
 
+        [ iOS and Mac wk2 ] http/tests/in-app-browser-privacy/ tests failing
+        https://bugs.webkit.org/show_bug.cgi?id=209016
+        <rdar://problem/60329530> 
+
+        Reviewed by Chris Dumez.
+
+        Re-initialize the app-bound domains when the correct
+        TestOptions parameter is set.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createWebViewWithOptions):
+        (WTR::TestController::reinitializeAppBoundDomains):
+        * WebKitTestRunner/TestController.h:
+
+2020-03-13  Kate Cheney  <katherine_cheney@apple.com>
+
         Report all third party loads on a per-page basis
         https://bugs.webkit.org/show_bug.cgi?id=209032
         <rdar://problem/60397323>
index 39c41a0..5e06f36 100644 (file)
@@ -791,6 +791,9 @@ void TestController::createWebViewWithOptions(const TestOptions& options)
     // Generally, the tests should default to running at 1x. updateWindowScaleForTest() will adjust the scale to
     // something else for specific tests that need to run at a different window scale.
     m_mainWebView->changeWindowScaleIfNeeded(1);
+    
+    if (!options.applicationBundleIdentifier.isEmpty())
+        reinitializeAppBoundDomains();
 }
 
 void TestController::ensureViewSupportsOptionsForTest(const TestInvocation& test)
@@ -3782,6 +3785,11 @@ void TestController::setInAppBrowserPrivacyEnabled(bool value)
     m_currentInvocation->didSetInAppBrowserPrivacyEnabled();
 }
 
+void TestController::reinitializeAppBoundDomains()
+{
+    WKWebsiteDataStoreReinitializeAppBoundDomains(TestController::websiteDataStore());
+}
+
 #if !PLATFORM(COCOA)
 void TestController::platformAddTestOptions(TestOptions&) const
 {
index d881c07..8eb9674 100644 (file)
@@ -269,6 +269,7 @@ public:
     void clearLoadedThirdPartyDomains();
     void getWebViewCategory();
     void setInAppBrowserPrivacyEnabled(bool);
+    void reinitializeAppBoundDomains();
 
     WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
     void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }