⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243181 in webkit


Ignore:
Timestamp:
Mar 19, 2019, 5:22:09 PM (7 years ago)
Author:
wilander@apple.com
Message:

Resource Load Statistics (experimental): Clear non-cookie website data for sites that have been navigated to, with link decoration, by a prevalent resource
https://bugs.webkit.org/show_bug.cgi?id=195923
<rdar://problem/49001272>

Reviewed by Alex Christensen.

Source/WebCore:

Adds a new experimental feature.

Test: http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html

  • page/RuntimeEnabledFeatures.h:

(WebCore::RuntimeEnabledFeatures::setIsITPFirstPartyWebsiteDataRemovalEnabled):
(WebCore::RuntimeEnabledFeatures::isITPFirstPartyWebsiteDataRemovalEnabled const):

Source/WebKit:

Cross-site trackers abuse link query parameters to transport user identifiers and then store
them in first-party storage space. To address this, we've done three things:

  • r236448 capped all persistent client-side cookies to seven days of storage.
  • r242288 further capped persistent client-side cookies for navigations with link decoration from prevalent resources.
  • r242603 added logging of navigations with link decoration from prevalent resources.

This patch introduces an experimental feature that removes non-cookie website data for sites
that have been navigated to, with link decoration, by a prevalent resource.

To achieve this, resource domains to remove website data for are now marked with an enum called
WebsiteDataToRemove with values All, AllButHttpOnlyCookies, AllButCookies. As resources are
iterated, they are marked for either of these values and the new function
ResourceLoadStatisticsMemoryStore::shouldRemoveAllButCookiesFor() leads to the marking with
WebsiteDataToRemove::AllButCookies.

Then NetworkProcess::deleteWebsiteDataForRegistrableDomains() looks at this setting and removes
website data accordingly.

The thinking behind this is that the lifetime cap applied in r236448 and r242288 take care of
script writable cookies, and this patch takes care of all other script writable storage.

The infrastructure to handle user interaction expiration is now parameterized so that multiple
expiries can be applied. In this particular case, seven days of browser use.

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:

(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
(WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction):
(WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllWebsiteDataFor const):
(WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllButCookiesFor const):
(WebKit::ResourceLoadStatisticsDatabaseStore::registrableDomainsToRemoveWebsiteDataFor):

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

(WebKit::ResourceLoadStatisticsMemoryStore::hasHadUserInteraction):
(WebKit::ResourceLoadStatisticsMemoryStore::hasHadUnexpiredRecentUserInteraction const):
(WebKit::ResourceLoadStatisticsMemoryStore::shouldRemoveAllWebsiteDataFor const):
(WebKit::ResourceLoadStatisticsMemoryStore::shouldRemoveAllButCookiesFor const):
(WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor):

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

(WebKit::domainsToString):
(WebKit::ResourceLoadStatisticsStore::removeDataRecords):
(WebKit::ResourceLoadStatisticsStore::statisticsEpirationTime const):
(WebKit::ResourceLoadStatisticsStore::mergeOperatingDates):
(WebKit::ResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
(WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired const):

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

(WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
(WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains):
(WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): Deleted.

Renamed to reflect that it actually takes a parameter for which types of data to remove.

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

(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::setCrossSiteLoadWithLinkDecorationForTesting):
(WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains):
(WebKit::NetworkProcess::deleteCookiesForTesting):
(WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): Deleted.

Renamed to reflect that it actually takes a parameter for which types of data to remove.

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • NetworkProcess/NetworkProcessCreationParameters.cpp:

(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):

  • NetworkProcess/NetworkProcessCreationParameters.h:
  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomains):
(WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): Deleted.

Renamed to reflect that it actually takes a parameter for which types of data to remove.

  • NetworkProcess/NetworkSession.h:
  • Shared/WebPreferences.yaml:
  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecoration):
(WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction):
(WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords):

  • UIProcess/API/C/WKWebsiteDataStoreRef.h:
  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeNetworkProcess):

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::setCrossSiteLoadWithLinkDecorationForTesting):

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

(WebKit::WebsiteDataStore::setCrossSiteLoadWithLinkDecorationForTesting):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

This patch does the following to the TestRunner:

  • Adds setStatisticsCrossSiteLoadWithLinkDecoration().
  • Makes setStatisticsTimeToLiveUserInteraction() wait for completion.
  • Makes statisticsProcessStatisticsAndDataRecords() wait for completion.
  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setStatisticsCrossSiteLoadWithLinkDecoration):

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

(WTR::TestController::setStatisticsCrossSiteLoadWithLinkDecoration):
(WTR::TestController::setStatisticsTimeToLiveUserInteraction):
(WTR::TestController::statisticsProcessStatisticsAndDataRecords):

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

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

  • http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration-expected.txt: Added.
  • http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html: Added.
Location:
trunk
Files:
2 added
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243175 r243181  
     12019-03-19  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Clear non-cookie website data for sites that have been navigated to, with link decoration, by a prevalent resource
     4        https://bugs.webkit.org/show_bug.cgi?id=195923
     5        <rdar://problem/49001272>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration-expected.txt: Added.
     10        * http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html: Added.
     11
    1122019-03-19  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r243175 r243181  
     12019-03-19  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Clear non-cookie website data for sites that have been navigated to, with link decoration, by a prevalent resource
     4        https://bugs.webkit.org/show_bug.cgi?id=195923
     5        <rdar://problem/49001272>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Adds a new experimental feature.
     10
     11        Test: http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html
     12
     13        * page/RuntimeEnabledFeatures.h:
     14        (WebCore::RuntimeEnabledFeatures::setIsITPFirstPartyWebsiteDataRemovalEnabled):
     15        (WebCore::RuntimeEnabledFeatures::isITPFirstPartyWebsiteDataRemovalEnabled const):
     16
    1172019-03-19  Ryosuke Niwa  <rniwa@webkit.org>
    218
  • trunk/Source/WebCore/page/RuntimeEnabledFeatures.h

    r242738 r243181  
    151151    void setIsITPDatabaseEnabled(bool isEnabled) { m_isITPDatabaseEnabled = isEnabled; }
    152152    bool isITPDatabaseEnabled() const { return m_isITPDatabaseEnabled; }
     153   
     154    void setIsITPFirstPartyWebsiteDataRemovalEnabled(bool isEnabled) { m_isITPFirstPartyWebsiteDataRemovalEnabled = isEnabled; }
     155    bool isITPFirstPartyWebsiteDataRemovalEnabled() const { return m_isITPFirstPartyWebsiteDataRemovalEnabled; }
    153156
    154157    void setRestrictedHTTPResponseAccess(bool isEnabled) { m_isRestrictedHTTPResponseAccess = isEnabled; }
     
    538541
    539542    bool m_isITPDatabaseEnabled { false };
     543    bool m_isITPFirstPartyWebsiteDataRemovalEnabled { false };
    540544
    541545    bool m_referrerPolicyAttributeEnabled { false };
  • trunk/Source/WebKit/ChangeLog

    r243178 r243181  
     12019-03-19  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Clear non-cookie website data for sites that have been navigated to, with link decoration, by a prevalent resource
     4        https://bugs.webkit.org/show_bug.cgi?id=195923
     5        <rdar://problem/49001272>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Cross-site trackers abuse link query parameters to transport user identifiers and then store
     10        them in first-party storage space. To address this, we've done three things:
     11        - r236448 capped all persistent client-side cookies to seven days of storage.
     12        - r242288 further capped persistent client-side cookies for navigations with link decoration from prevalent resources.
     13        - r242603 added logging of navigations with link decoration from prevalent resources.
     14
     15        This patch introduces an experimental feature that removes non-cookie website data for sites
     16        that have been navigated to, with link decoration, by a prevalent resource.
     17
     18        To achieve this, resource domains to remove website data for are now marked with an enum called
     19        WebsiteDataToRemove with values All, AllButHttpOnlyCookies, AllButCookies. As resources are
     20        iterated, they are marked for either of these values and the new function
     21        ResourceLoadStatisticsMemoryStore::shouldRemoveAllButCookiesFor() leads to the marking with
     22        WebsiteDataToRemove::AllButCookies.
     23
     24        Then NetworkProcess::deleteWebsiteDataForRegistrableDomains() looks at this setting and removes
     25        website data accordingly.
     26
     27        The thinking behind this is that the lifetime cap applied in r236448 and r242288 take care of
     28        script writable cookies, and this patch takes care of all other script writable storage.
     29
     30        The infrastructure to handle user interaction expiration is now parameterized so that multiple
     31        expiries can be applied. In this particular case, seven days of browser use.
     32
     33        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
     34        (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
     35        (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
     36        (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction):
     37        (WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllWebsiteDataFor const):
     38        (WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllButCookiesFor const):
     39        (WebKit::ResourceLoadStatisticsDatabaseStore::registrableDomainsToRemoveWebsiteDataFor):
     40        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
     41        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
     42        (WebKit::ResourceLoadStatisticsMemoryStore::hasHadUserInteraction):
     43        (WebKit::ResourceLoadStatisticsMemoryStore::hasHadUnexpiredRecentUserInteraction const):
     44        (WebKit::ResourceLoadStatisticsMemoryStore::shouldRemoveAllWebsiteDataFor const):
     45        (WebKit::ResourceLoadStatisticsMemoryStore::shouldRemoveAllButCookiesFor const):
     46        (WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor):
     47        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
     48        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
     49        (WebKit::domainsToString):
     50        (WebKit::ResourceLoadStatisticsStore::removeDataRecords):
     51        (WebKit::ResourceLoadStatisticsStore::statisticsEpirationTime const):
     52        (WebKit::ResourceLoadStatisticsStore::mergeOperatingDates):
     53        (WebKit::ResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
     54        (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired const):
     55        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
     56        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     57        (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
     58        (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains):
     59        (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): Deleted.
     60           Renamed to reflect that it actually takes a parameter for which types of data to remove.
     61        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
     62        * NetworkProcess/NetworkProcess.cpp:
     63        (WebKit::NetworkProcess::initializeNetworkProcess):
     64        (WebKit::NetworkProcess::setCrossSiteLoadWithLinkDecorationForTesting):
     65        (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains):
     66        (WebKit::NetworkProcess::deleteCookiesForTesting):
     67        (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): Deleted.
     68           Renamed to reflect that it actually takes a parameter for which types of data to remove.
     69        * NetworkProcess/NetworkProcess.h:
     70        * NetworkProcess/NetworkProcess.messages.in:
     71        * NetworkProcess/NetworkProcessCreationParameters.cpp:
     72        (WebKit::NetworkProcessCreationParameters::encode const):
     73        (WebKit::NetworkProcessCreationParameters::decode):
     74        * NetworkProcess/NetworkProcessCreationParameters.h:
     75        * NetworkProcess/NetworkSession.cpp:
     76        (WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomains):
     77        (WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): Deleted.
     78           Renamed to reflect that it actually takes a parameter for which types of data to remove.
     79        * NetworkProcess/NetworkSession.h:
     80        * Shared/WebPreferences.yaml:
     81        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     82        (WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecoration):
     83        (WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction):
     84        (WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords):
     85        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     86        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     87        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
     88        * UIProcess/Network/NetworkProcessProxy.cpp:
     89        (WebKit::NetworkProcessProxy::setCrossSiteLoadWithLinkDecorationForTesting):
     90        * UIProcess/Network/NetworkProcessProxy.h:
     91        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     92        (WebKit::WebsiteDataStore::setCrossSiteLoadWithLinkDecorationForTesting):
     93        * UIProcess/WebsiteData/WebsiteDataStore.h:
     94
    1952019-03-19  Chris Dumez  <cdumez@apple.com>
    296
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp

    r242764 r243181  
    820820        auto subFrameStatus = ensureResourceStatisticsForRegistrableDomain(subFrameDomain);
    821821        ASSERT(subFrameStatus.first == AddedRecord::No);
    822         ASSERT(hasHadUserInteraction(subFrameDomain));
     822        ASSERT(hasHadUserInteraction(subFrameDomain, OperatingDatesWindow::Long));
    823823        insertDomainRelationship(m_storageAccessUnderTopFrameDomainsStatement, subFrameStatus.second, topFrameDomain);
    824824    }
     
    840840        auto subFrameStatus = ensureResourceStatisticsForRegistrableDomain(subFrameDomain);
    841841        ASSERT(subFrameStatus.first == AddedRecord::No);
    842         ASSERT(hasHadUserInteraction(subFrameDomain));
     842        ASSERT(hasHadUserInteraction(subFrameDomain, OperatingDatesWindow::Long));
    843843        ASSERT(hasUserGrantedStorageAccessThroughPrompt(subFrameStatus.second, topFrameDomain));
    844844#endif
     
    10341034}
    10351035
    1036 bool ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction(const RegistrableDomain& domain)
     1036bool ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction(const RegistrableDomain& domain, OperatingDatesWindow operatingDatesWindow)
    10371037{
    10381038    ASSERT(!RunLoop::isMain());
     
    10511051    WallTime mostRecentUserInteractionTime = WallTime::fromRawSeconds(m_hadUserInteractionStatement.getColumnDouble(1));
    10521052
    1053     if (hasStatisticsExpired(mostRecentUserInteractionTime)) {
     1053    if (hasStatisticsExpired(mostRecentUserInteractionTime, operatingDatesWindow)) {
    10541054        // Drop privacy sensitive data because we no longer need it.
    10551055        // Set timestamp to 0 so that statistics merge will know
     
    14931493}
    14941494
    1495 Vector<RegistrableDomain> ResourceLoadStatisticsDatabaseStore::registrableDomainsToRemoveWebsiteDataFor()
     1495bool ResourceLoadStatisticsDatabaseStore::shouldRemoveAllWebsiteDataFor(const PrevalentDomainData& resourceStatistic, bool shouldCheckForGrandfathering) const
     1496{
     1497    return !resourceStatistic.hadUserInteraction && (!shouldCheckForGrandfathering || !resourceStatistic.grandfathered);
     1498}
     1499
     1500bool ResourceLoadStatisticsDatabaseStore::shouldRemoveAllButCookiesFor(const PrevalentDomainData& resourceStatistic, bool shouldCheckForGrandfathering) const
     1501{
     1502    UNUSED_PARAM(resourceStatistic);
     1503    UNUSED_PARAM(shouldCheckForGrandfathering);
     1504    return false;
     1505}
     1506
     1507HashMap<RegistrableDomain, WebsiteDataToRemove> ResourceLoadStatisticsDatabaseStore::registrableDomainsToRemoveWebsiteDataFor()
    14961508{
    14971509    ASSERT(!RunLoop::isMain());
     
    15051517    clearExpiredUserInteractions();
    15061518   
    1507     Vector<RegistrableDomain> prevalentResources;
     1519    HashMap<RegistrableDomain, WebsiteDataToRemove> domainsToRemoveWebsiteDataFor;
    15081520
    15091521    Vector<PrevalentDomainData> prevalentDomains = this->prevalentDomains();
    15101522    Vector<unsigned> domainIDsToClearGrandfathering;
    15111523    for (auto& statistic : prevalentDomains) {
    1512         if (!statistic.hadUserInteraction && (!shouldCheckForGrandfathering || !statistic.grandfathered))
    1513             prevalentResources.append(statistic.registerableDomain);
     1524        if (shouldRemoveAllWebsiteDataFor(statistic, shouldCheckForGrandfathering))
     1525            domainsToRemoveWebsiteDataFor.add(statistic.registerableDomain, WebsiteDataToRemove::All);
     1526        else if (shouldRemoveAllButCookiesFor(statistic, shouldCheckForGrandfathering))
     1527            domainsToRemoveWebsiteDataFor.add(statistic.registerableDomain, WebsiteDataToRemove::AllButCookies);
    15141528
    15151529        if (shouldClearGrandfathering && statistic.grandfathered)
     
    15191533    clearGrandfathering(WTFMove(domainIDsToClearGrandfathering));
    15201534   
    1521     return prevalentResources;
     1535    return domainsToRemoveWebsiteDataFor;
    15221536}
    15231537
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h

    r242738 r243181  
    102102
    103103    void clearUserInteraction(const RegistrableDomain&) override;
    104     bool hasHadUserInteraction(const RegistrableDomain&) override;
     104    bool hasHadUserInteraction(const RegistrableDomain&, OperatingDatesWindow) override;
    105105
    106106    void setLastSeen(const RegistrableDomain&, Seconds) override;
     
    159159    enum class AddedRecord { No, Yes };
    160160    std::pair<AddedRecord, unsigned> ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain&);
    161     Vector<RegistrableDomain> registrableDomainsToRemoveWebsiteDataFor() override;
     161    bool shouldRemoveAllWebsiteDataFor(const PrevalentDomainData&, bool shouldCheckForGrandfathering) const;
     162    bool shouldRemoveAllButCookiesFor(const PrevalentDomainData&, bool shouldCheckForGrandfathering) const;
     163    HashMap<RegistrableDomain, WebsiteDataToRemove> registrableDomainsToRemoveWebsiteDataFor() override;
    162164    bool isDatabaseStore() const final { return true; }
    163165
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp

    r242764 r243181  
    4141#include <WebCore/NetworkStorageSession.h>
    4242#include <WebCore/ResourceLoadStatistics.h>
     43#include <WebCore/RuntimeEnabledFeatures.h>
    4344#include <wtf/CallbackAggregator.h>
    4445#include <wtf/DateMath.h>
     
    445446}
    446447
    447 bool ResourceLoadStatisticsMemoryStore::hasHadUserInteraction(const RegistrableDomain& domain)
     448bool ResourceLoadStatisticsMemoryStore::hasHadUserInteraction(const RegistrableDomain& domain, OperatingDatesWindow operatingDatesWindow)
    448449{
    449450    ASSERT(!RunLoop::isMain());
    450451
    451452    auto mapEntry = m_resourceStatisticsMap.find(domain);
    452     return mapEntry == m_resourceStatisticsMap.end() ? false: hasHadUnexpiredRecentUserInteraction(mapEntry->value);
     453    return mapEntry == m_resourceStatisticsMap.end() ? false: hasHadUnexpiredRecentUserInteraction(mapEntry->value, operatingDatesWindow);
    453454}
    454455
     
    786787}
    787788
    788 bool ResourceLoadStatisticsMemoryStore::hasHadUnexpiredRecentUserInteraction(ResourceLoadStatistics& resourceStatistic) const
    789 {
    790     ASSERT(!RunLoop::isMain());
    791 
    792     if (resourceStatistic.hadUserInteraction && hasStatisticsExpired(resourceStatistic)) {
     789bool ResourceLoadStatisticsMemoryStore::hasHadUnexpiredRecentUserInteraction(ResourceLoadStatistics& resourceStatistic, OperatingDatesWindow operatingDatesWindow) const
     790{
     791    ASSERT(!RunLoop::isMain());
     792
     793    if (resourceStatistic.hadUserInteraction && hasStatisticsExpired(resourceStatistic, operatingDatesWindow)) {
    793794        // Drop privacy sensitive data because we no longer need it.
    794795        // Set timestamp to 0 so that statistics merge will know
     
    802803}
    803804
    804 Vector<RegistrableDomain> ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor()
     805bool ResourceLoadStatisticsMemoryStore::shouldRemoveAllWebsiteDataFor(ResourceLoadStatistics& resourceStatistic, bool shouldCheckForGrandfathering) const
     806{
     807    return resourceStatistic.isPrevalentResource && !hasHadUnexpiredRecentUserInteraction(resourceStatistic, OperatingDatesWindow::Long) && (!shouldCheckForGrandfathering || !resourceStatistic.grandfathered);
     808}
     809
     810bool ResourceLoadStatisticsMemoryStore::shouldRemoveAllButCookiesFor(ResourceLoadStatistics& resourceStatistic, bool shouldCheckForGrandfathering) const
     811{
     812    return RuntimeEnabledFeatures::sharedFeatures().isITPFirstPartyWebsiteDataRemovalEnabled() && resourceStatistic.gotLinkDecorationFromPrevalentResource && !hasHadUnexpiredRecentUserInteraction(resourceStatistic, OperatingDatesWindow::Short) && (!shouldCheckForGrandfathering || !resourceStatistic.grandfathered);
     813}
     814
     815HashMap<RegistrableDomain, WebsiteDataToRemove> ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor()
    805816{
    806817    ASSERT(!RunLoop::isMain());
     
    812823        clearEndOfGrandfatheringTimeStamp();
    813824
    814     Vector<RegistrableDomain> prevalentResources;
     825    HashMap<RegistrableDomain, WebsiteDataToRemove> domainsToRemoveWebsiteDataFor;
    815826    for (auto& statistic : m_resourceStatisticsMap.values()) {
    816         if (statistic.isPrevalentResource && !hasHadUnexpiredRecentUserInteraction(statistic) && (!shouldCheckForGrandfathering || !statistic.grandfathered))
    817             prevalentResources.append(statistic.registrableDomain);
     827        if (shouldRemoveAllWebsiteDataFor(statistic, shouldCheckForGrandfathering))
     828            domainsToRemoveWebsiteDataFor.add(statistic.registrableDomain, WebsiteDataToRemove::All);
     829        else if (shouldRemoveAllButCookiesFor(statistic, shouldCheckForGrandfathering)) {
     830            domainsToRemoveWebsiteDataFor.add(statistic.registrableDomain, WebsiteDataToRemove::AllButCookies);
     831            statistic.gotLinkDecorationFromPrevalentResource = false;
     832        }
    818833
    819834        if (shouldClearGrandfathering && statistic.grandfathered)
     
    821836    }
    822837
    823     return prevalentResources;
     838    return domainsToRemoveWebsiteDataFor;
    824839}
    825840
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h

    r242738 r243181  
    107107
    108108    void clearUserInteraction(const RegistrableDomain&) override;
    109     bool hasHadUserInteraction(const RegistrableDomain&) override;
     109    bool hasHadUserInteraction(const RegistrableDomain&, OperatingDatesWindow) override;
    110110
    111111    void setLastSeen(const RegistrableDomain&, Seconds) override;
     
    115115    static bool shouldBlockAndPurgeCookies(const ResourceLoadStatistics&);
    116116    static bool hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics&, const RegistrableDomain&);
    117     bool hasHadUnexpiredRecentUserInteraction(ResourceLoadStatistics&) const;
     117    bool hasHadUnexpiredRecentUserInteraction(ResourceLoadStatistics&, OperatingDatesWindow) const;
     118    bool shouldRemoveAllWebsiteDataFor(ResourceLoadStatistics&, bool shouldCheckForGrandfathering) const;
     119    bool shouldRemoveAllButCookiesFor(ResourceLoadStatistics&, bool shouldCheckForGrandfathering) const;
    118120    bool wasAccessedAsFirstPartyDueToUserInteraction(const ResourceLoadStatistics& current, const ResourceLoadStatistics& updated) const;
    119121    void incrementRecordsDeletedCountForDomains(HashSet<RegistrableDomain>&&) override;
     
    127129    void pruneStatisticsIfNeeded() override;
    128130    ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain&);
    129     Vector<RegistrableDomain> registrableDomainsToRemoveWebsiteDataFor() override;
     131    HashMap<RegistrableDomain, WebsiteDataToRemove> registrableDomainsToRemoveWebsiteDataFor() override;
    130132    bool isMemoryStore() const final { return true; }
    131 
    132133
    133134    WeakPtr<ResourceLoadStatisticsPersistentStorage> m_persistentStorage;
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp

    r242712 r243181  
    5151
    5252constexpr Seconds minimumStatisticsProcessingInterval { 5_s };
    53 constexpr unsigned operatingDatesWindow { 30 };
     53constexpr unsigned operatingDatesWindowLong { 30 };
     54constexpr unsigned operatingDatesWindowShort { 7 };
    5455
    5556#if !RELEASE_LOG_DISABLED
     
    6162            builder.appendLiteral(", ");
    6263        builder.append(domain.string());
     64    }
     65    return builder.toString();
     66}
     67
     68static String domainsToString(const HashMap<RegistrableDomain, WebsiteDataToRemove>& domainsToRemoveWebsiteDataFor)
     69{
     70    StringBuilder builder;
     71    for (auto& domain : domainsToRemoveWebsiteDataFor.keys()) {
     72        if (!builder.isEmpty())
     73            builder.appendLiteral(", ");
     74        builder.append(domain.string());
     75        switch (domainsToRemoveWebsiteDataFor.get(domain)) {
     76        case WebsiteDataToRemove::All:
     77            builder.appendLiteral("(all data)");
     78            break;
     79        case WebsiteDataToRemove::AllButHttpOnlyCookies:
     80            builder.appendLiteral("(all but HttpOnly cookies)");
     81            break;
     82        case WebsiteDataToRemove::AllButCookies:
     83            builder.appendLiteral("(all but cookies)");
     84            break;
     85        }
    6386    }
    6487    return builder.toString();
     
    158181}
    159182
    160 void ResourceLoadStatisticsStore::removeDataRecords(CompletionHandler<void()>&& callback)
     183void ResourceLoadStatisticsStore::removeDataRecords(CompletionHandler<void()>&& completionHandler)
    161184{
    162185    ASSERT(!RunLoop::isMain());
    163186
    164187    if (!shouldRemoveDataRecords()) {
    165         callback();
     188        completionHandler();
    166189        return;
    167190    }
     
    173196#endif
    174197
    175     auto prevalentResourceDomains = registrableDomainsToRemoveWebsiteDataFor();
    176     if (prevalentResourceDomains.isEmpty()) {
    177         callback();
     198    auto domainsToRemoveWebsiteDataFor = registrableDomainsToRemoveWebsiteDataFor();
     199    if (domainsToRemoveWebsiteDataFor.isEmpty()) {
     200        completionHandler();
    178201        return;
    179202    }
    180203
    181204#if !RELEASE_LOG_DISABLED
    182     RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "About to remove data records for %{public}s.", domainsToString(prevalentResourceDomains).utf8().data());
     205    RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "About to remove data records for %{public}s.", domainsToString(domainsToRemoveWebsiteDataFor).utf8().data());
    183206#endif
    184207
    185208    setDataRecordsBeingRemoved(true);
    186209
    187     RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), callback = WTFMove(callback), weakThis = makeWeakPtr(*this), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable {
     210    RunLoop::main().dispatch([domainsToRemoveWebsiteDataFor = crossThreadCopy(domainsToRemoveWebsiteDataFor), completionHandler = WTFMove(completionHandler), weakThis = makeWeakPtr(*this), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable {
    188211        if (!weakThis) {
    189             callback();
     212            completionHandler();
    190213            return;
    191214        }
    192215
    193         weakThis->m_store.deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, IncludeHttpOnlyCookies::Yes, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<RegistrableDomain>& domainsWithDeletedWebsiteData) mutable {
    194             workQueue->dispatch([domainsWithDeletedWebsiteData = crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), weakThis = WTFMove(weakThis)] () mutable {
     216        weakThis->m_store.deleteWebsiteDataForRegistrableDomains(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(domainsToRemoveWebsiteDataFor), shouldNotifyPagesWhenDataRecordsWereScanned, [completionHandler = WTFMove(completionHandler), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<RegistrableDomain>& domainsWithDeletedWebsiteData) mutable {
     217            workQueue->dispatch([domainsWithDeletedWebsiteData = crossThreadCopy(domainsWithDeletedWebsiteData), completionHandler = WTFMove(completionHandler), weakThis = WTFMove(weakThis)] () mutable {
    195218                if (!weakThis) {
    196                     callback();
     219                    completionHandler();
    197220                    return;
    198221                }
    199222                weakThis->incrementRecordsDeletedCountForDomains(WTFMove(domainsWithDeletedWebsiteData));
    200223                weakThis->setDataRecordsBeingRemoved(false);
    201                 callback();
     224                completionHandler();
    202225#if !RELEASE_LOG_DISABLED
    203226                RELEASE_LOG_INFO_IF(weakThis->m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Done removing data records.");
     
    431454        return WallTime::now().secondsSinceEpoch() - m_parameters.timeToLiveUserInteraction.value();
    432455   
    433     if (m_operatingDates.size() >= operatingDatesWindow)
     456    if (m_operatingDates.size() >= operatingDatesWindowLong)
    434457        return m_operatingDates.first().secondsSinceEpoch();
    435458   
     
    449472    removeRepeatedElements(mergedDates);
    450473   
    451     // Drop old dates until the Vector size reaches operatingDatesWindow.
    452     while (mergedDates.size() > operatingDatesWindow)
     474    // Drop old dates until the Vector size reaches operatingDatesWindowLong.
     475    while (mergedDates.size() > operatingDatesWindowLong)
    453476        mergedDates.remove(0);
    454477   
     
    469492        return;
    470493
    471     while (m_operatingDates.size() >= operatingDatesWindow)
     494    while (m_operatingDates.size() >= operatingDatesWindowLong)
    472495        m_operatingDates.remove(0);
    473496
     
    475498}
    476499
    477 bool ResourceLoadStatisticsStore::hasStatisticsExpired(WallTime mostRecentUserInteractionTime) const
    478 {
    479     ASSERT(!RunLoop::isMain());
    480    
    481     if (m_operatingDates.size() >= operatingDatesWindow) {
     500bool ResourceLoadStatisticsStore::hasStatisticsExpired(WallTime mostRecentUserInteractionTime, OperatingDatesWindow operatingDatesWindow) const
     501{
     502    ASSERT(!RunLoop::isMain());
     503
     504    unsigned operatingDatesWindowInDays = (operatingDatesWindow == OperatingDatesWindow::Long ? operatingDatesWindowLong : operatingDatesWindowShort);
     505    if (m_operatingDates.size() >= operatingDatesWindowInDays) {
    482506        if (OperatingDate::fromWallTime(mostRecentUserInteractionTime) < m_operatingDates.first())
    483507            return true;
     
    493517}
    494518
    495 bool ResourceLoadStatisticsStore::hasStatisticsExpired(const ResourceLoadStatistics& resourceStatistic) const
    496 {
    497     return hasStatisticsExpired(resourceStatistic.mostRecentUserInteractionTime);
     519bool ResourceLoadStatisticsStore::hasStatisticsExpired(const ResourceLoadStatistics& resourceStatistic, OperatingDatesWindow operatingDatesWindow) const
     520{
     521    return hasStatisticsExpired(resourceStatistic.mostRecentUserInteractionTime, operatingDatesWindow);
    498522}
    499523
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h

    r242764 r243181  
    7272};
    7373
     74enum class OperatingDatesWindow : bool { Long, Short };
     75
    7476// This is always constructed / used / destroyed on the WebResourceLoadStatisticsStore's statistics queue.
    7577class ResourceLoadStatisticsStore : public CanMakeWeakPtr<ResourceLoadStatisticsStore> {
     
    169171
    170172    virtual void clearUserInteraction(const RegistrableDomain&) = 0;
    171     virtual bool hasHadUserInteraction(const RegistrableDomain&) = 0;
     173    virtual bool hasHadUserInteraction(const RegistrableDomain&, OperatingDatesWindow) = 0;
    172174
    173175    virtual void setLastSeen(const RegistrableDomain& primaryDomain, Seconds) = 0;
     
    189191    ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost);
    190192
    191     bool hasStatisticsExpired(const ResourceLoadStatistics&) const;
    192     bool hasStatisticsExpired(WallTime mostRecentUserInteractionTime) const;
     193    bool hasStatisticsExpired(const ResourceLoadStatistics&, OperatingDatesWindow) const;
     194    bool hasStatisticsExpired(WallTime mostRecentUserInteractionTime, OperatingDatesWindow) const;
    193195    void scheduleStatisticsProcessingRequestIfNecessary();
    194196    void mergeOperatingDates(Vector<OperatingDate>&&);
    195197    virtual Vector<RegistrableDomain> ensurePrevalentResourcesForDebugMode() = 0;
    196     virtual Vector<RegistrableDomain> registrableDomainsToRemoveWebsiteDataFor() = 0;
     198    virtual HashMap<RegistrableDomain, WebsiteDataToRemove> registrableDomainsToRemoveWebsiteDataFor() = 0;
    197199    virtual void pruneStatisticsIfNeeded() = 0;
    198200
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r242738 r243181  
    581581{
    582582    postTask([this, domain, completionHandler = WTFMove(completionHandler)]() mutable {
    583         bool hadUserInteraction = m_statisticsStore ? m_statisticsStore->hasHadUserInteraction(domain) : false;
     583        bool hadUserInteraction = m_statisticsStore ? m_statisticsStore->hasHadUserInteraction(domain, OperatingDatesWindow::Long) : false;
    584584        postTaskReply([hadUserInteraction, completionHandler = WTFMove(completionHandler)]() mutable {
    585585            completionHandler(hadUserInteraction);
     
    10131013}
    10141014
    1015 void WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<RegistrableDomain>&& domains, bool shouldNotifyPage, IncludeHttpOnlyCookies includeHttpOnlyCookies, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
     1015void WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, HashMap<RegistrableDomain, WebsiteDataToRemove>&& domainsToRemoveWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
    10161016{
    10171017    ASSERT(RunLoop::isMain());
    10181018   
    10191019    if (m_networkSession) {
    1020         m_networkSession->deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(dataTypes, WTFMove(domains), shouldNotifyPage, includeHttpOnlyCookies, WTFMove(completionHandler));
     1020        m_networkSession->deleteWebsiteDataForRegistrableDomains(dataTypes, WTFMove(domainsToRemoveWebsiteDataFor), shouldNotifyPage, WTFMove(completionHandler));
    10211021        return;
    10221022    }
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r242764 r243181  
    6161enum class ShouldIncludeLocalhost : bool { No, Yes };
    6262enum class EnableResourceLoadStatisticsDebugMode : bool { No, Yes };
     63enum class WebsiteDataToRemove : uint8_t {
     64    All,
     65    AllButHttpOnlyCookies,
     66    AllButCookies
     67};
    6368
    6469class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main>, public IPC::MessageReceiver {
     
    108113    void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&, CompletionHandler<void()>&&);
    109114    void clearUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&);
    110     void deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<RegistrableDomain>&&, bool shouldNotifyPage, WebCore::IncludeHttpOnlyCookies, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
     115    void deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, HashMap<RegistrableDomain, WebsiteDataToRemove>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
    111116    void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&);
    112117    bool grantStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r243110 r243181  
    314314
    315315    WebCore::RuntimeEnabledFeatures::sharedFeatures().setIsITPDatabaseEnabled(parameters.shouldEnableITPDatabase);
     316    WebCore::RuntimeEnabledFeatures::sharedFeatures().setIsITPFirstPartyWebsiteDataRemovalEnabled(parameters.isITPFirstPartyWebsiteDataRemovalEnabled);
    316317
    317318    SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle);
     
    12101211        ASSERT_NOT_REACHED();
    12111212   
     1213    if (auto* networkSession = this->networkSession(sessionID)) {
     1214        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     1215            resourceLoadStatistics->logCrossSiteLoadWithLinkDecoration(fromDomain, toDomain, WTFMove(completionHandler));
     1216        else
     1217            completionHandler();
     1218    } else {
     1219        ASSERT_NOT_REACHED();
     1220        completionHandler();
     1221    }
     1222}
     1223
     1224void NetworkProcess::setCrossSiteLoadWithLinkDecorationForTesting(PAL::SessionID sessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, CompletionHandler<void()>&& completionHandler)
     1225{
    12121226    if (auto* networkSession = this->networkSession(sessionID)) {
    12131227        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     
    15111525}
    15121526
    1513 void NetworkProcess::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, Vector<RegistrableDomain>&& domains, bool shouldNotifyPage, IncludeHttpOnlyCookies includeHttpOnlyCookies, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
     1527void NetworkProcess::deleteWebsiteDataForRegistrableDomains(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, HashMap<RegistrableDomain, WebsiteDataToRemove>&& domains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
    15141528{
    15151529    OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses;
     
    15531567    auto& websiteDataStore = callbackAggregator->m_websiteData;
    15541568
     1569    Vector<RegistrableDomain> domainsToDeleteCookiesFor;
     1570    Vector<RegistrableDomain> domainsToDeleteAllButHttpOnlyCookiesFor;
     1571    Vector<RegistrableDomain> domainsToDeleteAllButCookiesFor;
    15551572    Vector<String> hostnamesWithCookiesToDelete;
    15561573    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
     1574        for (auto& domain : domains.keys()) {
     1575            domainsToDeleteAllButCookiesFor.append(domain);
     1576            switch (domains.get(domain)) {
     1577            case WebsiteDataToRemove::All:
     1578                domainsToDeleteCookiesFor.append(domain);
     1579                break;
     1580            case WebsiteDataToRemove::AllButHttpOnlyCookies:
     1581                domainsToDeleteAllButHttpOnlyCookiesFor.append(domain);
     1582                break;
     1583            case WebsiteDataToRemove::AllButCookies:
     1584                // Already added.
     1585                break;
     1586            }
     1587        }
    15571588        if (auto* networkStorageSession = storageSession(sessionID)) {
    15581589            networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies);
    1559             hostnamesWithCookiesToDelete = filterForRegistrableDomains(domains, websiteDataStore.hostNamesWithCookies);
    1560             networkStorageSession->deleteCookiesForHostnames(hostnamesWithCookiesToDelete, includeHttpOnlyCookies);
     1590
     1591            hostnamesWithCookiesToDelete = filterForRegistrableDomains(domainsToDeleteCookiesFor, websiteDataStore.hostNamesWithCookies);
     1592            networkStorageSession->deleteCookiesForHostnames(hostnamesWithCookiesToDelete, WebCore::IncludeHttpOnlyCookies::Yes);
     1593
     1594            hostnamesWithCookiesToDelete = filterForRegistrableDomains(domainsToDeleteAllButHttpOnlyCookiesFor, websiteDataStore.hostNamesWithCookies);
     1595            networkStorageSession->deleteCookiesForHostnames(hostnamesWithCookiesToDelete, WebCore::IncludeHttpOnlyCookies::No);
    15611596        }
     1597    } else {
     1598        for (auto& domain : domains.keys())
     1599            domainsToDeleteAllButCookiesFor.append(domain);
    15621600    }
    15631601
     
    15671605        if (auto* networkStorageSession = storageSession(sessionID)) {
    15681606            getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache);
    1569             hostnamesWithHSTSToDelete = filterForRegistrableDomains(domains, websiteDataStore.hostNamesWithHSTSCache);
     1607            hostnamesWithHSTSToDelete = filterForRegistrableDomains(domainsToDeleteAllButCookiesFor, websiteDataStore.hostNamesWithHSTSCache);
    15701608            deleteHSTSCacheForHostNames(*networkStorageSession, hostnamesWithHSTSToDelete);
    15711609        }
     
    15821620   
    15831621    if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) {
    1584         CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, domains, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
     1622        CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, domainsToDeleteAllButCookiesFor, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
    15851623           
    1586             auto entriesToDelete = filterForRegistrableDomains(domains, entries);
     1624            auto entriesToDelete = filterForRegistrableDomains(domainsToDeleteAllButCookiesFor, entries);
    15871625
    15881626            callbackAggregator->m_websiteData.entries.appendVector(entriesToDelete);
     
    15971635    if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) {
    15981636        // FIXME: Pick the right database store based on the session ID.
    1599         postStorageTask(CrossThreadTask([this, sessionID, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), domains]() mutable {
    1600             RunLoop::main().dispatch([this, sessionID, domains = crossThreadCopy(domains), callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] {
     1637        postStorageTask(CrossThreadTask([this, sessionID, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), domainsToDeleteAllButCookiesFor]() mutable {
     1638            RunLoop::main().dispatch([this, sessionID, domainsToDeleteAllButCookiesFor = crossThreadCopy(domainsToDeleteAllButCookiesFor), callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] {
    16011639                Vector<SecurityOriginData> entriesToDelete;
    16021640                for (const auto& securityOrigin : securityOrigins) {
    1603                     if (!domains.contains(RegistrableDomain::uncheckedCreateFromHost(securityOrigin.host)))
     1641                    if (!domainsToDeleteAllButCookiesFor.contains(RegistrableDomain::uncheckedCreateFromHost(securityOrigin.host)))
    16041642                        continue;
    16051643
     
    16171655    path = m_swDatabasePaths.get(sessionID);
    16181656    if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) {
    1619         swServerForSession(sessionID).getOriginsWithRegistrations([this, sessionID, domains, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable {
     1657        swServerForSession(sessionID).getOriginsWithRegistrations([this, sessionID, domainsToDeleteAllButCookiesFor, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable {
    16201658            for (auto& securityOrigin : securityOrigins) {
    1621                 if (!domains.contains(RegistrableDomain::uncheckedCreateFromHost(securityOrigin.host)))
     1659                if (!domainsToDeleteAllButCookiesFor.contains(RegistrableDomain::uncheckedCreateFromHost(securityOrigin.host)))
    16221660                    continue;
    16231661                callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 });
     
    16291667   
    16301668    if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) {
    1631         fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, domains, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
     1669        fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, domainsToDeleteAllButCookiesFor, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
    16321670
    16331671            Vector<SecurityOriginData> entriesToDelete;
    16341672            for (auto& entry : entries) {
    1635                 if (!domains.contains(RegistrableDomain::uncheckedCreateFromHost(entry.origin.host)))
     1673                if (!domainsToDeleteAllButCookiesFor.contains(RegistrableDomain::uncheckedCreateFromHost(entry.origin.host)))
    16361674                    continue;
    16371675                entriesToDelete.append(entry.origin);
     
    16461684{
    16471685    OptionSet<WebsiteDataType> cookieType = WebsiteDataType::Cookies;
    1648 
    1649     deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(sessionID, cookieType, { domain }, true, includeHttpOnlyCookies ? IncludeHttpOnlyCookies::Yes : IncludeHttpOnlyCookies::No, [completionHandler = WTFMove(completionHandler)] (const HashSet<RegistrableDomain>& domainsDeletedFor) mutable {
     1686    HashMap<RegistrableDomain, WebsiteDataToRemove> toDeleteFor;
     1687    toDeleteFor.add(domain, includeHttpOnlyCookies ? WebsiteDataToRemove::All : WebsiteDataToRemove::AllButHttpOnlyCookies);
     1688    deleteWebsiteDataForRegistrableDomains(sessionID, cookieType, WTFMove(toDeleteFor), true, [completionHandler = WTFMove(completionHandler)] (const HashSet<RegistrableDomain>& domainsDeletedFor) mutable {
    16501689        UNUSED_PARAM(domainsDeletedFor);
    16511690        completionHandler();
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r243110 r243181  
    3333#include "NetworkHTTPSUpgradeChecker.h"
    3434#include "SandboxExtension.h"
     35#include "WebResourceLoadStatisticsStore.h"
    3536#include <WebCore/AdClickAttribution.h>
    3637#include <WebCore/ClientOrigin.h>
     
    206207    void clearPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
    207208    void clearUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
    208     void deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(PAL::SessionID, OptionSet<WebsiteDataType>, Vector<RegistrableDomain>&&, bool shouldNotifyPage, WebCore::IncludeHttpOnlyCookies, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
     209    void deleteWebsiteDataForRegistrableDomains(PAL::SessionID, OptionSet<WebsiteDataType>, HashMap<RegistrableDomain, WebsiteDataToRemove>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
    209210    void deleteCookiesForTesting(PAL::SessionID, RegistrableDomain, bool includeHttpOnlyCookies, CompletionHandler<void()>&&);
    210211    void dumpResourceLoadStatistics(PAL::SessionID, CompletionHandler<void(String)>&&);
     
    259260    void registrableDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&);
    260261    void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID, CompletionHandler<void()>&&);
     262    void setCrossSiteLoadWithLinkDecorationForTesting(PAL::SessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, CompletionHandler<void()>&&);
    261263    void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&);
    262264#endif
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r243110 r243181  
    137137    ResetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID) -> () Async
    138138    CommittedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, WebCore::RegistrableDomain fromDomain, WebCore::RegistrableDomain toDomain, uint64_t pageID) -> () Async
     139    SetCrossSiteLoadWithLinkDecorationForTesting(PAL::SessionID sessionID, WebCore::RegistrableDomain fromDomain, WebCore::RegistrableDomain toDomain) -> () Async
    139140    ResetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID) -> () Async
    140141    DeleteCookiesForTesting(PAL::SessionID sessionID, WebCore::RegistrableDomain domain, bool includeHttpOnlyCookies) -> () Async
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp

    r243143 r243181  
    9595    encoder << shouldEnableITPDatabase;
    9696    encoder << downloadMonitorSpeedMultiplier;
     97    encoder << isITPFirstPartyWebsiteDataRemovalEnabled;
    9798}
    9899
     
    225226        return false;
    226227    result.downloadMonitorSpeedMultiplier = *downloadMonitorSpeedMultiplier;
    227    
     228
     229    if (!decoder.decode(result.isITPFirstPartyWebsiteDataRemovalEnabled))
     230        return false;
     231
    228232    return true;
    229233}
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h

    r243143 r243181  
    112112#endif
    113113    bool shouldEnableITPDatabase { false };
     114    bool isITPFirstPartyWebsiteDataRemovalEnabled { true };
    114115    uint32_t downloadMonitorSpeedMultiplier { 1 };
    115116};
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r242891 r243181  
    126126}
    127127
    128 void NetworkSession::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<RegistrableDomain>&& domains, bool shouldNotifyPage, IncludeHttpOnlyCookies includeHttpOnlyCookies, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
     128void NetworkSession::deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, HashMap<RegistrableDomain, WebsiteDataToRemove>&& domains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
    129129{
    130     m_networkProcess->deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(m_sessionID, dataTypes, WTFMove(domains), shouldNotifyPage, includeHttpOnlyCookies, WTFMove(completionHandler));
     130    m_networkProcess->deleteWebsiteDataForRegistrableDomains(m_sessionID, dataTypes, WTFMove(domains), shouldNotifyPage, WTFMove(completionHandler));
    131131}
    132132
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r242764 r243181  
    7575    void setResourceLoadStatisticsEnabled(bool);
    7676    void notifyResourceLoadStatisticsProcessed();
    77     void deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<WebCore::RegistrableDomain>&&, bool shouldNotifyPage, WebCore::IncludeHttpOnlyCookies, CompletionHandler<void(const HashSet<WebCore::RegistrableDomain>&)>&&);
     77    void deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, HashMap<WebCore::RegistrableDomain, WebsiteDataToRemove>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<WebCore::RegistrableDomain>&)>&&);
    7878    void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<WebCore::RegistrableDomain>&&)>&&);
    7979    void logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample);
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r243046 r243181  
    13821382  category: experimental
    13831383
     1384IsITPFirstPartyWebsiteDataRemovalEnabled:
     1385    type: bool
     1386    defaultValue: DEFAULT_EXPERIMENTAL_FEATURES_ENABLED
     1387    humanReadableName: "ITP First Party Website Data Removal"
     1388    humanReadableDescription: "Enable Intelligent Tracking Prevention First Party Website Data Removal"
     1389    webcoreBinding: RuntimeEnabledFeatures
     1390    category: experimental
     1391
    13841392# For internal features:
    13851393# The type should be boolean.
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r242712 r243181  
    298298}
    299299
    300 void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds)
    301 {
    302 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    303     WebKit::toImpl(dataStoreRef)->websiteDataStore().setTimeToLiveUserInteraction(Seconds { seconds }, [] { });
    304 #endif
    305 }
    306 
    307 void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef)
    308 {
    309 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    310     WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleStatisticsAndDataRecordsProcessing([] { });
     300void WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecoration(WKWebsiteDataStoreRef dataStoreRef, WKStringRef fromHost, WKStringRef toHost, void* context, WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecorationFunction callback)
     301{
     302#if ENABLE(RESOURCE_LOAD_STATISTICS)
     303    WebKit::toImpl(dataStoreRef)->websiteDataStore().setCrossSiteLoadWithLinkDecorationForTesting(URL(URL(), WebKit::toImpl(fromHost)->string()), URL(URL(), WebKit::toImpl(toHost)->string()), [context, callback] {
     304        callback(context);
     305    });
     306#else
     307    callback(context);
     308#endif
     309}
     310
     311void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds, void* context, WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteractionFunction callback)
     312{
     313#if ENABLE(RESOURCE_LOAD_STATISTICS)
     314    WebKit::toImpl(dataStoreRef)->websiteDataStore().setTimeToLiveUserInteraction(Seconds { seconds }, [context, callback] {
     315        callback(context);
     316    });
     317#else
     318    callback(context);
     319#endif
     320}
     321
     322void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecordsFunction callback)
     323{
     324#if ENABLE(RESOURCE_LOAD_STATISTICS)
     325    WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleStatisticsAndDataRecordsProcessing([context, callback] {
     326        callback(context);
     327    });
     328#else
     329    callback(context);
    311330#endif
    312331}
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r242712 r243181  
    7474WK_EXPORT void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo);
    7575WK_EXPORT void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom);
    76 WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds);
    77 WK_EXPORT void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef);
     76typedef void (*WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecorationFunction)(void* functionContext);
     77WK_EXPORT void WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecoration(WKWebsiteDataStoreRef dataStoreRef, WKStringRef fromHost, WKStringRef toHost, void* context, WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecorationFunction callback);
     78typedef void (*WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteractionFunction)(void* functionContext);
     79WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds, void* context, WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteractionFunction callback);
     80typedef void (*WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecordsFunction)(void* functionContext);
     81WK_EXPORT void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecordsFunction callback);
    7882typedef void (*WKWebsiteDataStoreStatisticsUpdateCookieBlockingFunction)(void* functionContext);
    7983WK_EXPORT void WKWebsiteDataStoreStatisticsUpdateCookieBlocking(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsUpdateCookieBlockingFunction completionHandler);
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r243143 r243181  
    308308    parameters.shouldEnableITPDatabase = [defaults boolForKey:[NSString stringWithFormat:@"InternalDebug%@", WebPreferencesKey::isITPDatabaseEnabledKey().createCFString().get()]];
    309309    parameters.downloadMonitorSpeedMultiplier = m_configuration->downloadMonitorSpeedMultiplier();
     310
     311    // Check if the feature has been turned off explicitly. This avoids interpreting
     312    // a non-existing default as a false value.
     313    auto isITPFirstPartyWebsiteDataRemovalEnabledStr = [defaults stringForKey:[NSString stringWithFormat:@"Experimental%@", WebPreferencesKey::isITPFirstPartyWebsiteDataRemovalEnabledKey().createCFString().get()]];
     314    if ([isITPFirstPartyWebsiteDataRemovalEnabledStr isEqual:@"0"])
     315        parameters.isITPFirstPartyWebsiteDataRemovalEnabled = false;
    310316}
    311317
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r243110 r243181  
    963963}
    964964
     965void NetworkProcessProxy::setCrossSiteLoadWithLinkDecorationForTesting(PAL::SessionID sessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, CompletionHandler<void()>&& completionHandler)
     966{
     967    if (!canSendMessage()) {
     968        completionHandler();
     969        return;
     970    }
     971   
     972    sendWithAsyncReply(Messages::NetworkProcess::SetCrossSiteLoadWithLinkDecorationForTesting(sessionID, fromDomain, toDomain), WTFMove(completionHandler));
     973}
     974
    965975void NetworkProcessProxy::resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
    966976{
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r243110 r243181  
    147147    void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&);
    148148    void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const NavigatedFromDomain&, const NavigatedToDomain&, PageID, CompletionHandler<void()>&&);
     149    void setCrossSiteLoadWithLinkDecorationForTesting(PAL::SessionID, const NavigatedFromDomain&, const NavigatedToDomain&, CompletionHandler<void()>&&);
    149150    void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&);
    150151    void deleteCookiesForTesting(PAL::SessionID, const RegistrableDomain&, bool includeHttpOnlyCookies, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r242738 r243181  
    17651765}
    17661766
     1767void WebsiteDataStore::setCrossSiteLoadWithLinkDecorationForTesting(const URL& fromURL, const URL& toURL, CompletionHandler<void()>&& completionHandler)
     1768{
     1769    ASSERT(RunLoop::isMain());
     1770   
     1771    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1772   
     1773    for (auto& processPool : processPools()) {
     1774        if (auto* process = processPool->networkProcess())
     1775            process->setCrossSiteLoadWithLinkDecorationForTesting(m_sessionID, RegistrableDomain { fromURL }, RegistrableDomain { toURL }, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1776    }
     1777}
     1778
    17671779void WebsiteDataStore::resetCrossSiteLoadsWithLinkDecorationForTesting(CompletionHandler<void()>&& completionHandler)
    17681780{
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r242738 r243181  
    169169    void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
    170170    void setSubframeUnderTopFrameDomain(const URL& subframe, const URL& topFrame);
     171    void setCrossSiteLoadWithLinkDecorationForTesting(const URL& fromURL, const URL& toURL, CompletionHandler<void()>&&);
    171172    void resetCrossSiteLoadsWithLinkDecorationForTesting(CompletionHandler<void()>&&);
    172173    void deleteCookiesForTesting(const URL&, bool includeHttpOnlyCookies, CompletionHandler<void()>&&);
  • trunk/Tools/ChangeLog

    r243179 r243181  
     12019-03-19  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Clear non-cookie website data for sites that have been navigated to, with link decoration, by a prevalent resource
     4        https://bugs.webkit.org/show_bug.cgi?id=195923
     5        <rdar://problem/49001272>
     6
     7        Reviewed by Alex Christensen.
     8
     9        This patch does the following to the TestRunner:
     10        - Adds setStatisticsCrossSiteLoadWithLinkDecoration().
     11        - Makes setStatisticsTimeToLiveUserInteraction() wait for completion.
     12        - Makes statisticsProcessStatisticsAndDataRecords() wait for completion.
     13
     14        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     15        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     16        (WTR::TestRunner::setStatisticsCrossSiteLoadWithLinkDecoration):
     17        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     18        * WebKitTestRunner/TestController.cpp:
     19        (WTR::TestController::setStatisticsCrossSiteLoadWithLinkDecoration):
     20        (WTR::TestController::setStatisticsTimeToLiveUserInteraction):
     21        (WTR::TestController::statisticsProcessStatisticsAndDataRecords):
     22        * WebKitTestRunner/TestController.h:
     23        * WebKitTestRunner/TestInvocation.cpp:
     24        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     25
    1262019-03-19  Christopher Reid  <chris.reid@sony.com>
    227
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r242727 r243181  
    304304    void setStatisticsTopFrameUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo);
    305305    void setStatisticsTopFrameUniqueRedirectFrom(DOMString hostName, DOMString hostNameRedirectedTo);
     306    void setStatisticsCrossSiteLoadWithLinkDecoration(DOMString fromHost, DOMString toHost);
    306307    void setStatisticsTimeToLiveUserInteraction(double seconds);
    307308    void statisticsNotifyObserver();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r242727 r243181  
    18521852}
    18531853
     1854void TestRunner::setStatisticsCrossSiteLoadWithLinkDecoration(JSStringRef fromHost, JSStringRef toHost)
     1855{
     1856    Vector<WKRetainPtr<WKStringRef>> keys;
     1857    Vector<WKRetainPtr<WKTypeRef>> values;
     1858   
     1859    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("FromHost") });
     1860    values.append({ AdoptWK, WKStringCreateWithJSString(fromHost) });
     1861   
     1862    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("ToHost") });
     1863    values.append({ AdoptWK, WKStringCreateWithJSString(toHost) });
     1864   
     1865    Vector<WKStringRef> rawKeys(keys.size());
     1866    Vector<WKTypeRef> rawValues(values.size());
     1867   
     1868    for (size_t i = 0; i < keys.size(); ++i) {
     1869        rawKeys[i] = keys[i].get();
     1870        rawValues[i] = values[i].get();
     1871    }
     1872   
     1873    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsCrossSiteLoadWithLinkDecoration"));
     1874    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
     1875    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1876}
    18541877
    18551878void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds)
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r242727 r243181  
    417417    void setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
    418418    void setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
     419    void setStatisticsCrossSiteLoadWithLinkDecoration(JSStringRef fromHost, JSStringRef toHost);
    419420    void setStatisticsTimeToLiveUserInteraction(double seconds);
    420421    void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r242727 r243181  
    32563256}
    32573257
     3258void TestController::setStatisticsCrossSiteLoadWithLinkDecoration(WKStringRef fromHost, WKStringRef toHost)
     3259{
     3260    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
     3261    ResourceStatisticsCallbackContext context(*this);
     3262    WKWebsiteDataStoreSetStatisticsCrossSiteLoadWithLinkDecoration(dataStore, fromHost, toHost, &context, resourceStatisticsVoidResultCallback);
     3263    runUntil(context.done, noTimeout);
     3264}
     3265
    32583266void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
    32593267{
    32603268    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    3261     WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(dataStore, seconds);
     3269    ResourceStatisticsCallbackContext context(*this);
     3270    WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(dataStore, seconds, &context, resourceStatisticsVoidResultCallback);
     3271    runUntil(context.done, noTimeout);
    32623272}
    32633273
     
    32653275{
    32663276    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
    3267     WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(dataStore);
     3277    ResourceStatisticsCallbackContext context(*this);
     3278    WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(dataStore, &context, resourceStatisticsVoidResultCallback);
     3279    runUntil(context.done, noTimeout);
    32683280}
    32693281
  • trunk/Tools/WebKitTestRunner/TestController.h

    r242727 r243181  
    226226    void setStatisticsTopFrameUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo);
    227227    void setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom);
     228    void setStatisticsCrossSiteLoadWithLinkDecoration(WKStringRef fromHost, WKStringRef toHost);
    228229    void setStatisticsTimeToLiveUserInteraction(double seconds);
    229230    void statisticsProcessStatisticsAndDataRecords();
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r242727 r243181  
    13051305    }
    13061306   
     1307    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsCrossSiteLoadWithLinkDecoration")) {
     1308        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     1309       
     1310        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     1311        auto fromHostKey = adoptWK(WKStringCreateWithUTF8CString("FromHost"));
     1312        auto toHostKey = adoptWK(WKStringCreateWithUTF8CString("ToHost"));
     1313
     1314        WKStringRef fromHost = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, fromHostKey.get()));
     1315        WKStringRef toHost = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, toHostKey.get()));
     1316       
     1317        TestController::singleton().setStatisticsCrossSiteLoadWithLinkDecoration(fromHost, toHost);
     1318        return nullptr;
     1319    }
     1320
    13071321    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveUserInteraction")) {
    13081322        ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
Note: See TracChangeset for help on using the changeset viewer.