Title: [290739] trunk
Revision
290739
Author
[email protected]
Date
2022-03-02 10:59:55 -0800 (Wed, 02 Mar 2022)

Log Message

Add assertion that no two sessions share the same general storage directory
https://bugs.webkit.org/show_bug.cgi?id=236844
<rdar://problem/89178566>

Reviewed by Chris Dumez.

Source/WebKit:

rdar://89190571 shows that there can be two WebsiteDataStores using the same general storage directory, when
initializing network process. This can lead to corruption because storage code of each session runs on its own
WorkQueue (or thread) in network process. If two sessions (WebsiteDataStores) use the same directory, the
directory and its files may be accessed concurrently. The correct usage is creating different persistent
sessions with different paths. Let's add an assertion to help find problematic use case.

* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::parameters):
* UIProcess/WebsiteData/WebsiteDataStore.h:
(WebKit::WebsiteDataStore::cacheStorageDirectory const):
(WebKit::WebsiteDataStore::resolvedGeneralStorageDirectory const):
(WebKit::WebsiteDataStore::generalStorageDirectory const): Deleted.

Tools:

Update the tests where two WebsiteDataStores are created with the same general storage directory.

* TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm:
(emptyObservationsDBPath):
(emptyPcmDBPath):
(cleanUp):
* TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm:
* TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
* TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
(runWebsiteDataStoreCustomPaths):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (290738 => 290739)


--- trunk/Source/WebKit/ChangeLog	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Source/WebKit/ChangeLog	2022-03-02 18:59:55 UTC (rev 290739)
@@ -1,3 +1,26 @@
+2022-03-02  Sihui Liu  <[email protected]>
+
+        Add assertion that no two sessions share the same general storage directory
+        https://bugs.webkit.org/show_bug.cgi?id=236844
+        <rdar://problem/89178566>
+
+        Reviewed by Chris Dumez.
+
+        rdar://89190571 shows that there can be two WebsiteDataStores using the same general storage directory, when
+        initializing network process. This can lead to corruption because storage code of each session runs on its own
+        WorkQueue (or thread) in network process. If two sessions (WebsiteDataStores) use the same directory, the 
+        directory and its files may be accessed concurrently. The correct usage is creating different persistent 
+        sessions with different paths. Let's add an assertion to help find problematic use case.
+
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::parameters):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        (WebKit::WebsiteDataStore::cacheStorageDirectory const):
+        (WebKit::WebsiteDataStore::resolvedGeneralStorageDirectory const):
+        (WebKit::WebsiteDataStore::generalStorageDirectory const): Deleted.
+
 2022-03-02  Youenn Fablet  <[email protected]>
 
         Rename MediaSampleAVFObjC::createImageSample to MediaSampleAVFObjC::createFromPixelBuffer

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (290738 => 290739)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-03-02 18:59:55 UTC (rev 290739)
@@ -211,7 +211,16 @@
 
 #if !PLATFORM(GTK) && !PLATFORM(WPE) // GTK and WPE don't use defaultNetworkProcess
     parameters.websiteDataStoreParameters = WebsiteDataStore::parametersFromEachWebsiteDataStore();
-    WebsiteDataStore::forEachWebsiteDataStore([this](auto& websiteDataStore) {
+    HashMap<String, PAL::SessionID> sessionForDirectory;
+    WebsiteDataStore::forEachWebsiteDataStore([&](auto& websiteDataStore) {
+        if (websiteDataStore.isPersistent()) {
+            if (auto directory = websiteDataStore.resolvedGeneralStorageDirectory(); !directory.isEmpty()) {
+                auto sessionID = websiteDataStore.sessionID();
+                // Persistent sessions sharing same storage directory may cause corruption.
+                // If the assertion is hit, check if you have multiple WebsiteDataStores with the same generalStorageDirectory.
+                RELEASE_ASSERT_WITH_MESSAGE(sessionForDirectory.add(directory, sessionID).isNewEntry, "GeneralStorageDirectory for session %" PRIu64 " is already in use by session %" PRIu64, sessionForDirectory.get(directory).toUInt64(), sessionID.toUInt64());
+            }
+        }
         addSession(websiteDataStore, SendParametersToNetworkProcess::No);
     });
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (290738 => 290739)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-03-02 18:59:55 UTC (rev 290739)
@@ -1882,7 +1882,7 @@
             parameters.cacheStorageDirectoryExtensionHandle = WTFMove(*handle);
     }
 
-    if (auto directory = generalStorageDirectory(); !directory.isEmpty()) {
+    if (auto directory = resolvedGeneralStorageDirectory(); !directory.isEmpty()) {
         parameters.generalStorageDirectory = directory;
         if (auto handle = SandboxExtension::createHandleForReadWriteDirectory(directory))
             parameters.generalStorageDirectoryHandle = WTFMove(*handle);

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (290738 => 290739)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2022-03-02 18:59:55 UTC (rev 290739)
@@ -159,7 +159,6 @@
     uint64_t perOriginStorageQuota() const { return m_resolvedConfiguration->perOriginStorageQuota(); }
     uint64_t perThirdPartyOriginStorageQuota() const;
     const String& cacheStorageDirectory() const { return m_resolvedConfiguration->cacheStorageDirectory(); }
-    const String& generalStorageDirectory() const { return m_resolvedConfiguration->generalStorageDirectory(); }
 
 #if ENABLE(INTELLIGENT_TRACKING_PREVENTION)
     void clearResourceLoadStatisticsInWebProcesses(CompletionHandler<void()>&&);
@@ -258,6 +257,7 @@
     const String& resolvedServiceWorkerRegistrationDirectory() const { return m_resolvedConfiguration->serviceWorkerRegistrationDirectory(); }
     const String& resolvedResourceLoadStatisticsDirectory() const { return m_resolvedConfiguration->resourceLoadStatisticsDirectory(); }
     const String& resolvedHSTSStorageDirectory() const { return m_resolvedConfiguration->hstsStorageDirectory(); }
+    const String& resolvedGeneralStorageDirectory() const { return m_resolvedConfiguration->generalStorageDirectory(); }
 #if ENABLE(ARKIT_INLINE_PREVIEW)
     const String& resolvedModelElementCacheDirectory() const { return m_resolvedConfiguration->modelElementCacheDirectory(); }
 #endif

Modified: trunk/Tools/ChangeLog (290738 => 290739)


--- trunk/Tools/ChangeLog	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Tools/ChangeLog	2022-03-02 18:59:55 UTC (rev 290739)
@@ -1,5 +1,26 @@
 2022-03-02  Sihui Liu  <[email protected]>
 
+        Add assertion that no two sessions share the same general storage directory
+        https://bugs.webkit.org/show_bug.cgi?id=236844
+        <rdar://problem/89178566>
+
+        Reviewed by Chris Dumez.
+
+        Update the tests where two WebsiteDataStores are created with the same general storage directory.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm:
+        (emptyObservationsDBPath):
+        (emptyPcmDBPath):
+        (cleanUp):
+        * TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+        (runWebsiteDataStoreCustomPaths):
+
+2022-03-02  Sihui Liu  <[email protected]>
+
         Add test coverage for deleting FileSystem data when file is being written
         https://bugs.webkit.org/show_bug.cgi?id=237353
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm (290738 => 290739)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PrivateClickMeasurement.mm	2022-03-02 18:59:55 UTC (rev 290739)
@@ -292,7 +292,8 @@
 static NSString *emptyObservationsDBPath()
 {
     NSFileManager *defaultFileManager = NSFileManager.defaultManager;
-    NSURL *itpRootURL = WKWebsiteDataStore.defaultDataStore._configuration._resourceLoadStatisticsDirectory;
+    auto dataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+    NSURL *itpRootURL = dataStoreConfiguration.get()._resourceLoadStatisticsDirectory;
     NSURL *fileURL = [itpRootURL URLByAppendingPathComponent:@"observations.db"];
     [defaultFileManager removeItemAtPath:itpRootURL.path error:nil];
     EXPECT_FALSE([defaultFileManager fileExistsAtPath:itpRootURL.path]);
@@ -303,7 +304,8 @@
 static NSString *emptyPcmDBPath()
 {
     NSFileManager *defaultFileManager = NSFileManager.defaultManager;
-    NSURL *itpRootURL = WKWebsiteDataStore.defaultDataStore._configuration._resourceLoadStatisticsDirectory;
+    auto dataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+    NSURL *itpRootURL = dataStoreConfiguration.get()._resourceLoadStatisticsDirectory;
     NSURL *fileURL = [itpRootURL URLByAppendingPathComponent:@"pcm.db"];
     [defaultFileManager removeItemAtPath:itpRootURL.path error:nil];
     EXPECT_FALSE([defaultFileManager fileExistsAtPath:itpRootURL.path]);
@@ -316,7 +318,8 @@
     static bool isDone = false;
     [[webView.get() configuration].websiteDataStore _closeDatabases:^{
         NSFileManager *defaultFileManager = NSFileManager.defaultManager;
-        NSString *itpRoot = WKWebsiteDataStore.defaultDataStore._configuration._resourceLoadStatisticsDirectory.path;
+        auto dataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+        NSString *itpRoot = dataStoreConfiguration.get()._resourceLoadStatisticsDirectory.path;
         [defaultFileManager removeItemAtPath:itpRoot error:nil];
         while ([defaultFileManager fileExistsAtPath:itpRoot])
             usleep(10000);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm (290738 => 290739)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm	2022-03-02 18:59:55 UTC (rev 290739)
@@ -107,7 +107,7 @@
 static void clearWebsiteDataStore(WKWebsiteDataStore *store)
 {
     __block bool clearedStore = false;
-    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+    [store removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
         clearedStore = true;
     }];
     TestWebKitAPI::Util::run(&clearedStore);
@@ -323,14 +323,13 @@
     [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
 
     expectedMessage = "Ready";
-    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-    [webView loadRequest:server.request()];
 
-    TestWebKitAPI::Util::run(&done);
+    @autoreleasepool {
+        auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+        [webView loadRequest:server.request()];
+        TestWebKitAPI::Util::run(&done);
+    }
 
-    [webView _close];
-    webView = nullptr;
-
     [dataStoreConfiguration setServiceWorkerProcessTerminationDelayEnabled:NO];
     dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]);
     configuration.get().websiteDataStore = dataStore.get();

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm (290738 => 290739)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm	2022-03-02 18:59:55 UTC (rev 290739)
@@ -1086,8 +1086,11 @@
 TEST(ResourceLoadStatistics, StoreSuspension)
 {
     auto *sharedProcessPool = [WKProcessPool _sharedProcessPool];
-    auto *dataStore1 = [WKWebsiteDataStore defaultDataStore];
-    auto dataStore2 = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]).get()]);
+    auto dataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+    auto customGeneralStorageDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@%@", dataStoreConfiguration.get().generalStorageDirectory.path, @"_Custom"]];
+    auto dataStore1 = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]);
+    dataStoreConfiguration.get().generalStorageDirectory = customGeneralStorageDirectory;
+    auto dataStore2 = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]);
 
     [dataStore1 _setResourceLoadStatisticsEnabled:YES];
     [dataStore2 _setResourceLoadStatisticsEnabled:YES];
@@ -1094,7 +1097,7 @@
 
     auto configuration1 = adoptNS([[WKWebViewConfiguration alloc] init]);
     [configuration1 setProcessPool: sharedProcessPool];
-    configuration1.get().websiteDataStore = dataStore1;
+    configuration1.get().websiteDataStore = dataStore1.get();
 
     auto configuration2 = adoptNS([[WKWebViewConfiguration alloc] init]);
     [configuration2 setProcessPool: sharedProcessPool];

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm (290738 => 290739)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm	2022-03-02 18:59:55 UTC (rev 290739)
@@ -390,7 +390,7 @@
 static void clearWebsiteDataStore(WKWebsiteDataStore *store)
 {
     __block bool clearedStore = false;
-    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+    [store removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
         clearedStore = true;
     }];
     TestWebKitAPI::Util::run(&clearedStore);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (290738 => 290739)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2022-03-02 18:53:56 UTC (rev 290738)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2022-03-02 18:59:55 UTC (rev 290739)
@@ -187,86 +187,70 @@
     RetainPtr<NSURL> fileIDBPath = [[idbPath URLByAppendingPathComponent:@"v1"] URLByAppendingPathComponent:@"file__0"];
     EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:fileIDBPath.get().path]);
 
-    auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]);
-    RetainPtr<NSSet> types = adoptNS([[NSSet alloc] initWithObjects:WKWebsiteDataTypeIndexedDBDatabases, nil]);
+    @autoreleasepool {
+        auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]);
+        RetainPtr<NSSet> types = adoptNS([[NSSet alloc] initWithObjects:WKWebsiteDataTypeIndexedDBDatabases, nil]);
 
-    // Subframe of different origins may also create IndexedDB files.
-    RetainPtr<NSURL> url1 = [[NSBundle mainBundle] URLForResource:@"IndexedDB" withExtension:@"sqlite3" subdirectory:@"TestWebKitAPI.resources"];
-    RetainPtr<NSURL> url2 = [[NSBundle mainBundle] URLForResource:@"IndexedDB" withExtension:@"sqlite3-shm" subdirectory:@"TestWebKitAPI.resources"];
-    RetainPtr<NSURL> url3 = [[NSBundle mainBundle] URLForResource:@"IndexedDB" withExtension:@"sqlite3-wal" subdirectory:@"TestWebKitAPI.resources"];
+        // Subframe of different origins may also create IndexedDB files.
+        RetainPtr<NSURL> url1 = [[NSBundle mainBundle] URLForResource:@"IndexedDB" withExtension:@"sqlite3" subdirectory:@"TestWebKitAPI.resources"];
+        RetainPtr<NSURL> url2 = [[NSBundle mainBundle] URLForResource:@"IndexedDB" withExtension:@"sqlite3-shm" subdirectory:@"TestWebKitAPI.resources"];
+        RetainPtr<NSURL> url3 = [[NSBundle mainBundle] URLForResource:@"IndexedDB" withExtension:@"sqlite3-wal" subdirectory:@"TestWebKitAPI.resources"];
 
-    RetainPtr<NSURL> frameIDBPath = [[fileIDBPath URLByAppendingPathComponent:@"https_apple.com_0"] URLByAppendingPathComponent:@"WebsiteDataStoreCustomPaths"];
-    [[NSFileManager defaultManager] createDirectoryAtURL:frameIDBPath.get() withIntermediateDirectories:YES attributes:nil error:nil];
+        RetainPtr<NSURL> frameIDBPath = [[fileIDBPath URLByAppendingPathComponent:@"https_apple.com_0"] URLByAppendingPathComponent:@"WebsiteDataStoreCustomPaths"];
+        [[NSFileManager defaultManager] createDirectoryAtURL:frameIDBPath.get() withIntermediateDirectories:YES attributes:nil error:nil];
 
-    [[NSFileManager defaultManager] copyItemAtURL:url1.get() toURL:[frameIDBPath.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3"] error:nil];
-    [[NSFileManager defaultManager] copyItemAtURL:url2.get() toURL:[frameIDBPath.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-shm"] error:nil];
-    [[NSFileManager defaultManager] copyItemAtURL:url3.get() toURL:[frameIDBPath.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-wal"] error:nil];
+        [[NSFileManager defaultManager] copyItemAtURL:url1.get() toURL:[frameIDBPath.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3"] error:nil];
+        [[NSFileManager defaultManager] copyItemAtURL:url2.get() toURL:[frameIDBPath.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-shm"] error:nil];
+        [[NSFileManager defaultManager] copyItemAtURL:url3.get() toURL:[frameIDBPath.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-wal"] error:nil];
 
-    RetainPtr<NSURL> frameIDBPath2 = [[fileIDBPath URLByAppendingPathComponent:@"https_webkit.org_0"] URLByAppendingPathComponent:@"WebsiteDataStoreCustomPaths"];
-    [[NSFileManager defaultManager] createDirectoryAtURL:frameIDBPath2.get() withIntermediateDirectories:YES attributes:nil error:nil];
+        RetainPtr<NSURL> frameIDBPath2 = [[fileIDBPath URLByAppendingPathComponent:@"https_webkit.org_0"] URLByAppendingPathComponent:@"WebsiteDataStoreCustomPaths"];
+        [[NSFileManager defaultManager] createDirectoryAtURL:frameIDBPath2.get() withIntermediateDirectories:YES attributes:nil error:nil];
 
-    [[NSFileManager defaultManager] copyItemAtURL:url1.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3"] error:nil];
-    [[NSFileManager defaultManager] copyItemAtURL:url2.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-shm"] error:nil];
-    [[NSFileManager defaultManager] copyItemAtURL:url3.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-wal"] error:nil];
+        [[NSFileManager defaultManager] copyItemAtURL:url1.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3"] error:nil];
+        [[NSFileManager defaultManager] copyItemAtURL:url2.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-shm"] error:nil];
+        [[NSFileManager defaultManager] copyItemAtURL:url3.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-wal"] error:nil];
 
-    [dataStore fetchDataRecordsOfTypes:types.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> * records) {
-        EXPECT_EQ([records count], (unsigned long)3);
-        for (id record in records) {
-            if ([[record displayName] isEqual: @"apple.com"]) {
-                [dataStore removeDataOfTypes:types.get() forDataRecords:@[record] completionHandler:^() {
-                    receivedScriptMessage = true;
-                    EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:frameIDBPath.get().path]);
-                }];
+        [dataStore fetchDataRecordsOfTypes:types.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> * records) {
+            EXPECT_EQ([records count], (unsigned long)3);
+            for (id record in records) {
+                if ([[record displayName] isEqual: @"apple.com"]) {
+                    [dataStore removeDataOfTypes:types.get() forDataRecords:@[record] completionHandler:^() {
+                        receivedScriptMessage = true;
+                        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:frameIDBPath.get().path]);
+                    }];
+                }
             }
-        }
-    }];
-    receivedScriptMessage = false;
-    TestWebKitAPI::Util::run(&receivedScriptMessage);
+        }];
+        receivedScriptMessage = false;
+        TestWebKitAPI::Util::run(&receivedScriptMessage);
 
-    [dataStore removeDataOfTypes:types.get() modifiedSince:[NSDate distantPast] completionHandler:[]() {
-        receivedScriptMessage = true;
-    }];
-    receivedScriptMessage = false;
-    TestWebKitAPI::Util::run(&receivedScriptMessage);
+        [dataStore removeDataOfTypes:types.get() modifiedSince:[NSDate distantPast] completionHandler:[]() {
+            receivedScriptMessage = true;
+        }];
+        receivedScriptMessage = false;
+        TestWebKitAPI::Util::run(&receivedScriptMessage);
 
-    EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fileIDBPath.get().path]);
+        EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fileIDBPath.get().path]);
 
-    // Now, with brand new WKWebsiteDataStores pointing at the same custom cookie storage location,
-    // in newly fired up NetworkProcesses, verify that the fetch and delete APIs work as expected.
+        // Now, with brand new WKWebsiteDataStores pointing at the same custom cookie storage location,
+        // in newly fired up NetworkProcesses, verify that the fetch and delete APIs work as expected.
+        [dataStore _terminateNetworkProcess];
+    }
 
-    [dataStore _terminateNetworkProcess];
     auto newCustomDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]);
-
     [newCustomDataStore fetchDataRecordsOfTypes:[NSSet setWithObjects:WKWebsiteDataTypeCookies, nil] completionHandler:^(NSArray<WKWebsiteDataRecord *> * records) {
         EXPECT_GT([records count], (unsigned long)0);
         receivedScriptMessage = true;
     }];
-
     receivedScriptMessage = false;
     TestWebKitAPI::Util::run(&receivedScriptMessage);
 
-    [dataStore _terminateNetworkProcess];
-    newCustomDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]);
-
     [newCustomDataStore removeDataOfTypes:[NSSet setWithObjects:WKWebsiteDataTypeCookies, nil] modifiedSince:[NSDate distantPast] completionHandler:^ {
         receivedScriptMessage = true;
     }];
-
     receivedScriptMessage = false;
     TestWebKitAPI::Util::run(&receivedScriptMessage);
 
-    // This time, reuse the same network process but still do a new websitedatastore, to make sure even an existing network process
-    // gets the new datastore.
-    newCustomDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]);
-
-    [newCustomDataStore fetchDataRecordsOfTypes:[NSSet setWithObjects:WKWebsiteDataTypeCookies, nil] completionHandler:^(NSArray<WKWebsiteDataRecord *> * records) {
-        EXPECT_EQ([records count], (unsigned long)0);
-        receivedScriptMessage = true;
-    }];
-
-    receivedScriptMessage = false;
-    TestWebKitAPI::Util::run(&receivedScriptMessage);
-
     EXPECT_FALSE([WKWebsiteDataStore _defaultDataStoreExists]);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to