Changeset 251213 in webkit


Ignore:
Timestamp:
Oct 16, 2019 3:38:55 PM (5 years ago)
Author:
wilander@apple.com
Message:

Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction
https://bugs.webkit.org/show_bug.cgi?id=203017
<rdar://problem/56262708>

Reviewed by Alex Christensen.

Source/WebCore:

NetworkStorageSession::shouldBlockCookies() now checks if the first-party website has
received user interaction and if not, blocks all third-party cookies, regardless of the
status of those third-party domains (prevalent or not).

Bundled cleanup task: Remove the two month old feature flag for NSURLSession switching.

Tests: http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html

http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html

  • page/RuntimeEnabledFeatures.h:

(WebCore::RuntimeEnabledFeatures::setIsITPSessionSwitchingEnabled): Deleted.
(WebCore::RuntimeEnabledFeatures::isITPSessionSwitchingEnabled const): Deleted.

  • page/Settings.yaml:
  • platform/network/NetworkStorageSession.cpp:

(WebCore::NetworkStorageSession::hasHadUserInteractionAsFirstParty const):
(WebCore::NetworkStorageSession::shouldBlockCookies const):
(WebCore::NetworkStorageSession::setDomainsWithUserInteractionAsFirstParty):

  • platform/network/NetworkStorageSession.h:

(WebCore::NetworkStorageSession::setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled):

Source/WebKit:

This enhancement is off by default and controlled by an internal feature flag.

The functional change is in WebCore::NetworkStorageSession::shouldBlockCookies() which is
called from:

  • NetworkDataTaskCocoa::NetworkDataTaskCocoa()
  • NetworkDataTaskCocoa::willPerformHTTPRedirection

shouldBlockCookies() now checks if the first-party website has received user interaction
and if not, blocks all third-party cookies, regardless of the status of those third-party
domains (prevalent or not).

The changes to ResourceLoadStatisticsDatabaseStore and ResourceLoadStatisticsMemoryStore
are about communicating which domains have received user interaction (prevalent or not)
to the network storage session so that it can enforce the new restriction.

The C API change and piping through the WebsiteDataStore is test infrastructure.

Bundled cleanup task: Remove the two month old feature flag for NSURLSession switching.

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:

(WebKit::CompletionHandler<void):

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

(WebKit::ResourceLoadStatisticsMemoryStore::clear):
(WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking):

  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:

(WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):

  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:

(WebKit::RegistrableDomainsToBlockCookiesFor::isolatedCopy const):

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::setShouldBlockThirdPartyCookiesForTesting):

  • NetworkProcess/NetworkProcess.messages.in:
  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::NetworkSession):

  • NetworkProcess/NetworkSession.h:

(WebKit::NetworkSession::setResourceLoadStatisticsLogTestingEvent):
(WebKit::NetworkSession::shouldIsolateSessionsForPrevalentTopFrames const): Deleted.

  • NetworkProcess/NetworkSessionCreationParameters.cpp:

(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):

  • NetworkProcess/NetworkSessionCreationParameters.h:
  • NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:

(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):

  • NetworkProcess/cocoa/NetworkSessionCocoa.mm:

(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):

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

(WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting):
(WKWebsiteDataStoreStatisticsResetToConsistentState):

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

(WebKit::NetworkProcessProxy::setShouldBlockThirdPartyCookiesForTesting):

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:

(WebKit::WebsiteDataStore::parameters):

  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

These changes are test infrastructure to be able to toggle the function
through testRunner.setStatisticsShouldBlockThirdPartyCookies().

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

(WTR::InjectedBundle::didReceiveMessageToPage):

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setStatisticsShouldBlockThirdPartyCookies):
(WTR::TestRunner::statisticsCallDidSetShouldBlockThirdPartyCookiesCallback):

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

(WTR::TestController::setStatisticsShouldBlockThirdPartyCookies):

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

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
(WTR::TestInvocation::didSetShouldBlockThirdPartyCookies):

  • WebKitTestRunner/TestInvocation.h:

LayoutTests:

  • http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database-expected.txt: Added.
  • http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html: Added.
  • http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-expected.txt: Added.
  • http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html: Added.
Location:
trunk
Files:
4 added
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r251189 r251213  
     12019-10-16  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction
     4        https://bugs.webkit.org/show_bug.cgi?id=203017
     5        <rdar://problem/56262708>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database-expected.txt: Added.
     10        * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html: Added.
     11        * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-expected.txt: Added.
     12        * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html: Added.
     13
    1142019-10-16  Russell Epstein  <repstein@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r251211 r251213  
     12019-10-16  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction
     4        https://bugs.webkit.org/show_bug.cgi?id=203017
     5        <rdar://problem/56262708>
     6
     7        Reviewed by Alex Christensen.
     8
     9        NetworkStorageSession::shouldBlockCookies() now checks if the first-party website has
     10        received user interaction and if not, blocks all third-party cookies, regardless of the
     11        status of those third-party domains (prevalent or not).
     12
     13        Bundled cleanup task: Remove the two month old feature flag for NSURLSession switching.
     14
     15        Tests: http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html
     16               http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html
     17
     18        * page/RuntimeEnabledFeatures.h:
     19        (WebCore::RuntimeEnabledFeatures::setIsITPSessionSwitchingEnabled): Deleted.
     20        (WebCore::RuntimeEnabledFeatures::isITPSessionSwitchingEnabled const): Deleted.
     21        * page/Settings.yaml:
     22        * platform/network/NetworkStorageSession.cpp:
     23        (WebCore::NetworkStorageSession::hasHadUserInteractionAsFirstParty const):
     24        (WebCore::NetworkStorageSession::shouldBlockCookies const):
     25        (WebCore::NetworkStorageSession::setDomainsWithUserInteractionAsFirstParty):
     26        * platform/network/NetworkStorageSession.h:
     27        (WebCore::NetworkStorageSession::setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled):
     28
    1292019-10-16  Zalan Bujtas  <zalan@apple.com>
    230
  • trunk/Source/WebCore/page/RuntimeEnabledFeatures.h

    r250969 r251213  
    147147    void setIsITPDatabaseEnabled(bool isEnabled) { m_isITPDatabaseEnabled = isEnabled; }
    148148    bool isITPDatabaseEnabled() const { return m_isITPDatabaseEnabled; }
    149 
    150     void setIsITPSessionSwitchingEnabled(bool isEnabled) { m_isITPSessionSwitchingEnabled = isEnabled; }
    151     bool isITPSessionSwitchingEnabled() const { return m_isITPSessionSwitchingEnabled; }
    152149
    153150    void setRestrictedHTTPResponseAccess(bool isEnabled) { m_isRestrictedHTTPResponseAccess = isEnabled; }
     
    421418    bool m_ariaReflectionEnabled { true };
    422419    bool m_itpDebugMode { false };
    423     bool m_isITPSessionSwitchingEnabled { true };
    424420    bool m_isRestrictedHTTPResponseAccess { true };
    425421    bool m_crossOriginResourcePolicyEnabled { true };
  • trunk/Source/WebCore/page/Settings.yaml

    r251204 r251213  
    870870  inspectorOverride: true
    871871
    872 isITPSessionSwitchingEnabled:
    873   initial: true
     872isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled:
     873  initial: false
    874874
    875875isLoggedInAPIEnabled:
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp

    r250287 r251213  
    7979}
    8080
     81bool NetworkStorageSession::hasHadUserInteractionAsFirstParty(const RegistrableDomain& registrableDomain) const
     82{
     83    if (registrableDomain.isEmpty())
     84        return false;
     85
     86    return m_registrableDomainsWithUserInteractionAsFirstParty.contains(registrableDomain);
     87}
     88
    8189bool NetworkStorageSession::shouldBlockCookies(const ResourceRequest& request, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID) const
    8290{
     
    99107    if (pageID && hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID.value()))
    100108        return false;
     109
     110    if (m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled && !hasHadUserInteractionAsFirstParty(firstPartyDomain))
     111        return true;
    101112
    102113    return shouldBlockThirdPartyCookies(resourceDomain);
     
    126137    m_registrableDomainsToBlockButKeepCookiesFor.clear();
    127138    m_registrableDomainsToBlockButKeepCookiesFor.add(domains.begin(), domains.end());
     139}
     140
     141void NetworkStorageSession::setDomainsWithUserInteractionAsFirstParty(const Vector<RegistrableDomain>& domains)
     142{
     143    m_registrableDomainsWithUserInteractionAsFirstParty.clear();
     144    m_registrableDomainsWithUserInteractionAsFirstParty.add(domains.begin(), domains.end());
    128145}
    129146
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.h

    r250589 r251213  
    148148    WEBCORE_EXPORT bool shouldBlockThirdPartyCookies(const RegistrableDomain&) const;
    149149    WEBCORE_EXPORT bool shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(const RegistrableDomain&) const;
     150    WEBCORE_EXPORT bool hasHadUserInteractionAsFirstParty(const RegistrableDomain&) const;
    150151    WEBCORE_EXPORT void setPrevalentDomainsToBlockAndDeleteCookiesFor(const Vector<RegistrableDomain>&);
    151152    WEBCORE_EXPORT void setPrevalentDomainsToBlockButKeepCookiesFor(const Vector<RegistrableDomain>&);
     153    WEBCORE_EXPORT void setDomainsWithUserInteractionAsFirstParty(const Vector<RegistrableDomain>&);
    152154    WEBCORE_EXPORT void setAgeCapForClientSideCookies(Optional<Seconds>);
    153155    WEBCORE_EXPORT void removePrevalentDomains(const Vector<RegistrableDomain>& domains);
     
    163165    WEBCORE_EXPORT void didCommitCrossSiteLoadWithDataTransferFromPrevalentResource(const RegistrableDomain& toDomain, PageIdentifier);
    164166    WEBCORE_EXPORT void resetCrossSiteLoadsWithLinkDecorationForTesting();
     167    void setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled(bool enabled) { m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled = enabled; }
    165168#endif
    166169
     
    189192    HashSet<RegistrableDomain> m_registrableDomainsToBlockAndDeleteCookiesFor;
    190193    HashSet<RegistrableDomain> m_registrableDomainsToBlockButKeepCookiesFor;
     194    HashSet<RegistrableDomain> m_registrableDomainsWithUserInteractionAsFirstParty;
    191195    HashMap<PageIdentifier, HashMap<FrameIdentifier, RegistrableDomain>> m_framesGrantedStorageAccess;
    192196    HashMap<PageIdentifier, HashMap<RegistrableDomain, RegistrableDomain>> m_pagesGrantedStorageAccess;
     
    196200    HashMap<WebCore::PageIdentifier, RegistrableDomain> m_navigatedToWithLinkDecorationByPrevalentResource;
    197201    bool m_navigationWithLinkDecorationTestMode = false;
     202    bool m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled = false;
    198203#endif
    199204
  • trunk/Source/WebKit/ChangeLog

    r251212 r251213  
     12019-10-16  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction
     4        https://bugs.webkit.org/show_bug.cgi?id=203017
     5        <rdar://problem/56262708>
     6
     7        Reviewed by Alex Christensen.
     8
     9        This enhancement is off by default and controlled by an internal feature flag.
     10
     11        The functional change is in WebCore::NetworkStorageSession::shouldBlockCookies() which is
     12        called from:
     13        - NetworkDataTaskCocoa::NetworkDataTaskCocoa()
     14        - NetworkDataTaskCocoa::willPerformHTTPRedirection
     15
     16        shouldBlockCookies() now checks if the first-party website has received user interaction
     17        and if not, blocks all third-party cookies, regardless of the status of those third-party
     18        domains (prevalent or not).
     19
     20        The changes to ResourceLoadStatisticsDatabaseStore and ResourceLoadStatisticsMemoryStore
     21        are about communicating which domains have received user interaction (prevalent or not)
     22        to the network storage session so that it can enforce the new restriction.
     23
     24        The C API change and piping through the WebsiteDataStore is test infrastructure.
     25
     26        Bundled cleanup task: Remove the two month old feature flag for NSURLSession switching.
     27
     28        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
     29        (WebKit::CompletionHandler<void):
     30        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
     31        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
     32        (WebKit::ResourceLoadStatisticsMemoryStore::clear):
     33        (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking):
     34        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     35        (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
     36        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
     37        (WebKit::RegistrableDomainsToBlockCookiesFor::isolatedCopy const):
     38        * NetworkProcess/NetworkProcess.cpp:
     39        (WebKit::NetworkProcess::initializeNetworkProcess):
     40        (WebKit::NetworkProcess::setShouldBlockThirdPartyCookiesForTesting):
     41        * NetworkProcess/NetworkProcess.messages.in:
     42        * NetworkProcess/NetworkSession.cpp:
     43        (WebKit::NetworkSession::NetworkSession):
     44        * NetworkProcess/NetworkSession.h:
     45        (WebKit::NetworkSession::setResourceLoadStatisticsLogTestingEvent):
     46        (WebKit::NetworkSession::shouldIsolateSessionsForPrevalentTopFrames const): Deleted.
     47        * NetworkProcess/NetworkSessionCreationParameters.cpp:
     48        (WebKit::NetworkSessionCreationParameters::encode const):
     49        (WebKit::NetworkSessionCreationParameters::decode):
     50        * NetworkProcess/NetworkSessionCreationParameters.h:
     51        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
     52        (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
     53        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     54        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
     55        * Shared/WebPreferences.yaml:
     56        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     57        (WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting):
     58        (WKWebsiteDataStoreStatisticsResetToConsistentState):
     59        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     60        * UIProcess/Network/NetworkProcessProxy.cpp:
     61        (WebKit::NetworkProcessProxy::setShouldBlockThirdPartyCookiesForTesting):
     62        * UIProcess/Network/NetworkProcessProxy.h:
     63        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
     64        (WebKit::WebsiteDataStore::parameters):
     65        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     66        (WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting):
     67        * UIProcess/WebsiteData/WebsiteDataStore.h:
     68
    1692019-10-16  Kate Cheney  <katherine_cheney@apple.com>
    270
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp

    r251016 r251213  
    16811681
    16821682    auto registrableDomainsToBlockAndDeleteCookiesFor = ensurePrevalentResourcesForDebugMode();
    1683     RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { } };
     1683    RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { }, { } };
    16841684    updateCookieBlockingForDomains(domainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { });
    16851685}
     
    17531753}
    17541754
     1755Vector<RegistrableDomain> ResourceLoadStatisticsDatabaseStore::domainsWithUserInteractionAsFirstParty() const
     1756{
     1757    ASSERT(!RunLoop::isMain());
     1758
     1759    Vector<RegistrableDomain> results;
     1760    SQLiteStatement statement(m_database, "SELECT registrableDomain FROM ObservedDomains WHERE hadUserInteraction = 1"_s);
     1761    if (statement.prepare() != SQLITE_OK)
     1762        return results;
     1763   
     1764    while (statement.step() == SQLITE_ROW)
     1765        results.append(RegistrableDomain::uncheckedCreateFromRegistrableDomainString(statement.getColumnText(0)));
     1766
     1767    return results;
     1768}
     1769
    17551770void ResourceLoadStatisticsDatabaseStore::updateCookieBlocking(CompletionHandler<void()>&& completionHandler)
    17561771{
     
    17591774    auto domainsToBlockAndDeleteCookiesFor = this->domainsToBlockAndDeleteCookiesFor();
    17601775    auto domainsToBlockButKeepCookiesFor = this->domainsToBlockButKeepCookiesFor();
    1761 
    1762     if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty()) {
     1776    auto domainsWithUserInteractionAsFirstParty = this->domainsWithUserInteractionAsFirstParty();
     1777
     1778    if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty() && domainsWithUserInteractionAsFirstParty.isEmpty()) {
    17631779        completionHandler();
    17641780        return;
    17651781    }
    17661782
    1767     RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor };
     1783    RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor, domainsWithUserInteractionAsFirstParty };
    17681784
    17691785    if (debugLoggingEnabled() && !domainsToBlockAndDeleteCookiesFor.isEmpty() && !domainsToBlockButKeepCookiesFor.isEmpty())
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h

    r250866 r251213  
    156156    Vector<RegistrableDomain> domainsToBlockAndDeleteCookiesFor() const;
    157157    Vector<RegistrableDomain> domainsToBlockButKeepCookiesFor() const;
     158    Vector<RegistrableDomain> domainsWithUserInteractionAsFirstParty() const;
    158159
    159160    struct PrevalentDomainData {
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp

    r250621 r251213  
    698698
    699699    auto registrableDomainsToBlockAndDeleteCookiesFor = ensurePrevalentResourcesForDebugMode();
    700     RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { } };
     700    RegistrableDomainsToBlockCookiesFor domainsToBlock { registrableDomainsToBlockAndDeleteCookiesFor, { }, { } };
    701701    updateCookieBlockingForDomains(domainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { });
    702702}
     
    736736    Vector<RegistrableDomain> domainsToBlockAndDeleteCookiesFor;
    737737    Vector<RegistrableDomain> domainsToBlockButKeepCookiesFor;
     738    Vector<RegistrableDomain> domainsWithUserInteractionAsFirstParty;
    738739    for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
    739         if (resourceStatistic.isPrevalentResource) {
    740             if (hasHadUnexpiredRecentUserInteraction(resourceStatistic, OperatingDatesWindow::Long))
    741                 domainsToBlockButKeepCookiesFor.append(resourceStatistic.registrableDomain);
    742             else
    743                 domainsToBlockAndDeleteCookiesFor.append(resourceStatistic.registrableDomain);
    744         }
    745     }
    746 
    747     if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty() && !debugModeEnabled()) {
     740        if (hasHadUnexpiredRecentUserInteraction(resourceStatistic, OperatingDatesWindow::Long)) {
     741            if (resourceStatistic.isPrevalentResource)
     742                domainsToBlockButKeepCookiesFor.append(resourceStatistic.registrableDomain.isolatedCopy());
     743            domainsWithUserInteractionAsFirstParty.append(resourceStatistic.registrableDomain);
     744        } else if (resourceStatistic.isPrevalentResource)
     745            domainsToBlockAndDeleteCookiesFor.append(resourceStatistic.registrableDomain);
     746    }
     747
     748    if (domainsToBlockAndDeleteCookiesFor.isEmpty() && domainsToBlockButKeepCookiesFor.isEmpty() && domainsWithUserInteractionAsFirstParty.isEmpty() && !debugModeEnabled()) {
    748749        completionHandler();
    749750        return;
    750751    }
    751752
    752     RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor };
     753    RegistrableDomainsToBlockCookiesFor domainsToBlock { domainsToBlockAndDeleteCookiesFor, domainsToBlockButKeepCookiesFor, domainsWithUserInteractionAsFirstParty };
    753754
    754755    if (debugLoggingEnabled() && !domainsToBlockAndDeleteCookiesFor.isEmpty() && !domainsToBlockButKeepCookiesFor.isEmpty())
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r251176 r251213  
    966966            storageSession->setPrevalentDomainsToBlockAndDeleteCookiesFor(domainsToBlock.domainsToBlockAndDeleteCookiesFor);
    967967            storageSession->setPrevalentDomainsToBlockButKeepCookiesFor(domainsToBlock.domainsToBlockButKeepCookiesFor);
     968            storageSession->setDomainsWithUserInteractionAsFirstParty(domainsToBlock.domainsWithUserInteractionAsFirstParty);
    968969        }
    969970    }
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r250866 r251213  
    6666enum class ShouldIncludeLocalhost : bool { No, Yes };
    6767enum class EnableResourceLoadStatisticsDebugMode : bool { No, Yes };
    68 enum class EnableResourceLoadStatisticsNSURLSessionSwitching : bool { No, Yes };
    6968enum class WebsiteDataToRemove : uint8_t {
    7069    All,
     
    7574    Vector<WebCore::RegistrableDomain> domainsToBlockAndDeleteCookiesFor;
    7675    Vector<WebCore::RegistrableDomain> domainsToBlockButKeepCookiesFor;
    77     RegistrableDomainsToBlockCookiesFor isolatedCopy() const { return { domainsToBlockAndDeleteCookiesFor.isolatedCopy(), domainsToBlockButKeepCookiesFor.isolatedCopy() }; }
     76    Vector<WebCore::RegistrableDomain> domainsWithUserInteractionAsFirstParty;
     77    RegistrableDomainsToBlockCookiesFor isolatedCopy() const { return { domainsToBlockAndDeleteCookiesFor.isolatedCopy(), domainsToBlockButKeepCookiesFor.isolatedCopy(), domainsWithUserInteractionAsFirstParty.isolatedCopy() }; }
    7878};
    7979
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r251212 r251213  
    12591259    completionHandler();
    12601260}
     1261
     1262void NetworkProcess::setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID sessionID, bool enabled, CompletionHandler<void()>&& completionHandler)
     1263{
     1264    if (auto* networkStorageSession = storageSession(sessionID))
     1265        networkStorageSession->setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled(enabled);
     1266    else
     1267        ASSERT_NOT_REACHED();
     1268    completionHandler();
     1269}
    12611270#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
    12621271
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r251212 r251213  
    267267    bool isITPDatabaseEnabled() const { return m_isITPDatabaseEnabled; }
    268268    void setShouldDowngradeReferrerForTesting(bool, CompletionHandler<void()>&&);
     269    void setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID, bool, CompletionHandler<void()>&&);
    269270#endif
    270271
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r251212 r251213  
    138138    HasIsolatedSession(PAL::SessionID sessionID, WebCore::RegistrableDomain domain) -> (bool hasIsolatedSession) Async
    139139    SetShouldDowngradeReferrerForTesting(bool enabled) -> () Async
     140    SetShouldBlockThirdPartyCookiesForTesting(PAL::SessionID sessionID, bool enabled) -> () Async
    140141#endif
    141142
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r250866 r251213  
    9494    bool enableResourceLoadStatisticsLogTestingEvent() const { return m_enableResourceLoadStatisticsLogTestingEvent; }
    9595    void setResourceLoadStatisticsLogTestingEvent(bool log) { m_enableResourceLoadStatisticsLogTestingEvent = log; }
    96     bool shouldIsolateSessionsForPrevalentTopFrames() const { return m_enableResourceLoadStatisticsNSURLSessionSwitching == EnableResourceLoadStatisticsNSURLSessionSwitching::Yes; }
    9796    virtual bool hasIsolatedSession(const WebCore::RegistrableDomain) const { return false; }
    9897    virtual void clearIsolatedSessions() { }
    9998    void setShouldDowngradeReferrerForTesting(bool);
    10099    bool shouldDowngradeReferrer() const;
     100    void setShouldBlockThirdPartyCookiesForTesting(bool);
    101101#endif
    102102    void storeAdClickAttribution(WebCore::AdClickAttribution&&);
     
    141141    EnableResourceLoadStatisticsDebugMode m_enableResourceLoadStatisticsDebugMode { EnableResourceLoadStatisticsDebugMode::No };
    142142    WebCore::RegistrableDomain m_resourceLoadStatisticsManualPrevalentResource;
    143     EnableResourceLoadStatisticsNSURLSessionSwitching m_enableResourceLoadStatisticsNSURLSessionSwitching { EnableResourceLoadStatisticsNSURLSessionSwitching::No };
    144143    bool m_enableResourceLoadStatisticsLogTestingEvent;
    145144    bool m_downgradeReferrer { true };
  • trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp

    r250677 r251213  
    6969    encoder << enableResourceLoadStatisticsDebugMode;
    7070    encoder << resourceLoadStatisticsManualPrevalentResource;
    71     encoder << enableResourceLoadStatisticsNSURLSessionSwitching;
     71    encoder << enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction;
    7272
    7373    encoder << networkCacheDirectory << networkCacheDirectoryExtensionHandle;
     
    200200        return WTF::nullopt;
    201201
    202     Optional<bool> enableResourceLoadStatisticsNSURLSessionSwitching;
    203     decoder >> enableResourceLoadStatisticsNSURLSessionSwitching;
    204     if (!enableResourceLoadStatisticsNSURLSessionSwitching)
     202    Optional<bool> enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction;
     203    decoder >> enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction;
     204    if (!enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction)
    205205        return WTF::nullopt;
    206206
     
    283283        , WTFMove(*shouldIncludeLocalhostInResourceLoadStatistics)
    284284        , WTFMove(*enableResourceLoadStatisticsDebugMode)
    285         , WTFMove(*enableResourceLoadStatisticsNSURLSessionSwitching)
     285        , WTFMove(*enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction)
    286286        , WTFMove(*deviceManagementRestrictionsEnabled)
    287287        , WTFMove(*allLoadsBlockedByDeviceManagementRestrictionsForTesting)
  • trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h

    r250677 r251213  
    8686    bool shouldIncludeLocalhostInResourceLoadStatistics { true };
    8787    bool enableResourceLoadStatisticsDebugMode { false };
    88     bool enableResourceLoadStatisticsNSURLSessionSwitching { true };
     88    bool enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction { false };
    8989    bool deviceManagementRestrictionsEnabled { false };
    9090    bool allLoadsBlockedByDeviceManagementRestrictionsForTesting { false };
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

    r250413 r251213  
    214214        if (!shouldBlockCookies)
    215215            shouldBlockCookies = networkStorageSession->shouldBlockCookies(request, frameID, pageID);
    216         needsIsolatedSession = session.shouldIsolateSessionsForPrevalentTopFrames() && networkStorageSession->shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(firstParty);
     216        needsIsolatedSession = networkStorageSession->shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(firstParty);
    217217    }
    218218#endif
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r251021 r251213  
    11101110    m_enableResourceLoadStatisticsDebugMode = parameters.enableResourceLoadStatisticsDebugMode ? EnableResourceLoadStatisticsDebugMode::Yes : EnableResourceLoadStatisticsDebugMode::No;
    11111111    m_resourceLoadStatisticsManualPrevalentResource = parameters.resourceLoadStatisticsManualPrevalentResource;
    1112     m_enableResourceLoadStatisticsNSURLSessionSwitching = parameters.enableResourceLoadStatisticsNSURLSessionSwitching ? EnableResourceLoadStatisticsNSURLSessionSwitching::Yes : EnableResourceLoadStatisticsNSURLSessionSwitching::No;
     1112    storageSession->setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled(parameters.enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction);
    11131113    setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics);
    11141114#endif
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r251160 r251213  
    17661766  category: experimental
    17671767
    1768 IsITPSessionSwitchingEnabled:
    1769   type: bool
    1770   defaultValue: true
    1771   humanReadableName: "ITP Session Switching"
    1772   humanReadableDescription: "Enable session switching for domains classified by ITP"
    1773   webcoreBinding: RuntimeEnabledFeatures
     1768IsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled:
     1769  type: bool
     1770  defaultValue: false
     1771  humanReadableName: "Block 3rd-Party Cookies On Sites Without Interaction (ITP)"
     1772  humanReadableDescription: "Block all third-party cookies on websites without user interaction"
    17741773  category: internal
    17751774
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r251212 r251213  
    539539}
    540540
     541void WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTestingFunction completionHandler)
     542{
     543#if ENABLE(RESOURCE_LOAD_STATISTICS)
     544    WebKit::toImpl(dataStoreRef)->setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(enabled, [context, completionHandler] {
     545        completionHandler(context);
     546    });
     547#else
     548    completionHandler(context);
     549#endif
     550}
     551
    541552void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler)
    542553{
     
    551562    store.resetCrossSiteLoadsWithLinkDecorationForTesting([callbackAggregator = callbackAggregator.copyRef()] { });
    552563    store.setResourceLoadStatisticsShouldDowngradeReferrerForTesting(true, [callbackAggregator = callbackAggregator.copyRef()] { });
     564    store.setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(false, [callbackAggregator = callbackAggregator.copyRef()] { });
    553565    store.resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { });
    554566    store.scheduleClearInMemoryAndPersistent(WebKit::ShouldGrandfatherStatistics::No, [callbackAggregator = callbackAggregator.copyRef()] { });
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r251212 r251213  
    118118typedef void (*WKWebsiteDataStoreSetResourceLoadStatisticsShouldDowngradeReferrerForTestingFunction)(void* functionContext);
    119119WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsShouldDowngradeReferrerForTesting(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsShouldDowngradeReferrerForTestingFunction completionHandler);
     120typedef void (*WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTestingFunction)(void* functionContext);
     121WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTestingFunction completionHandler);
    120122typedef void (*WKWebsiteDataStoreStatisticsResetToConsistentStateFunction)(void* functionContext);
    121123WK_EXPORT void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler);
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r251212 r251213  
    10551055    sendWithAsyncReply(Messages::NetworkProcess::SetShouldDowngradeReferrerForTesting(enabled), WTFMove(completionHandler));
    10561056}
     1057
     1058void NetworkProcessProxy::setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID sessionID, bool enabled, CompletionHandler<void()>&& completionHandler)
     1059{
     1060    if (!canSendMessage()) {
     1061        completionHandler();
     1062        return;
     1063    }
     1064   
     1065    sendWithAsyncReply(Messages::NetworkProcess::SetShouldBlockThirdPartyCookiesForTesting(sessionID, enabled), WTFMove(completionHandler));
     1066}
    10571067#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
    10581068
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r251212 r251213  
    156156    void hasIsolatedSession(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&);
    157157    void setShouldDowngradeReferrerForTesting(bool, CompletionHandler<void()>&&);
     158    void setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID, bool, CompletionHandler<void()>&&);
    158159#endif
    159160
  • trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm

    r251108 r251213  
    3030#import "SandboxUtilities.h"
    3131#import "StorageManager.h"
     32#import "WebPreferencesKeys.h"
    3233#import "WebResourceLoadStatisticsStore.h"
    3334#import "WebsiteDataStoreParameters.h"
     
    6970    bool shouldLogCookieInformation = false;
    7071    bool enableResourceLoadStatisticsDebugMode = false;
    71     bool enableResourceLoadStatisticsNSURLSessionSwitching = WebCore::RuntimeEnabledFeatures::sharedFeatures().isITPSessionSwitchingEnabled();
     72    bool enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction = false;
     73    bool enableLegacyTLS = [defaults boolForKey:@"WebKitEnableLegacyTLS"];
    7274    WebCore::RegistrableDomain resourceLoadStatisticsManualPrevalentResource { };
    73     bool enableLegacyTLS = [defaults boolForKey:@"WebKitEnableLegacyTLS"];
    7475#if ENABLE(RESOURCE_LOAD_STATISTICS)
    7576    enableResourceLoadStatisticsDebugMode = [defaults boolForKey:@"ITPDebugMode"];
     77    enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction = [defaults boolForKey:[NSString stringWithFormat:@"InternalDebug%@", WebPreferencesKey::isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabledKey().createCFString().get()]];
    7678    auto* manualPrevalentResource = [defaults stringForKey:@"ITPManualPrevalentResource"];
    7779    if (manualPrevalentResource) {
     
    137139        shouldIncludeLocalhostInResourceLoadStatistics,
    138140        enableResourceLoadStatisticsDebugMode,
    139         enableResourceLoadStatisticsNSURLSessionSwitching,
     141        enableThirdPartyCookieBlockingOnSitesWithoutUserInteraction,
    140142        m_configuration->deviceManagementRestrictionsEnabled(),
    141143        m_configuration->allLoadsBlockedByDeviceManagementRestrictionsForTesting(),
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r251212 r251213  
    17831783    ASSERT(!completionHandler);
    17841784}
     1785
     1786void WebsiteDataStore::setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(bool enabled, CompletionHandler<void()>&& completionHandler)
     1787{
     1788    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1789   
     1790    for (auto& processPool : processPools()) {
     1791        if (auto* networkProcess = processPool->networkProcess()) {
     1792            networkProcess->setShouldBlockThirdPartyCookiesForTesting(m_sessionID, enabled, [callbackAggregator = callbackAggregator.copyRef()] { });
     1793            ASSERT(processPools().size() == 1);
     1794            break;
     1795        }
     1796    }
     1797    ASSERT(!completionHandler);
     1798}
    17851799#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
    17861800
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r251212 r251213  
    193193    void hasIsolatedSessionForTesting(const URL&, CompletionHandler<void(bool)>&&) const;
    194194    void setResourceLoadStatisticsShouldDowngradeReferrerForTesting(bool, CompletionHandler<void()>&&);
     195    void setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(bool, CompletionHandler<void()>&&);
    195196#endif
    196197    void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&);
  • trunk/Tools/ChangeLog

    r251212 r251213  
     12019-10-16  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction
     4        https://bugs.webkit.org/show_bug.cgi?id=203017
     5        <rdar://problem/56262708>
     6
     7        Reviewed by Alex Christensen.
     8
     9        These changes are test infrastructure to be able to toggle the function
     10        through testRunner.setStatisticsShouldBlockThirdPartyCookies().
     11
     12        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     13        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     14        (WTR::InjectedBundle::didReceiveMessageToPage):
     15        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     16        (WTR::TestRunner::setStatisticsShouldBlockThirdPartyCookies):
     17        (WTR::TestRunner::statisticsCallDidSetShouldBlockThirdPartyCookiesCallback):
     18        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     19        * WebKitTestRunner/TestController.cpp:
     20        (WTR::TestController::setStatisticsShouldBlockThirdPartyCookies):
     21        * WebKitTestRunner/TestController.h:
     22        * WebKitTestRunner/TestInvocation.cpp:
     23        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     24        (WTR::TestInvocation::didSetShouldBlockThirdPartyCookies):
     25        * WebKitTestRunner/TestInvocation.h:
     26
    1272019-10-16  Kate Cheney  <katherine_cheney@apple.com>
    228
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r251067 r251213  
    342342    boolean hasStatisticsIsolatedSession(DOMString hostName);
    343343    void setStatisticsShouldDowngradeReferrer(boolean value, object callback);
     344    void setStatisticsShouldBlockThirdPartyCookies(boolean value, object callback);
    344345
    345346    // Injected bundle form client.
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r251160 r251213  
    333333    }
    334334
     335    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetShouldBlockThirdPartyCookies")) {
     336        m_testRunner->statisticsCallDidSetShouldBlockThirdPartyCookiesCallback();
     337        return;
     338    }
     339
    335340    if (WKStringIsEqualToUTF8CString(messageName, "CallDidResetStatisticsToConsistentState")) {
    336341        m_testRunner->statisticsCallDidResetToConsistentStateCallback();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r251160 r251213  
    744744    StatisticsDidSetBlockCookiesForHostCallbackID,
    745745    StatisticsDidSetShouldDowngradeReferrerCallbackID,
     746    StatisticsDidSetShouldBlockThirdPartyCookiesCallbackID,
    746747    AllStorageAccessEntriesCallbackID,
    747748    DidRemoveAllSessionCredentialsCallbackID,
     
    22072208{
    22082209    callTestRunnerCallback(StatisticsDidSetShouldDowngradeReferrerCallbackID);
     2210}
     2211
     2212void TestRunner::setStatisticsShouldBlockThirdPartyCookies(bool value, JSValueRef completionHandler)
     2213{
     2214    if (m_hasSetBlockThirdPartyCookiesCallback)
     2215        return;
     2216   
     2217    cacheTestRunnerCallback(StatisticsDidSetShouldBlockThirdPartyCookiesCallbackID, completionHandler);
     2218    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsShouldBlockThirdPartyCookies"));
     2219    WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value));
     2220    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     2221    m_hasSetBlockThirdPartyCookiesCallback = true;
     2222}
     2223
     2224void TestRunner::statisticsCallDidSetShouldBlockThirdPartyCookiesCallback()
     2225{
     2226    callTestRunnerCallback(StatisticsDidSetShouldBlockThirdPartyCookiesCallbackID);
    22092227}
    22102228
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r251160 r251213  
    441441    void setStatisticsShouldDowngradeReferrer(bool, JSValueRef callback);
    442442    void statisticsCallDidSetShouldDowngradeReferrerCallback();
     443    void setStatisticsShouldBlockThirdPartyCookies(bool, JSValueRef callback);
     444    void statisticsCallDidSetShouldBlockThirdPartyCookiesCallback();
    443445    void statisticsResetToConsistentState(JSValueRef completionHandler);
    444446    void statisticsCallDidResetToConsistentStateCallback();
     
    574576    bool m_dumpAllHTTPRedirectedResponseHeaders { false };
    575577    bool m_hasSetDowngradeReferrerCallback { false };
     578    bool m_hasSetBlockThirdPartyCookiesCallback { false };
    576579};
    577580
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r251212 r251213  
    35563556}
    35573557
     3558void TestController::setStatisticsShouldBlockThirdPartyCookies(bool value)
     3559{
     3560    ResourceStatisticsCallbackContext context(*this);
     3561    WKWebsiteDataStoreSetResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(TestController::websiteDataStore(), value, &context, resourceStatisticsVoidResultCallback);
     3562    runUntil(context.done, noTimeout);
     3563    m_currentInvocation->didSetShouldBlockThirdPartyCookies();
     3564}
     3565
    35583566void TestController::statisticsResetToConsistentState()
    35593567{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r250940 r251213  
    253253    bool hasStatisticsIsolatedSession(WKStringRef hostName);
    254254    void setStatisticsShouldDowngradeReferrer(bool value);
     255    void setStatisticsShouldBlockThirdPartyCookies(bool value);
    255256    void statisticsResetToConsistentState();
    256257
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r251067 r251213  
    15431543    }
    15441544   
     1545    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsShouldBlockThirdPartyCookies")) {
     1546        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     1547        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
     1548        TestController::singleton().setStatisticsShouldBlockThirdPartyCookies(WKBooleanGetValue(value));
     1549        return nullptr;
     1550    }
     1551   
    15451552    if (WKStringIsEqualToUTF8CString(messageName, "RemoveAllSessionCredentials")) {
    15461553        TestController::singleton().removeAllSessionCredentials();
     
    18261833}
    18271834
     1835void TestInvocation::didSetShouldBlockThirdPartyCookies()
     1836{
     1837    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetShouldBlockThirdPartyCookies"));
     1838    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), nullptr);
     1839}
     1840
    18281841void TestInvocation::didResetStatisticsToConsistentState()
    18291842{
  • trunk/Tools/WebKitTestRunner/TestInvocation.h

    r250621 r251213  
    7575    void didClearStatisticsThroughWebsiteDataRemoval();
    7676    void didSetShouldDowngradeReferrer();
     77    void didSetShouldBlockThirdPartyCookies();
    7778    void didResetStatisticsToConsistentState();
    7879    void didSetBlockCookiesForHost();
Note: See TracChangeset for help on using the changeset viewer.