Changeset 233853 in webkit


Ignore:
Timestamp:
Jul 16, 2018, 11:35:50 AM (7 years ago)
Author:
sihui_liu@apple.com
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):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r233851 r233853  
     12018-07-16  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
     4        https://bugs.webkit.org/show_bug.cgi?id=187631
     5        <rdar://problem/42164227>
     6
     7        Reviewed by Brady Eidson.
     8
     9        When asked to delete database for an origin, we deleted the databases whose mainFrameOrigin
     10        is that origin. Given that the origin may create IndexedDB from subframes, we should delete
     11        databases whose openingOrigin is that origin too.
     12
     13        Covered by modified API test: WebKit.WebsiteDataStoreCustomPaths.
     14
     15        * Modules/indexeddb/server/IDBServer.cpp:
     16        (WebCore::IDBServer::IDBServer::performCloseAndDeleteDatabasesForOrigins):
     17
    1182018-07-16  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

    r233777 r233853  
    627627            String originPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, origin.databaseIdentifier());
    628628            removeAllDatabasesForOriginPath(originPath, -WallTime::infinity());
     629
     630            for (const auto& topOriginPath : FileSystem::listDirectory(m_databaseDirectoryPath, "*")) {
     631                originPath = FileSystem::pathByAppendingComponent(topOriginPath, origin.databaseIdentifier());
     632                removeAllDatabasesForOriginPath(originPath, -WallTime::infinity());
     633            }
    629634        }
    630635    }
  • trunk/Source/WebKit/ChangeLog

    r233842 r233853  
     12018-07-16  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
     4        https://bugs.webkit.org/show_bug.cgi?id=187631
     5        <rdar://problem/42164227>
     6
     7        Reviewed by Brady Eidson.
     8
     9        We need to return all origins, both openingOrigin and mainFrameOrigin, of IndexedDB so users
     10        could be better aware of which origins are using databases and decide what they want to
     11        remove.
     12
     13        * StorageProcess/StorageProcess.cpp:
     14        (WebKit::StorageProcess::indexedDatabaseOrigins):
     15        * StorageProcess/StorageProcess.h:
     16
    1172018-07-15  Carlos Garcia Campos  <cgarcia@igalia.com>
    218
  • trunk/Source/WebKit/StorageProcess/StorageProcess.cpp

    r233807 r233853  
    407407}
    408408
    409 Vector<WebCore::SecurityOriginData> StorageProcess::indexedDatabaseOrigins(const String& path)
     409HashSet<WebCore::SecurityOriginData> StorageProcess::indexedDatabaseOrigins(const String& path)
    410410{
    411411    if (path.isEmpty())
    412412        return { };
    413413
    414     Vector<WebCore::SecurityOriginData> securityOrigins;
    415     for (auto& originPath : FileSystem::listDirectory(path, "*")) {
    416         String databaseIdentifier = FileSystem::pathGetFileName(originPath);
    417 
     414    HashSet<WebCore::SecurityOriginData> securityOrigins;
     415    for (auto& topOriginPath : FileSystem::listDirectory(path, "*")) {
     416        auto databaseIdentifier = FileSystem::pathGetFileName(topOriginPath);
    418417        if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
    419             securityOrigins.append(WTFMove(*securityOrigin));
     418            securityOrigins.add(WTFMove(*securityOrigin));
     419       
     420        for (auto& originPath : FileSystem::listDirectory(topOriginPath, "*")) {
     421            databaseIdentifier = FileSystem::pathGetFileName(originPath);
     422            if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
     423                securityOrigins.add(WTFMove(*securityOrigin));
     424        }
    420425    }
    421426
  • trunk/Source/WebKit/StorageProcess/StorageProcess.h

    r232891 r233853  
    156156#endif
    157157#if ENABLE(INDEXED_DATABASE)
    158     Vector<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path);
     158    HashSet<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path);
    159159#endif
    160160
  • trunk/Tools/ChangeLog

    r233844 r233853  
     12018-07-16  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
     4        https://bugs.webkit.org/show_bug.cgi?id=187631
     5        <rdar://problem/42164227>
     6
     7        Reviewed by Brady Eidson.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
     10        (TEST):
     11
    1122018-07-15  Carlos Garcia Campos  <cgarcia@igalia.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm

    r233798 r233853  
    191191    [[NSFileManager defaultManager] copyItemAtURL:url3.get() toURL:[frameIDBPath.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-wal"] error:nil];
    192192   
     193    RetainPtr<NSURL> frameIDBPath2 = [[fileIDBPath URLByAppendingPathComponent:@"https_webkit.org_0"] URLByAppendingPathComponent:@"WebsiteDataStoreCustomPaths"];
     194    [[NSFileManager defaultManager] createDirectoryAtURL:frameIDBPath2.get() withIntermediateDirectories:YES attributes:nil error:nil];
     195   
     196    [[NSFileManager defaultManager] copyItemAtURL:url1.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3"] error:nil];
     197    [[NSFileManager defaultManager] copyItemAtURL:url2.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-shm"] error:nil];
     198    [[NSFileManager defaultManager] copyItemAtURL:url3.get() toURL:[frameIDBPath2.get() URLByAppendingPathComponent:@"IndexedDB.sqlite3-wal"] error:nil];
     199
     200    [dataStore fetchDataRecordsOfTypes:types.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> * records) {
     201        EXPECT_EQ([records count], (unsigned long)3);
     202        for (id record in records) {
     203            if ([[record displayName] isEqual: @"apple.com"]) {
     204                [dataStore removeDataOfTypes:types.get() forDataRecords:[NSArray arrayWithObject:record] completionHandler:^() {
     205                    receivedScriptMessage = true;
     206                    EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:frameIDBPath.get().path]);
     207                }];
     208            }
     209        }
     210    }];
    193211    receivedScriptMessage = false;
     212    TestWebKitAPI::Util::run(&receivedScriptMessage);
     213
    194214    [dataStore removeDataOfTypes:types.get() modifiedSince:[NSDate distantPast] completionHandler:[]() {
    195215        receivedScriptMessage = true;
    196216    }];
     217    receivedScriptMessage = false;
    197218    TestWebKitAPI::Util::run(&receivedScriptMessage);
    198219
Note: See TracChangeset for help on using the changeset viewer.