Title: [233946] branches/safari-606-branch
Revision
233946
Author
bshaf...@apple.com
Date
2018-07-18 18:59:12 -0700 (Wed, 18 Jul 2018)

Log Message

Cherry-pick r233853. rdar://problem/42344991

    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):

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

Modified Paths

Diff

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (233945 => 233946)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-19 01:19:40 UTC (rev 233945)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-19 01:59:12 UTC (rev 233946)
@@ -1,3 +1,59 @@
+2018-07-18  Babak Shafiei  <bshaf...@apple.com>
+
+        Cherry-pick r233853. rdar://problem/42344991
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233853 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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: branches/safari-606-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (233945 => 233946)


--- branches/safari-606-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2018-07-19 01:19:40 UTC (rev 233945)
+++ branches/safari-606-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2018-07-19 01:59:12 UTC (rev 233946)
@@ -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: branches/safari-606-branch/Source/WebKit/ChangeLog (233945 => 233946)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-19 01:19:40 UTC (rev 233945)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-19 01:59:12 UTC (rev 233946)
@@ -1,3 +1,58 @@
+2018-07-18  Babak Shafiei  <bshaf...@apple.com>
+
+        Cherry-pick r233853. rdar://problem/42344991
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233853 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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: branches/safari-606-branch/Source/WebKit/StorageProcess/StorageProcess.cpp (233945 => 233946)


--- branches/safari-606-branch/Source/WebKit/StorageProcess/StorageProcess.cpp	2018-07-19 01:19:40 UTC (rev 233945)
+++ branches/safari-606-branch/Source/WebKit/StorageProcess/StorageProcess.cpp	2018-07-19 01:59:12 UTC (rev 233946)
@@ -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: branches/safari-606-branch/Source/WebKit/StorageProcess/StorageProcess.h (233945 => 233946)


--- branches/safari-606-branch/Source/WebKit/StorageProcess/StorageProcess.h	2018-07-19 01:19:40 UTC (rev 233945)
+++ branches/safari-606-branch/Source/WebKit/StorageProcess/StorageProcess.h	2018-07-19 01:59:12 UTC (rev 233946)
@@ -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: branches/safari-606-branch/Tools/ChangeLog (233945 => 233946)


--- branches/safari-606-branch/Tools/ChangeLog	2018-07-19 01:19:40 UTC (rev 233945)
+++ branches/safari-606-branch/Tools/ChangeLog	2018-07-19 01:59:12 UTC (rev 233946)
@@ -1,3 +1,53 @@
+2018-07-18  Babak Shafiei  <bshaf...@apple.com>
+
+        Cherry-pick r233853. rdar://problem/42344991
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233853 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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: branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (233945 => 233946)


--- branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2018-07-19 01:19:40 UTC (rev 233945)
+++ branches/safari-606-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2018-07-19 01:59:12 UTC (rev 233946)
@@ -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