REGRESSION(r244162) Clearing website data from ephemeral WKWebsiteDataStore should...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2019 00:18:11 +0000 (00:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2019 00:18:11 +0000 (00:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196995

Patch by Alex Christensen <achristensen@webkit.org> on 2019-04-16
Reviewed by Brady Eidson.

Source/WebKit:

Always call CompletionHandlers.  Otherwise things hang or assert.
I added an API test that asserts without this change so we don't regress this again.

* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::clearAllCaches):
(WebKit::CacheStorage::Engine::clearCachesForOrigin):

Tools:

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

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

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm

index 9bf6a91..1e6d723 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-16  Alex Christensen  <achristensen@webkit.org>
+
+        REGRESSION(r244162) Clearing website data from ephemeral WKWebsiteDataStore should finish instead of asserting or hanging
+        https://bugs.webkit.org/show_bug.cgi?id=196995
+
+        Reviewed by Brady Eidson.
+
+        Always call CompletionHandlers.  Otherwise things hang or assert.
+        I added an API test that asserts without this change so we don't regress this again.
+
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::Engine::clearAllCaches):
+        (WebKit::CacheStorage::Engine::clearCachesForOrigin):
+
 2019-04-16  Chris Dumez  <cdumez@apple.com>
 
         URL set by document.open() is not communicated to the UIProcess
index b3332f9..d90c70f 100644 (file)
@@ -525,7 +525,7 @@ void Engine::clearAllCaches(CompletionHandler<void()>&& completionHandler)
 
     auto callbackAggregator = CallbackAggregator::create([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
         if (!this->shouldPersist())
-            return;
+            return completionHandler();
         
         this->clearAllCachesFromDisk(WTFMove(completionHandler));
     });
@@ -553,7 +553,7 @@ void Engine::clearCachesForOrigin(const WebCore::SecurityOriginData& origin, Com
 
     auto callbackAggregator = CallbackAggregator::create([this, protectedThis = makeRef(*this), origin, completionHandler = WTFMove(completionHandler)]() mutable {
         if (!this->shouldPersist())
-            return;
+            return completionHandler();
 
         this->clearCachesForOriginFromDisk(origin, [completionHandler = WTFMove(completionHandler)]() mutable {
             completionHandler();
index a10cd16..e7286be 100644 (file)
@@ -1,3 +1,13 @@
+2019-04-16  Alex Christensen  <achristensen@webkit.org>
+
+        REGRESSION(r244162) Clearing website data from ephemeral WKWebsiteDataStore should finish instead of asserting or hanging
+        https://bugs.webkit.org/show_bug.cgi?id=196995
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
+        (TEST):
+
 2019-04-16  Chris Dumez  <cdumez@apple.com>
 
         URL set by document.open() is not communicated to the UIProcess
index 3c3b8a2..183233a 100644 (file)
@@ -27,6 +27,7 @@
 
 #import "PlatformUtilities.h"
 #import "Test.h"
+#import "TestWKWebView.h"
 #import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <wtf/text/WTFString.h>
@@ -48,3 +49,16 @@ TEST(WKWebsiteDataStore, RemoveAndFetchData)
     }];
     TestWebKitAPI::Util::run(&readyToContinue);
 }
+
+TEST(WKWebsiteDataStore, RemoveEphemeralData)
+{
+    auto configuration = adoptNS([WKWebViewConfiguration new]);
+    [configuration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+    __block bool done = false;
+    [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler: ^{
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+}