Title: [252259] trunk
Revision
252259
Author
[email protected]
Date
2019-11-08 13:26:15 -0800 (Fri, 08 Nov 2019)

Log Message

Fix flaky tests in http/tests/cache/disk-cache
https://bugs.webkit.org/show_bug.cgi?id=203822

Reviewed by Youenn Fablet.

Source/WebKit:

Right now tests that set the cache model do so using a race condition.  I think this will fix the flakyness we've observed.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::setCacheModelSynchronouslyForTesting):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::setCacheModelSynchronouslyForTesting):
* UIProcess/WebProcessPool.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setCacheModelSynchronouslyForTesting):
* UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setCacheModel):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (252258 => 252259)


--- trunk/Source/WebKit/ChangeLog	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/ChangeLog	2019-11-08 21:26:15 UTC (rev 252259)
@@ -1,5 +1,28 @@
 2019-11-08  Alex Christensen  <[email protected]>
 
+        Fix flaky tests in http/tests/cache/disk-cache
+        https://bugs.webkit.org/show_bug.cgi?id=203822
+
+        Reviewed by Youenn Fablet.
+
+        Right now tests that set the cache model do so using a race condition.  I think this will fix the flakyness we've observed.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::setCacheModelSynchronouslyForTesting):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::setCacheModelSynchronouslyForTesting):
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::setCacheModelSynchronouslyForTesting):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+
+2019-11-08  Alex Christensen  <[email protected]>
+
         Revert some changes accidentally committed with r252257
         https://bugs.webkit.org/show_bug.cgi?id=202178
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (252258 => 252259)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-11-08 21:26:15 UTC (rev 252259)
@@ -1993,6 +1993,12 @@
         downloadManager().continueDecidePendingDownloadDestination(downloadID, destination, WTFMove(sandboxExtensionHandle), allowOverwrite);
 }
 
+void NetworkProcess::setCacheModelSynchronouslyForTesting(CacheModel cacheModel, CompletionHandler<void()>&& completionHandler)
+{
+    setCacheModel(cacheModel, { });
+    completionHandler();
+}
+
 void NetworkProcess::setCacheModel(CacheModel cacheModel, String cacheStorageDirectory)
 {
     if (m_hasSetCacheModel && (cacheModel == m_cacheModel))

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (252258 => 252259)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-11-08 21:26:15 UTC (rev 252259)
@@ -406,6 +406,7 @@
     void applicationWillEnterForeground();
 
     void setCacheModel(CacheModel, String overrideCacheStorageDirectory);
+    void setCacheModelSynchronouslyForTesting(CacheModel, CompletionHandler<void()>&&);
     void allowSpecificHTTPSCertificateForHost(const WebCore::CertificateInfo&, const String& host);
     void clearCacheForAllOrigins(uint32_t cachesToClear);
     void setAllowsAnySSLCertificateForWebSocket(bool, CompletionHandler<void()>&&);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (252258 => 252259)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2019-11-08 21:26:15 UTC (rev 252259)
@@ -69,7 +69,8 @@
     AllowSpecificHTTPSCertificateForHost(WebCore::CertificateInfo certificate, String host)
     
     ClearCacheForAllOrigins(uint32_t cachesToClear)
-    SetCacheModel(enum:uint8_t WebKit::CacheModel cacheModel, String overrideCacheStorageDirectory);
+    SetCacheModel(enum:uint8_t WebKit::CacheModel cacheModel, String overrideCacheStorageDirectory)
+    SetCacheModelSynchronouslyForTesting(enum:uint8_t WebKit::CacheModel cacheModel) -> () Synchronous
 
     ProcessDidTransitionToBackground()
     ProcessDidTransitionToForeground()

Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (252258 => 252259)


--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp	2019-11-08 21:26:15 UTC (rev 252259)
@@ -682,3 +682,7 @@
     });
 }
 
+void WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(WKWebsiteDataStoreRef dataStoreRef, WKCacheModel cacheModel)
+{
+    WebKit::toImpl(dataStoreRef)->setCacheModelSynchronouslyForTesting(WebKit::toCacheModel(cacheModel));
+}

Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h (252258 => 252259)


--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h	2019-11-08 21:26:15 UTC (rev 252259)
@@ -33,6 +33,8 @@
 extern "C" {
 #endif
 
+typedef uint32_t WKCacheModel;
+
 WK_EXPORT WKTypeID WKWebsiteDataStoreGetTypeID();
 
 WK_EXPORT WKWebsiteDataStoreRef WKWebsiteDataStoreGetDefaultDataStore();
@@ -151,6 +153,8 @@
 typedef void (*WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemovalFunction)(void* functionContext);
 WK_EXPORT void WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemovalFunction callback);
 
+WK_EXPORT void WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(WKWebsiteDataStoreRef dataStoreRef, WKCacheModel cacheModel);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (252258 => 252259)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-11-08 21:26:15 UTC (rev 252259)
@@ -1574,6 +1574,14 @@
         m_networkProcess->send(Messages::NetworkProcess::SetCacheModel(cacheModel, { }), 0);
 }
 
+void WebProcessPool::setCacheModelSynchronouslyForTesting(CacheModel cacheModel)
+{
+    updateBackForwardCacheCapacity();
+
+    if (m_networkProcess)
+        m_networkProcess->sendSync(Messages::NetworkProcess::SetCacheModelSynchronouslyForTesting(cacheModel), { }, { });
+}
+
 void WebProcessPool::setDefaultRequestTimeoutInterval(double timeoutInterval)
 {
     sendToAllProcesses(Messages::WebProcess::SetDefaultRequestTimeoutInterval(timeoutInterval));

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (252258 => 252259)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-11-08 21:26:15 UTC (rev 252259)
@@ -283,7 +283,9 @@
     VisitedLinkStore& visitedLinkStore() { return m_visitedLinkStore.get(); }
 
     void setCacheModel(CacheModel);
+    void setCacheModelSynchronouslyForTesting(CacheModel);
 
+
     void setDefaultRequestTimeoutInterval(double);
 
     void startMemorySampler(const double interval);

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (252258 => 252259)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-11-08 21:26:15 UTC (rev 252259)
@@ -2063,6 +2063,12 @@
     return WebCore::StorageQuotaManager::defaultThirdPartyQuotaFromPerOriginQuota(perOriginStorageQuota());
 }
 
+void WebsiteDataStore::setCacheModelSynchronouslyForTesting(CacheModel cacheModel)
+{
+    for (auto processPool : WebProcessPool::allProcessPools())
+        processPool->setCacheModelSynchronouslyForTesting(cacheModel);
+}
+
 #if !PLATFORM(COCOA)
 WebsiteDataStoreParameters WebsiteDataStore::parameters()
 {

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (252258 => 252259)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2019-11-08 21:26:15 UTC (rev 252259)
@@ -78,6 +78,7 @@
 class WebProcessPool;
 class WebProcessProxy;
 class WebResourceLoadStatisticsStore;
+enum class CacheModel : uint8_t;
 enum class WebsiteDataFetchOption;
 enum class WebsiteDataType;
 struct WebsiteDataRecord;
@@ -138,6 +139,7 @@
     void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, Function<void()>&& completionHandler);
 
     void getLocalStorageDetails(Function<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&&);
+    void setCacheModelSynchronouslyForTesting(CacheModel);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void fetchDataForRegistrableDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<WebCore::RegistrableDomain>&, CompletionHandler<void(Vector<WebsiteDataRecord>&&, HashSet<WebCore::RegistrableDomain>&&)>&&);

Modified: trunk/Tools/ChangeLog (252258 => 252259)


--- trunk/Tools/ChangeLog	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Tools/ChangeLog	2019-11-08 21:26:15 UTC (rev 252259)
@@ -1,3 +1,16 @@
+2019-11-08  Alex Christensen  <[email protected]>
+
+        Fix flaky tests in http/tests/cache/disk-cache
+        https://bugs.webkit.org/show_bug.cgi?id=203822
+
+        Reviewed by Youenn Fablet.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::setCacheModel):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2019-11-08  Aakash Jain  <[email protected]>
 
         Clicking on EWS status-bubble should open the results in new tab

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (252258 => 252259)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2019-11-08 21:26:15 UTC (rev 252259)
@@ -925,7 +925,7 @@
 {
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetCacheModel"));
     WKRetainPtr<WKUInt64Ref> messageBody = adoptWK(WKUInt64Create(model));
-    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
+    WKBundlePagePostSynchronousMessageForTesting(page()->page(), messageName.get(), messageBody.get(), nullptr);
 }
 
 bool InjectedBundle::shouldProcessWorkQueue() const

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (252258 => 252259)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2019-11-08 21:16:35 UTC (rev 252258)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2019-11-08 21:26:15 UTC (rev 252259)
@@ -546,13 +546,6 @@
         return;
     }
 
-    if (WKStringIsEqualToUTF8CString(messageName, "SetCacheModel")) {
-        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
-        uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
-        WKContextSetCacheModel(TestController::singleton().context(), model);
-        return;
-    }
-
     if (WKStringIsEqualToUTF8CString(messageName, "SetCustomPolicyDelegate")) {
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
@@ -879,6 +872,13 @@
         return result;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "SetCacheModel")) {
+        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
+        uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
+        WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController::websiteDataStore(), model);
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "IsWorkQueueEmpty")) {
         bool isEmpty = TestController::singleton().workQueueManager().isWorkQueueEmpty();
         WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isEmpty));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to