Title: [223648] trunk
Revision
223648
Author
[email protected]
Date
2017-10-18 19:14:55 -0700 (Wed, 18 Oct 2017)

Log Message

TestController should clear all fetch caches when resetting its state
https://bugs.webkit.org/show_bug.cgi?id=178486

Patch by Youenn Fablet <[email protected]> on 2017-10-18
Reviewed by Chris Dumez.

Tools:

Adding clearDOMCaches test runner method.
Using that method when resetting state.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::clearDOMCaches):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/cache-storage/cache-clearing-all.https.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (223647 => 223648)


--- trunk/LayoutTests/ChangeLog	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/LayoutTests/ChangeLog	2017-10-19 02:14:55 UTC (rev 223648)
@@ -1,3 +1,12 @@
+2017-10-18  Youenn Fablet  <[email protected]>
+
+        TestController should clear all fetch caches when resetting its state
+        https://bugs.webkit.org/show_bug.cgi?id=178486
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/cache-storage/cache-clearing-all.https.html:
+
 2017-10-18  Dean Jackson  <[email protected]>
 
         Some older hardware can't actually use renderbuffers at the size they advertise

Modified: trunk/LayoutTests/http/tests/cache-storage/cache-clearing-all.https.html (223647 => 223648)


--- trunk/LayoutTests/http/tests/cache-storage/cache-clearing-all.https.html	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/LayoutTests/http/tests/cache-storage/cache-clearing-all.https.html	2017-10-19 02:14:55 UTC (rev 223648)
@@ -22,7 +22,7 @@
 
     if (!window.testRunner)
         return Promise.reject("test runner needed");
-    testRunner.clearDOMCache();
+    testRunner.clearDOMCaches();
 
     var keys = await self.caches.keys();
     assert_equals(keys.length, 0, "keys should be empty");

Modified: trunk/Tools/ChangeLog (223647 => 223648)


--- trunk/Tools/ChangeLog	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/Tools/ChangeLog	2017-10-19 02:14:55 UTC (rev 223648)
@@ -1,3 +1,20 @@
+2017-10-18  Youenn Fablet  <[email protected]>
+
+        TestController should clear all fetch caches when resetting its state
+        https://bugs.webkit.org/show_bug.cgi?id=178486
+
+        Reviewed by Chris Dumez.
+
+        Adding clearDOMCaches test runner method.
+        Using that method when resetting state.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::clearDOMCaches):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2017-10-18  Chelsea Pugh  <[email protected]>
 
         [iOS] Use new class name from UIKit when checking UITextSuggestion type

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (223647 => 223648)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2017-10-19 02:14:55 UTC (rev 223648)
@@ -57,6 +57,7 @@
     void dumpDOMAsWebArchive();
     void dumpPolicyDelegateCallbacks();
 
+    void clearDOMCaches();
     void clearDOMCache(DOMString origin);
     boolean hasDOMCache(DOMString origin);
     unsigned long domCacheSize(DOMString origin);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (223647 => 223648)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2017-10-19 02:14:55 UTC (rev 223648)
@@ -1834,6 +1834,12 @@
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
+void TestRunner::clearDOMCaches()
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ClearDOMCaches"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
+}
+
 bool TestRunner::hasDOMCache(JSStringRef origin)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("HasDOMCache"));

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (223647 => 223648)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2017-10-19 02:14:55 UTC (rev 223648)
@@ -164,6 +164,7 @@
     JSValueRef originsWithApplicationCache();
 
     void clearDOMCache(JSStringRef origin);
+    void clearDOMCaches();
     bool hasDOMCache(JSStringRef origin);
     uint64_t domCacheSize(JSStringRef origin);
 

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (223647 => 223648)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2017-10-19 02:14:55 UTC (rev 223648)
@@ -783,6 +783,8 @@
 
     WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKContextGetWebsiteDataStore(platformContext()));
 
+    clearDOMCaches();
+
     // FIXME: This function should also ensure that there is only one page open.
 
     // Reset the EventSender for each test.
@@ -2322,17 +2324,26 @@
     auto websiteDataStore = WKContextGetWebsiteDataStore(platformContext());
     ClearDOMCacheCallbackContext context(*this);
 
-    if (WKStringIsEmpty(origin))
-        WKWebsiteDataStoreRemoveAllFetchCaches(websiteDataStore, &context, clearDOMCacheCallback);
-    else {
-        auto cacheOrigin = adoptWK(WKSecurityOriginCreateFromString(origin));
-        WKWebsiteDataStoreRemoveFetchCacheForOrigin(websiteDataStore, cacheOrigin.get(), &context, clearDOMCacheCallback);
-    }
+    auto cacheOrigin = adoptWK(WKSecurityOriginCreateFromString(origin));
+    WKWebsiteDataStoreRemoveFetchCacheForOrigin(websiteDataStore, cacheOrigin.get(), &context, clearDOMCacheCallback);
+
     if (!context.done)
         runUntil(context.done, m_currentInvocation->shortTimeout());
 #endif
 }
 
+void TestController::clearDOMCaches()
+{
+#if PLATFORM(COCOA) && WK_API_ENABLED
+    auto websiteDataStore = WKContextGetWebsiteDataStore(platformContext());
+    ClearDOMCacheCallbackContext context(*this);
+
+    WKWebsiteDataStoreRemoveAllFetchCaches(websiteDataStore, &context, clearDOMCacheCallback);
+    if (!context.done)
+        runUntil(context.done, m_currentInvocation->shortTimeout());
+#endif
+}
+
 struct FetchCacheOriginsCallbackContext {
     FetchCacheOriginsCallbackContext(TestController& controller, WKStringRef origin)
         : testController(controller)

Modified: trunk/Tools/WebKitTestRunner/TestController.h (223647 => 223648)


--- trunk/Tools/WebKitTestRunner/TestController.h	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2017-10-19 02:14:55 UTC (rev 223648)
@@ -191,6 +191,7 @@
     void removeAllSessionCredentials();
 
     void clearDOMCache(WKStringRef origin);
+    void clearDOMCaches();
     bool hasDOMCache(WKStringRef origin);
     uint64_t domCacheSize(WKStringRef origin);
 

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (223647 => 223648)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2017-10-19 01:39:14 UTC (rev 223647)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2017-10-19 02:14:55 UTC (rev 223648)
@@ -1210,6 +1210,11 @@
         return nullptr;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "ClearDOMCaches")) {
+        TestController::singleton().clearDOMCaches();
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "HasDOMCache")) {
         ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
         WKStringRef origin = static_cast<WKStringRef>(messageBody);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to