Changeset 260668 in webkit


Ignore:
Timestamp:
Apr 24, 2020 2:08:10 PM (4 years ago)
Author:
Kate Cheney
Message:

Removing website data for a domain should delete corresponding ITP entry
https://bugs.webkit.org/show_bug.cgi?id=210864
<rdar://problem/59473193>

Reviewed by John Wilander.

Source/WebKit:

Tests: http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database.html

http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration.html
http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database.html
http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries.html
http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database.html
http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads.html

In the database store: deletes domain from the ObservedDomains table
when website data is deleted for that domain. This deletes every
instance of the domainID in the database due to cascading deletions.

In the memory store: deletes every instance of the domain in the
statistics map, which will update the plist.

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:

(WebKit::ResourceLoadStatisticsDatabaseStore::removeDataForDomain):
(WebKit::ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase):
Needed a new function to check for the existence of domainID in any
table. Existing queries rely on the ObservedDomains entry, which means
testing using those could result in a false positive if the domainID
was deleted from ObservedDomains but is floating around in another
table.

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
  • NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:

(WebKit::ResourceLoadStatisticsMemoryStore::removeDataForDomain):

  • NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
  • NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:

(WebKit::WebResourceLoadStatisticsStore::domainIDExistsInDatabase):
(WebKit::WebResourceLoadStatisticsStore::removeDataForDomain):

  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::domainIDExistsInDatabase):
(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
Pass RegistrableDomains vector to deleteWebsiteDataForOrigins,
captured based on the WebsiteData display name.

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreRemoveITPDataForDomain):
(WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase):

  • UIProcess/API/C/WKWebsiteDataStoreRef.h:
  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::deleteWebsiteDataForOrigins):
(WebKit::NetworkProcessProxy::domainIDExistsInDatabase):

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::removeData):
(WebKit::WebsiteDataStore::domainIDExistsInDatabase):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

Created 2 new APIs for testing. One to mimic clearing website data
for a domain, and one to check if the domain exists in the database
after a deletion was requested.

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::doesStatisticsDomainIDExistInDatabase):
(WTR::TestRunner::domainIDExistsInDatabase): Deleted.

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::doesStatisticsDomainIDExistInDatabase):
(WTR::TestController::domainIDExistsInDatabase): Deleted.

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

Inserts values into the ITP database then tests removing the domain's
website data will remove all instances of that domain in the ITP
database.

Database store expectations will reflect the result of the new
domainIDExistsInDatabase function. Memory store tests will use the
dump output which should not include the deleted information.

  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database-expected.txt: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database.html: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-expected.txt: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration.html: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database-expected.txt: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database.html: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-expected.txt: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries.html: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database-expected.txt: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database.html: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-expected.txt: Added.
  • http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads.html: Added.
Location:
trunk
Files:
12 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r260662 r260668  
     12020-04-24  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        Removing website data for a domain should delete corresponding ITP entry
     4        https://bugs.webkit.org/show_bug.cgi?id=210864
     5        <rdar://problem/59473193>
     6
     7        Reviewed by John Wilander.
     8
     9        Inserts values into the ITP database then tests removing the domain's
     10        website data will remove all instances of that domain in the ITP
     11        database.
     12
     13        Database store expectations will reflect the result of the new
     14        domainIDExistsInDatabase function. Memory store tests will use the
     15        dump output which should not include the deleted information.
     16
     17        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database-expected.txt: Added.
     18        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database.html: Added.
     19        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-expected.txt: Added.
     20        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration.html: Added.
     21        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database-expected.txt: Added.
     22        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database.html: Added.
     23        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-expected.txt: Added.
     24        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries.html: Added.
     25        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database-expected.txt: Added.
     26        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database.html: Added.
     27        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-expected.txt: Added.
     28        * http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads.html: Added.
     29
    1302020-04-24  Antoine Quint  <graouts@apple.com>
    231
  • trunk/Source/WebKit/ChangeLog

    r260667 r260668  
     12020-04-24  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        Removing website data for a domain should delete corresponding ITP entry
     4        https://bugs.webkit.org/show_bug.cgi?id=210864
     5        <rdar://problem/59473193>
     6
     7        Reviewed by John Wilander.
     8
     9        Tests: http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration-database.html
     10               http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-link-decoration.html
     11               http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries-database.html
     12               http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-mixed-statistics-entries.html
     13               http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads-database.html
     14               http/tests/resourceLoadStatistics/remove-website-data-for-origin-deletes-third-party-script-loads.html
     15
     16        In the database store: deletes domain from the ObservedDomains table
     17        when website data is deleted for that domain. This deletes every
     18        instance of the domainID in the database due to cascading deletions.
     19
     20        In the memory store: deletes every instance of the domain in the
     21        statistics map, which will update the plist.
     22
     23        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
     24        (WebKit::ResourceLoadStatisticsDatabaseStore::removeDataForDomain):
     25        (WebKit::ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase):
     26        Needed a new function to check for the existence of domainID in any
     27        table. Existing queries rely on the ObservedDomains entry, which means
     28        testing using those could result in a false positive if the domainID
     29        was deleted from ObservedDomains but is floating around in another
     30        table.
     31
     32        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
     33        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
     34        (WebKit::ResourceLoadStatisticsMemoryStore::removeDataForDomain):
     35        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
     36        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
     37        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     38        (WebKit::WebResourceLoadStatisticsStore::domainIDExistsInDatabase):
     39        (WebKit::WebResourceLoadStatisticsStore::removeDataForDomain):
     40        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
     41        * NetworkProcess/NetworkProcess.cpp:
     42        (WebKit::NetworkProcess::domainIDExistsInDatabase):
     43        (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
     44        Pass RegistrableDomains vector to deleteWebsiteDataForOrigins,
     45        captured based on the WebsiteData display name.
     46
     47        * NetworkProcess/NetworkProcess.h:
     48        * NetworkProcess/NetworkProcess.messages.in:
     49        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     50        (WKWebsiteDataStoreRemoveITPDataForDomain):
     51        (WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase):
     52        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     53        * UIProcess/Network/NetworkProcessProxy.cpp:
     54        (WebKit::NetworkProcessProxy::deleteWebsiteDataForOrigins):
     55        (WebKit::NetworkProcessProxy::domainIDExistsInDatabase):
     56        * UIProcess/Network/NetworkProcessProxy.h:
     57        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     58        (WebKit::WebsiteDataStore::removeData):
     59        (WebKit::WebsiteDataStore::domainIDExistsInDatabase):
     60        * UIProcess/WebsiteData/WebsiteDataStore.h:
     61
    1622020-04-24  David Kilzer  <ddkilzer@apple.com>
    263
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp

    r260594 r260668  
    135135    "UNION ALL SELECT topFrameDomainID FROM SubresourceUnderTopFrameDomains WHERE subresourceDomainID = ?"
    136136    "UNION ALL SELECT toDomainID FROM SubresourceUniqueRedirectsTo WHERE subresourceDomainID = ?"_s;
     137
     138// EXISTS for testing queries
     139constexpr auto linkDecorationExistsQuery = "SELECT EXISTS (SELECT * FROM TopFrameLinkDecorationsFrom WHERE toDomainID = ? OR fromDomainID = ?)"_s;
     140constexpr auto scriptLoadExistsQuery = "SELECT EXISTS (SELECT * FROM TopFrameLoadedThirdPartyScripts WHERE topFrameDomainID = ? OR subresourceDomainID = ?)"_s;
     141constexpr auto subFrameExistsQuery = "SELECT EXISTS (SELECT * FROM SubframeUnderTopFrameDomains WHERE subFrameDomainID = ? OR topFrameDomainID = ?)"_s;
     142constexpr auto subResourceExistsQuery = "SELECT EXISTS (SELECT * FROM SubresourceUnderTopFrameDomains WHERE subresourceDomainID = ? OR topFrameDomainID = ?)"_s;
     143constexpr auto uniqueRedirectExistsQuery = "SELECT EXISTS (SELECT * FROM SubresourceUniqueRedirectsTo WHERE subresourceDomainID = ? OR toDomainID = ?)"_s;
     144constexpr auto observedDomainsExistsQuery = "SELECT EXISTS (SELECT * FROM ObservedDomains WHERE domainID = ?)"_s;
     145
     146// DELETE Queries
     147constexpr auto removeAllDataQuery = "DELETE FROM ObservedDomains WHERE domainID = ?"_s;
    137148
    138149const char* tables[] = {
     
    291302    , m_storageAccessExistsStatement(m_database, storageAccessExistsQuery)
    292303    , m_getMostRecentlyUpdatedTimestampStatement(m_database, getMostRecentlyUpdatedTimestampQuery)
     304    , m_linkDecorationExistsStatement(m_database, linkDecorationExistsQuery)
     305    , m_scriptLoadExistsStatement(m_database, scriptLoadExistsQuery)
     306    , m_subFrameExistsStatement(m_database, subFrameExistsQuery)
     307    , m_subResourceExistsStatement(m_database, subResourceExistsQuery)
     308    , m_uniqueRedirectExistsStatement(m_database, uniqueRedirectExistsQuery)
     309    , m_observedDomainsExistsStatement(m_database, observedDomainsExistsQuery)
     310    , m_removeAllDataStatement(m_database, removeAllDataQuery)
    293311    , m_sessionID(sessionID)
    294312{
     
    632650        || m_storageAccessExistsStatement.prepare() != SQLITE_OK
    633651        || m_getMostRecentlyUpdatedTimestampStatement.prepare() != SQLITE_OK
     652        || m_linkDecorationExistsStatement.prepare() != SQLITE_OK
     653        || m_scriptLoadExistsStatement.prepare() != SQLITE_OK
     654        || m_subFrameExistsStatement.prepare() != SQLITE_OK
     655        || m_subResourceExistsStatement.prepare() != SQLITE_OK
     656        || m_uniqueRedirectExistsStatement.prepare() != SQLITE_OK
     657        || m_observedDomainsExistsStatement.prepare() != SQLITE_OK
     658        || m_removeAllDataStatement.prepare() != SQLITE_OK
    634659        ) {
    635660        RELEASE_LOG_ERROR(Network, "%p - ResourceLoadStatisticsDatabaseStore::prepareStatements failed to prepare, error message: %" PUBLIC_LOG_STRING, this, m_database.lastErrorMsg());
     
    22442269}
    22452270
     2271void ResourceLoadStatisticsDatabaseStore::removeDataForDomain(const RegistrableDomain& domain)
     2272{
     2273    auto domainIDToRemove = domainID(domain);
     2274    if (!domainIDToRemove)
     2275        return;
     2276
     2277    if (m_removeAllDataStatement.bindInt(1, *domainIDToRemove) != SQLITE_OK
     2278        || m_removeAllDataStatement.step() != SQLITE_DONE) {
     2279        RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::removeDataForDomain failed, error message: %{private}s", this, m_database.lastErrorMsg());
     2280        ASSERT_NOT_REACHED();
     2281    }
     2282   
     2283    resetStatement(m_removeAllDataStatement);
     2284}
     2285
    22462286void ResourceLoadStatisticsDatabaseStore::clear(CompletionHandler<void()>&& completionHandler)
    22472287{
     
    28902930}
    28912931
     2932bool ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase(int domainID)
     2933{
     2934    if (m_linkDecorationExistsStatement.bindInt(1, domainID) != SQLITE_OK
     2935        || m_linkDecorationExistsStatement.bindInt(2, domainID) != SQLITE_OK
     2936        || m_scriptLoadExistsStatement.bindInt(1, domainID) != SQLITE_OK
     2937        || m_scriptLoadExistsStatement.bindInt(2, domainID) != SQLITE_OK
     2938        || m_subFrameExistsStatement.bindInt(1, domainID) != SQLITE_OK
     2939        || m_subFrameExistsStatement.bindInt(2, domainID) != SQLITE_OK
     2940        || m_subResourceExistsStatement.bindInt(1, domainID) != SQLITE_OK
     2941        || m_subResourceExistsStatement.bindInt(2, domainID) != SQLITE_OK
     2942        || m_uniqueRedirectExistsStatement.bindInt(1, domainID) != SQLITE_OK
     2943        || m_uniqueRedirectExistsStatement.bindInt(2, domainID) != SQLITE_OK
     2944        || m_observedDomainsExistsStatement.bindInt(1, domainID) != SQLITE_OK) {
     2945        RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase failed to bind, error message: %{private}s", this, m_database.lastErrorMsg());
     2946        ASSERT_NOT_REACHED();
     2947        return false;
     2948    }
     2949
     2950    if (m_linkDecorationExistsStatement.step() != SQLITE_ROW
     2951        || m_scriptLoadExistsStatement.step() != SQLITE_ROW
     2952        || m_subFrameExistsStatement.step() != SQLITE_ROW
     2953        || m_subResourceExistsStatement.step() != SQLITE_ROW
     2954        || m_uniqueRedirectExistsStatement.step() != SQLITE_ROW
     2955        || m_observedDomainsExistsStatement.step() != SQLITE_ROW) {
     2956        RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::domainIDExistsInDatabase failed to step, error message: %{private}s", this, m_database.lastErrorMsg());
     2957        ASSERT_NOT_REACHED();
     2958        return false;
     2959    }
     2960   
     2961    resetStatement(m_linkDecorationExistsStatement);
     2962    resetStatement(m_scriptLoadExistsStatement);
     2963    resetStatement(m_subFrameExistsStatement);
     2964    resetStatement(m_subResourceExistsStatement);
     2965    resetStatement(m_uniqueRedirectExistsStatement);
     2966    resetStatement(m_observedDomainsExistsStatement);
     2967
     2968    return m_linkDecorationExistsStatement.getColumnInt(0) || m_scriptLoadExistsStatement.getColumnInt(0) || m_subFrameExistsStatement.getColumnInt(0) || m_subResourceExistsStatement.getColumnInt(0) || m_uniqueRedirectExistsStatement.getColumnInt(0) || m_observedDomainsExistsStatement.getColumnInt(0);
     2969}
     2970
    28922971} // namespace WebKit
    28932972
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h

    r260594 r260668  
    139139    bool isNewResourceLoadStatisticsDatabaseFile() const { return m_isNewResourceLoadStatisticsDatabaseFile; }
    140140    void setIsNewResourceLoadStatisticsDatabaseFile(bool isNewResourceLoadStatisticsDatabaseFile) { m_isNewResourceLoadStatisticsDatabaseFile = isNewResourceLoadStatisticsDatabaseFile; }
     141    void removeDataForDomain(const RegistrableDomain&) override;
     142    bool domainIDExistsInDatabase(int);
    141143
    142144private:
     
    264266    mutable WebCore::SQLiteStatement m_storageAccessExistsStatement;
    265267    mutable WebCore::SQLiteStatement m_getMostRecentlyUpdatedTimestampStatement;
     268    mutable WebCore::SQLiteStatement m_linkDecorationExistsStatement;
     269    mutable WebCore::SQLiteStatement m_scriptLoadExistsStatement;
     270    mutable WebCore::SQLiteStatement m_subFrameExistsStatement;
     271    mutable WebCore::SQLiteStatement m_subResourceExistsStatement;
     272    mutable WebCore::SQLiteStatement m_uniqueRedirectExistsStatement;
     273    mutable WebCore::SQLiteStatement m_observedDomainsExistsStatement;
     274    mutable WebCore::SQLiteStatement m_removeAllDataStatement;
    266275    PAL::SessionID m_sessionID;
    267276    bool m_isNewResourceLoadStatisticsDatabaseFile { false };
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp

    r260169 r260668  
    10431043}
    10441044
     1045void ResourceLoadStatisticsMemoryStore::removeDataForDomain(const RegistrableDomain& domain)
     1046{
     1047    m_resourceStatisticsMap.remove(domain);
     1048   
     1049    for (auto& statistic : m_resourceStatisticsMap) {
     1050        statistic.value.topFrameUniqueRedirectsTo.remove(domain);
     1051        statistic.value.topFrameUniqueRedirectsToSinceSameSiteStrictEnforcement.remove(domain);
     1052        statistic.value.topFrameUniqueRedirectsFrom.remove(domain);
     1053        statistic.value.topFrameLinkDecorationsFrom.remove(domain);
     1054        statistic.value.topFrameLoadedThirdPartyScripts.remove(domain);
     1055        statistic.value.subframeUnderTopFrameDomains.remove(domain);
     1056        statistic.value.subresourceUnderTopFrameDomains.remove(domain);
     1057        statistic.value.subresourceUniqueRedirectsTo.remove(domain);
     1058        statistic.value.subresourceUniqueRedirectsFrom.remove(domain);
     1059    }
     1060}
     1061
    10451062void ResourceLoadStatisticsMemoryStore::setPrevalentResource(const RegistrableDomain& domain)
    10461063{
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h

    r259275 r260668  
    113113
    114114    void setLastSeen(const RegistrableDomain&, Seconds) override;
     115    void removeDataForDomain(const RegistrableDomain&) override;
    115116
    116117private:
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h

    r260169 r260668  
    185185    virtual void setLastSeen(const RegistrableDomain& primaryDomain, Seconds) = 0;
    186186
     187    virtual void removeDataForDomain(const RegistrableDomain&) = 0;
     188   
    187189    void didCreateNetworkProcess();
    188190
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r260169 r260668  
    11561156}
    11571157
     1158void WebResourceLoadStatisticsStore::domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&& completionHandler)
     1159{
     1160    ASSERT(RunLoop::isMain());
     1161
     1162    postTask([this, domainID, completionHandler = WTFMove(completionHandler)]() mutable {
     1163        if (!m_statisticsStore || !is<ResourceLoadStatisticsDatabaseStore>(*m_statisticsStore)) {
     1164            completionHandler(false);
     1165            return;
     1166        }
     1167        auto& databaseStore = downcast<ResourceLoadStatisticsDatabaseStore>(*m_statisticsStore);
     1168        bool domainIDExists = databaseStore.domainIDExistsInDatabase(domainID);
     1169        postTaskReply([domainIDExists, completionHandler = WTFMove(completionHandler)]() mutable {
     1170            completionHandler(domainIDExists);
     1171        });
     1172    });
     1173}
     1174
    11581175void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler)
    11591176{
     
    12841301}
    12851302
     1303void WebResourceLoadStatisticsStore::removeDataForDomain(RegistrableDomain domain, CompletionHandler<void()>&& completionHandler)
     1304{
     1305    ASSERT(RunLoop::isMain());
     1306    postTask([this, domain = WTFMove(domain), completionHandler = WTFMove(completionHandler)]() mutable {
     1307        if (m_statisticsStore)
     1308            m_statisticsStore->removeDataForDomain(domain);
     1309
     1310        postTaskReply(WTFMove(completionHandler));
     1311    });
     1312}
     1313
    12861314void WebResourceLoadStatisticsStore::deleteAndRestrictWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, RegistrableDomainsToDeleteOrRestrictWebsiteDataFor&& domainsToDeleteAndRestrictWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
    12871315{
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r260169 r260668  
    219219    void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&, CompletionHandler<void()>&&);
    220220    void clearUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&);
     221    void removeDataForDomain(const RegistrableDomain, CompletionHandler<void()>&&);
    221222    void deleteAndRestrictWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, RegistrableDomainsToDeleteOrRestrictWebsiteDataFor&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
    222223    void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&);
     
    255256    void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfatherStatistics, CompletionHandler<void()>&&);
    256257    void clearInMemoryEphemeral(CompletionHandler<void()>&&);
     258    void domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&&);
    257259
    258260    void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r260496 r260668  
    991991}
    992992
     993void NetworkProcess::domainIDExistsInDatabase(PAL::SessionID sessionID, int domainID, CompletionHandler<void(bool)>&& completionHandler)
     994{
     995    if (auto* networkSession = this->networkSession(sessionID)) {
     996        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     997            resourceLoadStatistics->domainIDExistsInDatabase(domainID, WTFMove(completionHandler));
     998        else
     999            completionHandler(false);
     1000    } else {
     1001        ASSERT_NOT_REACHED();
     1002        completionHandler(false);
     1003    }
     1004}
     1005
    9931006void NetworkProcess::mergeStatisticForTesting(PAL::SessionID sessionID, const RegistrableDomain& domain, const RegistrableDomain& topFrameDomain1, const RegistrableDomain& topFrameDomain2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&& completionHandler)
    9941007{
     
    16051618}
    16061619
    1607 void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& originDatas, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CallbackID callbackID)
     1620void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& originDatas, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, const Vector<RegistrableDomain>& registrableDomains, CallbackID callbackID)
    16081621{
    16091622    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
     
    16791692        WebCore::CredentialStorage::removeSessionCredentialsWithOrigins(originDatas);
    16801693    }
     1694
     1695#if ENABLE(RESOURCE_LOAD_STATISTICS)
     1696    if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) {
     1697        if (auto* networkSession = this->networkSession(sessionID)) {
     1698            for (auto& domain : registrableDomains) {
     1699                if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     1700                    resourceLoadStatistics->removeDataForDomain(domain, [clearTasksHandler = clearTasksHandler.copyRef()] { });
     1701            }
     1702        }
     1703    }
     1704#endif
    16811705}
    16821706
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r260496 r260668  
    242242    void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
    243243    void setLastSeen(PAL::SessionID, const RegistrableDomain&, Seconds, CompletionHandler<void()>&&);
     244    void domainIDExistsInDatabase(PAL::SessionID, int domainID, CompletionHandler<void(bool)>&&);
    244245    void mergeStatisticForTesting(PAL::SessionID, const RegistrableDomain&, const TopFrameDomain& topFrameDomain1, const TopFrameDomain& topFrameDomain2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&&);
    245246    void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     
    400401    void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, CallbackID);
    401402    void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CallbackID);
    402     void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostnames, CallbackID);
     403    void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostnames, const Vector<RegistrableDomain>&, CallbackID);
    403404
    404405    void clearCachedCredentials();
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r260496 r260668  
    4646    FetchWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, OptionSet<WebKit::WebsiteDataFetchOption> fetchOptions, WebKit::CallbackID callbackID)
    4747    DeleteWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, WallTime modifiedSince, WebKit::CallbackID callbackID)
    48     DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, Vector<String> cookieHostNames, Vector<String> HSTSCacheHostNames, WebKit::CallbackID callbackID)
     48    DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, Vector<String> cookieHostNames, Vector<String> HSTSCacheHostNames, Vector<WebCore::RegistrableDomain> registrableDomains, WebKit::CallbackID callbackID)
    4949
    5050    DownloadRequest(PAL::SessionID sessionID, WebKit::DownloadID downloadID, WebCore::ResourceRequest request, enum:bool Optional<WebKit::NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, String suggestedFilename)
     
    105105    IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain) -> (bool isSubframeUnder) Async
    106106    IsRegisteredAsSubresourceUnder(PAL::SessionID sessionID, WebCore::RegistrableDomain subresourceDomain, WebCore::RegistrableDomain topFrameDomain) -> (bool isSubresourceUnder) Async
     107    DomainIDExistsInDatabase(PAL::SessionID sessionID, int domainID) -> (bool exists) Async
    107108    LogFrameNavigation(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain sourceDomain, bool isRedirect, bool isMainFrame, Seconds delayAfterMainFrameDocumentLoad, bool wasPotentiallyInitiatedByUser)
    108109    LogUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain) -> () Async
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r259275 r260668  
    6767}
    6868
     69void WKWebsiteDataStoreRemoveITPDataForDomain(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreRemoveITPDataForDomainFunction callback)
     70{
     71    WebKit::WebsiteDataRecord dataRecord;
     72    dataRecord.types.add(WebKit::WebsiteDataType::ResourceLoadStatistics);
     73    dataRecord.displayName = WebKit::toImpl(host)->string();
     74    Vector<WebKit::WebsiteDataRecord> dataRecords = { WTFMove(dataRecord) };
     75
     76    OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::ResourceLoadStatistics;
     77    WebKit::toImpl(dataStoreRef)->removeData(dataTypes, dataRecords, [context, callback] {
     78        callback(context);
     79    });
     80}
     81
     82void WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase(WKWebsiteDataStoreRef dataStoreRef, int domainID, void* context, WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabaseFunction callback)
     83{
     84#if ENABLE(RESOURCE_LOAD_STATISTICS)
     85    WebKit::toImpl(dataStoreRef)->domainIDExistsInDatabase(domainID, [context, callback](bool exists) {
     86        callback(exists, context);
     87    });
     88#else
     89    callback(false, context);
     90#endif
     91}
     92
    6993void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable)
    7094{
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r258884 r260668  
    137137WK_EXPORT void WKWebsiteDataStoreRemoveAllFetchCaches(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveFetchCacheRemovalFunction callback);
    138138
     139typedef void (*WKWebsiteDataStoreRemoveITPDataForDomainFunction)(void* functionContext);
     140WK_EXPORT void WKWebsiteDataStoreRemoveITPDataForDomain(WKWebsiteDataStoreRef dataStoreRef, WKStringRef origin, void* context, WKWebsiteDataStoreRemoveITPDataForDomainFunction callback);
     141typedef void (*WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabaseFunction)(bool domainExistsInDatabase, void* functionContext);
     142WK_EXPORT void WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase(WKWebsiteDataStoreRef dataStoreRef, int domainID, void* context, WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabaseFunction callback);
     143
    139144typedef void (*WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback)(void* functionContext);
    140145WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback);
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r260658 r260668  
    199199}
    200200
    201 void NetworkProcessProxy::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&& completionHandler)
     201void NetworkProcessProxy::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, const Vector<RegistrableDomain>& registrableDomains, CompletionHandler<void()>&& completionHandler)
    202202{
    203203    ASSERT(canSendMessage());
     
    215215    });
    216216
    217     send(Messages::NetworkProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, callbackID), 0);
     217    send(Messages::NetworkProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, registrableDomains, callbackID), 0);
    218218}
    219219
     
    573573   
    574574    sendWithAsyncReply(Messages::NetworkProcess::SetLastSeen(sessionID, resourceDomain, lastSeen), WTFMove(completionHandler));
     575}
     576
     577void NetworkProcessProxy::domainIDExistsInDatabase(PAL::SessionID sessionID, int domainID, CompletionHandler<void(bool)>&& completionHandler)
     578{
     579    if (!canSendMessage()) {
     580        completionHandler(false);
     581        return;
     582    }
     583   
     584    sendWithAsyncReply(Messages::NetworkProcess::DomainIDExistsInDatabase(sessionID, domainID), WTFMove(completionHandler));
    575585}
    576586
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r260658 r260668  
    108108    void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, CompletionHandler<void(WebsiteData)>&&);
    109109    void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CompletionHandler<void()>&& completionHandler);
    110     void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&&);
     110    void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, const Vector<RegistrableDomain>&, CompletionHandler<void()>&&);
    111111
    112112    void getLocalStorageDetails(PAL::SessionID, CompletionHandler<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&&);
     
    131131    void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&);
    132132    void setLastSeen(PAL::SessionID, const RegistrableDomain&, Seconds, CompletionHandler<void()>&&);
     133    void domainIDExistsInDatabase(PAL::SessionID, int domainID, CompletionHandler<void(bool)>&&);
    133134    void mergeStatisticForTesting(PAL::SessionID, const RegistrableDomain&, const TopFrameDomain& topFrameDomain1, const TopFrameDomain& topFrameDomain2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&&);
    134135    void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r259910 r260668  
    991991            Vector<String> cookieHostNames;
    992992            Vector<String> HSTSCacheHostNames;
     993            Vector<WebCore::RegistrableDomain> registrableDomains;
    993994            for (const auto& dataRecord : dataRecords) {
    994995                for (auto& hostName : dataRecord.cookieHostNames)
     
    996997                for (auto& hostName : dataRecord.HSTSCacheHostNames)
    997998                    HSTSCacheHostNames.append(hostName);
     999                registrableDomains.append(WebCore::RegistrableDomain::uncheckedCreateFromHost(dataRecord.displayName));
    9981000            }
    9991001
    10001002            callbackAggregator->addPendingCallback();
    1001             processPool->networkProcess()->deleteWebsiteDataForOrigins(m_sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, [callbackAggregator, processPool] {
     1003            processPool->networkProcess()->deleteWebsiteDataForOrigins(m_sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, registrableDomains, [callbackAggregator, processPool] {
    10021004                callbackAggregator->removePendingCallback();
    10031005            });
     
    15941596        if (auto* process = processPool->networkProcess())
    15951597            process->setLastSeen(m_sessionID, WebCore::RegistrableDomain { url }, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1598    }
     1599}
     1600
     1601void WebsiteDataStore::domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&& completionHandler)
     1602{
     1603    ASSERT(RunLoop::isMain());
     1604
     1605    for (auto& processPool : processPools()) {
     1606        if (auto* process = processPool->networkProcess()) {
     1607            process->domainIDExistsInDatabase(m_sessionID, domainID, WTFMove(completionHandler));
     1608            break;
     1609        }
    15961610    }
    15971611}
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r259520 r260668  
    168168    void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&);
    169169    void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&);
     170    void domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&&);
    170171    void mergeStatisticForTesting(const URL&, const URL& topFrameUrl1, const URL& topFrameUrl2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&&);
    171172    void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&);
  • trunk/Tools/ChangeLog

    r260662 r260668  
     12020-04-24  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        Removing website data for a domain should delete corresponding ITP entry
     4        https://bugs.webkit.org/show_bug.cgi?id=210864
     5        <rdar://problem/59473193>
     6
     7        Reviewed by John Wilander.
     8
     9        Created 2 new APIs for testing. One to mimic clearing website data
     10        for a domain, and one to check if the domain exists in the database
     11        after a deletion was requested.
     12
     13        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     14        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     15        (WTR::TestRunner::doesStatisticsDomainIDExistInDatabase):
     16        (WTR::TestRunner::domainIDExistsInDatabase): Deleted.
     17        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     18        * WebKitTestRunner/TestController.cpp:
     19        (WTR::TestController::doesStatisticsDomainIDExistInDatabase):
     20        (WTR::TestController::domainIDExistsInDatabase): Deleted.
     21        * WebKitTestRunner/TestController.h:
     22        * WebKitTestRunner/TestInvocation.cpp:
     23        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     24
    1252020-04-24  Antoine Quint  <graouts@apple.com>
    226
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r258884 r260668  
    293293
    294294    // Resource Load Statistics
     295    void clearStatisticsDataForDomain(DOMString domain);
     296    boolean doesStatisticsDomainIDExistInDatabase(unsigned long domainID);
    295297    void setStatisticsEnabled(boolean value);
    296298    boolean isStatisticsEphemeral();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r258884 r260668  
    14161416}
    14171417
     1418void TestRunner::clearStatisticsDataForDomain(JSStringRef domain)
     1419{
     1420    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("ClearStatisticsDataForDomain"));
     1421    WKRetainPtr<WKStringRef> messageBody = adoptWK(WKStringCreateWithJSString(domain));
     1422    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1423}
     1424
     1425bool TestRunner::doesStatisticsDomainIDExistInDatabase(unsigned domainID)
     1426{
     1427    Vector<WKRetainPtr<WKStringRef>> keys;
     1428    Vector<WKRetainPtr<WKTypeRef>> values;
     1429
     1430    keys.append(adoptWK(WKStringCreateWithUTF8CString("DomainID")));
     1431    values.append(adoptWK(WKUInt64Create(domainID)));
     1432
     1433    Vector<WKStringRef> rawKeys(keys.size());
     1434    Vector<WKTypeRef> rawValues(values.size());
     1435
     1436    for (size_t i = 0; i < keys.size(); ++i) {
     1437        rawKeys[i] = keys[i].get();
     1438        rawValues[i] = values[i].get();
     1439    }
     1440
     1441    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("DoesStatisticsDomainIDExistInDatabase"));
     1442    WKRetainPtr<WKDictionaryRef> messageBody = adoptWK(WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
     1443    WKTypeRef returnData = nullptr;
     1444    WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
     1445    ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID());
     1446    return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get());
     1447}
     1448
    14181449void TestRunner::setStatisticsEnabled(bool value)
    14191450{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r258884 r260668  
    381381   
    382382    // Resource Load Statistics
     383    void clearStatisticsDataForDomain(JSStringRef domain);
     384    bool doesStatisticsDomainIDExistInDatabase(unsigned domainID);
    383385    void setStatisticsEnabled(bool value);
    384386    bool isStatisticsEphemeral();
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r260356 r260668  
    34183418}
    34193419
     3420void TestController::clearStatisticsDataForDomain(WKStringRef domain)
     3421{
     3422    ResourceStatisticsCallbackContext context(*this);
     3423
     3424    WKWebsiteDataStoreRemoveITPDataForDomain(TestController::defaultWebsiteDataStore(), domain, &context, resourceStatisticsVoidResultCallback);
     3425    runUntil(context.done, noTimeout);
     3426}
     3427
     3428bool TestController::doesStatisticsDomainIDExistInDatabase(unsigned domainID)
     3429{
     3430    ResourceStatisticsCallbackContext context(*this);
     3431    WKWebsiteDataStoreDoesStatisticsDomainIDExistInDatabase(websiteDataStore(), domainID, &context, resourceStatisticsBooleanResultCallback);
     3432    runUntil(context.done, noTimeout);
     3433    return context.result;
     3434}
     3435
    34203436void TestController::setStatisticsEnabled(bool value)
    34213437{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r260169 r260668  
    215215    void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; }
    216216
     217    void clearStatisticsDataForDomain(WKStringRef domain);
     218    bool doesStatisticsDomainIDExistInDatabase(unsigned domainID);
    217219    void setStatisticsEnabled(bool value);
    218220    bool isStatisticsEphemeral();
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r259843 r260668  
    12891289        return result;
    12901290    }
     1291   
     1292    if (WKStringIsEqualToUTF8CString(messageName, "ClearStatisticsDataForDomain")) {
     1293        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
     1294        WKStringRef domain = static_cast<WKStringRef>(messageBody);
     1295
     1296        TestController::singleton().clearStatisticsDataForDomain(domain);
     1297        return nullptr;
     1298    }
     1299
     1300    if (WKStringIsEqualToUTF8CString(messageName, "DoesStatisticsDomainIDExistInDatabase")) {
     1301        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     1302        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     1303        WKRetainPtr<WKStringRef> domainIDKey = adoptWK(WKStringCreateWithUTF8CString("DomainID"));
     1304        WKUInt64Ref domainID = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, domainIDKey.get()));
     1305        bool domainIDExists = TestController::singleton().doesStatisticsDomainIDExistInDatabase(WKUInt64GetValue(domainID));
     1306        WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(domainIDExists));
     1307        return result;
     1308    }
    12911309
    12921310    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsEnabled")) {
Note: See TracChangeset for help on using the changeset viewer.