Title: [233853] trunk
Revision
233853
Author
sihui_...@apple.com
Date
2018-07-16 11:35:50 -0700 (Mon, 16 Jul 2018)

Log Message

IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
https://bugs.webkit.org/show_bug.cgi?id=187631
<rdar://problem/42164227>

Reviewed by Brady Eidson.

Source/WebCore:

When asked to delete database for an origin, we deleted the databases whose mainFrameOrigin
is that origin. Given that the origin may create IndexedDB from subframes, we should delete
databases whose openingOrigin is that origin too.

Covered by modified API test: WebKit.WebsiteDataStoreCustomPaths.

* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::performCloseAndDeleteDatabasesForOrigins):

Source/WebKit:

We need to return all origins, both openingOrigin and mainFrameOrigin, of IndexedDB so users
could be better aware of which origins are using databases and decide what they want to
remove.

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::indexedDatabaseOrigins):
* StorageProcess/StorageProcess.h:

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233852 => 233853)


--- trunk/Source/WebCore/ChangeLog	2018-07-16 18:28:54 UTC (rev 233852)
+++ trunk/Source/WebCore/ChangeLog	2018-07-16 18:35:50 UTC (rev 233853)
@@ -1,3 +1,20 @@
+2018-07-16  Sihui Liu  <sihui_...@apple.com>
+
+        IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
+        https://bugs.webkit.org/show_bug.cgi?id=187631
+        <rdar://problem/42164227>
+
+        Reviewed by Brady Eidson.
+
+        When asked to delete database for an origin, we deleted the databases whose mainFrameOrigin 
+        is that origin. Given that the origin may create IndexedDB from subframes, we should delete 
+        databases whose openingOrigin is that origin too.
+
+        Covered by modified API test: WebKit.WebsiteDataStoreCustomPaths. 
+
+        * Modules/indexeddb/server/IDBServer.cpp:
+        (WebCore::IDBServer::IDBServer::performCloseAndDeleteDatabasesForOrigins):
+
 2018-07-16  Simon Fraser  <simon.fra...@apple.com>
 
         Shrink some font-related classes and enums

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (233852 => 233853)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2018-07-16 18:28:54 UTC (rev 233852)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2018-07-16 18:35:50 UTC (rev 233853)
@@ -626,6 +626,11 @@
         for (const auto& origin : origins) {
             String originPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, origin.databaseIdentifier());
             removeAllDatabasesForOriginPath(originPath, -WallTime::infinity());
+
+            for (const auto& topOriginPath : FileSystem::listDirectory(m_databaseDirectoryPath, "*")) {
+                originPath = FileSystem::pathByAppendingComponent(topOriginPath, origin.databaseIdentifier());
+                removeAllDatabasesForOriginPath(originPath, -WallTime::infinity());
+            }
         }
     }
 

Modified: trunk/Source/WebKit/ChangeLog (233852 => 233853)


--- trunk/Source/WebKit/ChangeLog	2018-07-16 18:28:54 UTC (rev 233852)
+++ trunk/Source/WebKit/ChangeLog	2018-07-16 18:35:50 UTC (rev 233853)
@@ -1,3 +1,19 @@
+2018-07-16  Sihui Liu  <sihui_...@apple.com>
+
+        IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
+        https://bugs.webkit.org/show_bug.cgi?id=187631
+        <rdar://problem/42164227>
+
+        Reviewed by Brady Eidson.
+
+        We need to return all origins, both openingOrigin and mainFrameOrigin, of IndexedDB so users
+        could be better aware of which origins are using databases and decide what they want to 
+        remove.
+
+        * StorageProcess/StorageProcess.cpp:
+        (WebKit::StorageProcess::indexedDatabaseOrigins):
+        * StorageProcess/StorageProcess.h:
+
 2018-07-15  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [SOUP] http/tests/misc/bubble-drag-events.html crashes

Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.cpp (233852 => 233853)


--- trunk/Source/WebKit/StorageProcess/StorageProcess.cpp	2018-07-16 18:28:54 UTC (rev 233852)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.cpp	2018-07-16 18:35:50 UTC (rev 233853)
@@ -406,17 +406,22 @@
         extension->revoke();
 }
 
-Vector<WebCore::SecurityOriginData> StorageProcess::indexedDatabaseOrigins(const String& path)
+HashSet<WebCore::SecurityOriginData> StorageProcess::indexedDatabaseOrigins(const String& path)
 {
     if (path.isEmpty())
         return { };
 
-    Vector<WebCore::SecurityOriginData> securityOrigins;
-    for (auto& originPath : FileSystem::listDirectory(path, "*")) {
-        String databaseIdentifier = FileSystem::pathGetFileName(originPath);
-
+    HashSet<WebCore::SecurityOriginData> securityOrigins;
+    for (auto& topOriginPath : FileSystem::listDirectory(path, "*")) {
+        auto databaseIdentifier = FileSystem::pathGetFileName(topOriginPath);
         if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
-            securityOrigins.append(WTFMove(*securityOrigin));
+            securityOrigins.add(WTFMove(*securityOrigin));
+        
+        for (auto& originPath : FileSystem::listDirectory(topOriginPath, "*")) {
+            databaseIdentifier = FileSystem::pathGetFileName(originPath);
+            if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
+                securityOrigins.add(WTFMove(*securityOrigin));
+        }
     }
 
     return securityOrigins;

Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.h (233852 => 233853)


--- trunk/Source/WebKit/StorageProcess/StorageProcess.h	2018-07-16 18:28:54 UTC (rev 233852)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.h	2018-07-16 18:35:50 UTC (rev 233853)
@@ -155,7 +155,7 @@
     bool needsServerToContextConnectionForOrigin(const WebCore::SecurityOriginData&) const;
 #endif
 #if ENABLE(INDEXED_DATABASE)
-    Vector<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path);
+    HashSet<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path);
 #endif
 
     // For execution on work queue thread only

Modified: trunk/Tools/ChangeLog (233852 => 233853)


--- trunk/Tools/ChangeLog	2018-07-16 18:28:54 UTC (rev 233852)
+++ trunk/Tools/ChangeLog	2018-07-16 18:35:50 UTC (rev 233853)
@@ -1,3 +1,14 @@
+2018-07-16  Sihui Liu  <sihui_...@apple.com>
+
+        IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
+        https://bugs.webkit.org/show_bug.cgi?id=187631
+        <rdar://problem/42164227>
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+        (TEST):
+
 2018-07-15  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GLIB] Add API to evaluate code using a given object to store global symbols

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (233852 => 233853)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2018-07-16 18:28:54 UTC (rev 233852)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2018-07-16 18:35:50 UTC (rev 233853)
@@ -190,10 +190,31 @@
     [[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];
+    
+    [[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:[NSArray arrayWithObject:record] completionHandler:^() {
+                    receivedScriptMessage = true;
+                    EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:frameIDBPath.get().path]);
+                }];
+            }
+        }
+    }];
     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]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to