Changeset 252623 in webkit


Ignore:
Timestamp:
Nov 18, 2019 10:30:46 PM (4 years ago)
Author:
wilander@apple.com
Message:

Check if ITP is on before applying third-party cookie blocking
https://bugs.webkit.org/show_bug.cgi?id=204322
<rdar://problem/57120772>

Reviewed by Chris Dumez and Alexey Proskuryakov.

Source/WebCore:

This change makes sure WebCore::NetworkStorageSession knows
whether ITP is on or off and checks that first thing in
WebCore::NetworkStorageSession::shouldBlockCookies().

This check was never needed before since if ITP was off,
there would be no classified domains and thus the function
would always return false. However,
https://trac.webkit.org/changeset/251353/webkit introduced
full third-party cookie blocking for websites without user
interaction and that rule is checked before checking domain
classification. The effect was unconditional third-party
cookie blocking if ITP is off. This changes fixes that bug.

Note that this patch already landed as branch-specific in
https://trac.webkit.org/changeset/252549/webkit

Test: http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html

  • platform/network/NetworkStorageSession.cpp:

(WebCore::NetworkStorageSession::shouldBlockThirdPartyCookies const):
(WebCore::NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor const):
(WebCore::NetworkStorageSession::shouldBlockCookies const):

Now checks whether ITP is on or off.

  • platform/network/NetworkStorageSession.h:

(WebCore::NetworkStorageSession::setResourceLoadStatisticsEnabled):

Source/WebKit:

This change makes sure WebCore::NetworkStorageSession knows
whether ITP is on or off and checks that first thing in
WebCore::NetworkStorageSession::shouldBlockCookies().

This check was never needed before since if ITP was off,
there would be no classified domains and thus the function
would always return false. However,
https://trac.webkit.org/changeset/251353/webkit introduced
full third-party cookie blocking for websites without user
interaction and that rule is checked before checking domain
classification. The effect was unconditional third-party
cookie blocking if ITP is off. This changes fixes that bug.

Note that this patch already landed as branch-specific in
https://trac.webkit.org/changeset/252549/webkit

  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::setResourceLoadStatisticsEnabled):

Now tells WebCore::NetworkStorageSession the status of
ITP.

Tools:

This is test infrastructure to allow a layout test to
disable ITP in the network process.

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

(WTR::TestRunner::setStatisticsEnabled):
(WTR::TestRunner::setStatisticsDebugMode):

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

(WTR::TestController::setStatisticsEnabled):

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

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

  • http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt: Added.
  • http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html: Added.
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r252622 r252623  
     12019-11-18  John Wilander  <wilander@apple.com>
     2
     3        Check if ITP is on before applying third-party cookie blocking
     4        https://bugs.webkit.org/show_bug.cgi?id=204322
     5        <rdar://problem/57120772>
     6
     7        Reviewed by Chris Dumez and Alexey Proskuryakov.
     8
     9        * http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt: Added.
     10        * http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html: Added.
     11
    1122019-11-18  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r252622 r252623  
     12019-11-18  John Wilander  <wilander@apple.com>
     2
     3        Check if ITP is on before applying third-party cookie blocking
     4        https://bugs.webkit.org/show_bug.cgi?id=204322
     5        <rdar://problem/57120772>
     6
     7        Reviewed by Chris Dumez and Alexey Proskuryakov.
     8
     9        This change makes sure WebCore::NetworkStorageSession knows
     10        whether ITP is on or off and checks that first thing in
     11        WebCore::NetworkStorageSession::shouldBlockCookies().
     12
     13        This check was never needed before since if ITP was off,
     14        there would be no classified domains and thus the function
     15        would always return false. However,
     16        https://trac.webkit.org/changeset/251353/webkit introduced
     17        full third-party cookie blocking for websites without user
     18        interaction and that rule is checked before checking domain
     19        classification. The effect was unconditional third-party
     20        cookie blocking if ITP is off. This changes fixes that bug.
     21
     22        Note that this patch already landed as branch-specific in
     23        https://trac.webkit.org/changeset/252549/webkit
     24
     25        Test: http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html
     26
     27        * platform/network/NetworkStorageSession.cpp:
     28        (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookies const):
     29        (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor const):
     30        (WebCore::NetworkStorageSession::shouldBlockCookies const):
     31            Now checks whether ITP is on or off.
     32        * platform/network/NetworkStorageSession.h:
     33        (WebCore::NetworkStorageSession::setResourceLoadStatisticsEnabled):
     34
    1352019-11-18  Simon Fraser  <simon.fraser@apple.com>
    236
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp

    r251467 r252623  
    6060bool NetworkStorageSession::shouldBlockThirdPartyCookies(const RegistrableDomain& registrableDomain) const
    6161{
    62     if (registrableDomain.isEmpty())
     62    if (!m_isResourceLoadStatisticsEnabled || registrableDomain.isEmpty())
    6363        return false;
    6464
     
    7171bool NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(const RegistrableDomain& registrableDomain) const
    7272{
     73    if (!m_isResourceLoadStatisticsEnabled || registrableDomain.isEmpty())
     74        return false;
     75
     76    ASSERT(!(m_registrableDomainsToBlockAndDeleteCookiesFor.contains(registrableDomain) && m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain)));
     77
     78    return m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain);
     79}
     80
     81bool NetworkStorageSession::hasHadUserInteractionAsFirstParty(const RegistrableDomain& registrableDomain) const
     82{
    7383    if (registrableDomain.isEmpty())
    7484        return false;
    7585
    76     ASSERT(!(m_registrableDomainsToBlockAndDeleteCookiesFor.contains(registrableDomain) && m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain)));
    77 
    78     return m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain);
    79 }
    80 
    81 bool NetworkStorageSession::hasHadUserInteractionAsFirstParty(const RegistrableDomain& registrableDomain) const
    82 {
    83     if (registrableDomain.isEmpty())
    84         return false;
    85 
    8686    return m_registrableDomainsWithUserInteractionAsFirstParty.contains(registrableDomain);
    8787}
     
    8989bool NetworkStorageSession::shouldBlockCookies(const ResourceRequest& request, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID) const
    9090{
     91    if (!m_isResourceLoadStatisticsEnabled)
     92        return false;
     93
    9194    return shouldBlockCookies(request.firstPartyForCookies(), request.url(), frameID, pageID);
    9295}
     
    9497bool NetworkStorageSession::shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID) const
    9598{
     99    if (!m_isResourceLoadStatisticsEnabled)
     100        return false;
     101
    96102    RegistrableDomain firstPartyDomain { firstPartyForCookies };
    97103    if (firstPartyDomain.isEmpty())
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.h

    r251467 r252623  
    144144
    145145#if ENABLE(RESOURCE_LOAD_STATISTICS)
     146    void setResourceLoadStatisticsEnabled(bool enabled) { m_isResourceLoadStatisticsEnabled = enabled; }
    146147    WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&, Optional<FrameIdentifier>, Optional<PageIdentifier>) const;
    147148    WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, Optional<FrameIdentifier>, Optional<PageIdentifier>) const;
     
    189190
    190191#if ENABLE(RESOURCE_LOAD_STATISTICS)
     192    bool m_isResourceLoadStatisticsEnabled = false;
    191193    Optional<Seconds> clientSideCookieCap(const RegistrableDomain& firstParty, Optional<PageIdentifier>) const;
    192194    HashSet<RegistrableDomain> m_registrableDomainsToBlockAndDeleteCookiesFor;
  • trunk/Source/WebKit/ChangeLog

    r252619 r252623  
     12019-11-18  John Wilander  <wilander@apple.com>
     2
     3        Check if ITP is on before applying third-party cookie blocking
     4        https://bugs.webkit.org/show_bug.cgi?id=204322
     5        <rdar://problem/57120772>
     6
     7        Reviewed by Chris Dumez and Alexey Proskuryakov.
     8
     9        This change makes sure WebCore::NetworkStorageSession knows
     10        whether ITP is on or off and checks that first thing in
     11        WebCore::NetworkStorageSession::shouldBlockCookies().
     12
     13        This check was never needed before since if ITP was off,
     14        there would be no classified domains and thus the function
     15        would always return false. However,
     16        https://trac.webkit.org/changeset/251353/webkit introduced
     17        full third-party cookie blocking for websites without user
     18        interaction and that rule is checked before checking domain
     19        classification. The effect was unconditional third-party
     20        cookie blocking if ITP is off. This changes fixes that bug.
     21
     22        Note that this patch already landed as branch-specific in
     23        https://trac.webkit.org/changeset/252549/webkit
     24
     25        * NetworkProcess/NetworkSession.cpp:
     26        (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
     27            Now tells WebCore::NetworkStorageSession the status of
     28            ITP.
     29
    1302019-11-18  David Kilzer  <ddkilzer@apple.com>
    231
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r252397 r252623  
    154154{
    155155    ASSERT(!m_isInvalidated);
     156    if (auto* storageSession = networkStorageSession())
     157        storageSession->setResourceLoadStatisticsEnabled(enable);
    156158    if (!enable) {
    157159        destroyResourceLoadStatistics();
  • trunk/Tools/ChangeLog

    r252617 r252623  
     12019-11-18  John Wilander  <wilander@apple.com>
     2
     3        Check if ITP is on before applying third-party cookie blocking
     4        https://bugs.webkit.org/show_bug.cgi?id=204322
     5        <rdar://problem/57120772>
     6
     7        Reviewed by Chris Dumez and Alexey Proskuryakov.
     8
     9        This is test infrastructure to allow a layout test to
     10        disable ITP in the network process.
     11
     12        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     13        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     14        (WTR::TestRunner::setStatisticsEnabled):
     15        (WTR::TestRunner::setStatisticsDebugMode):
     16        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     17        * WebKitTestRunner/TestController.cpp:
     18        (WTR::TestController::setStatisticsEnabled):
     19        * WebKitTestRunner/TestController.h:
     20        * WebKitTestRunner/TestInvocation.cpp:
     21        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     22
    1232019-11-18  Fujii Hironori  <Hironori.Fujii@sony.com>
    224
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r251213 r252623  
    293293
    294294    // Resource Load Statistics
     295    void setStatisticsEnabled(boolean value);
    295296    void installStatisticsDidModifyDataRecordsCallback(object callback);
    296297    void installStatisticsDidScanDataRecordsCallback(object callback);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r251950 r252623  
    14091409}
    14101410
     1411void TestRunner::setStatisticsEnabled(bool value)
     1412{
     1413    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsEnabled"));
     1414    WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value));
     1415    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1416}
     1417
    14111418void TestRunner::setStatisticsDebugMode(bool value, JSValueRef completionHandler)
    14121419{
     
    14161423    WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value));
    14171424    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1418 
    14191425}
    14201426
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r251950 r252623  
    381381   
    382382    // Resource Load Statistics
     383    void setStatisticsEnabled(bool value);
    383384    void installStatisticsDidModifyDataRecordsCallback(JSValueRef callback);
    384385    void installStatisticsDidScanDataRecordsCallback(JSValueRef callback);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r252397 r252623  
    32553255}
    32563256
     3257void TestController::setStatisticsEnabled(bool value)
     3258{
     3259    WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(TestController::websiteDataStore(), value);
     3260}
     3261
    32573262void TestController::setStatisticsDebugMode(bool value)
    32583263{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r252228 r252623  
    208208    void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; }
    209209
     210    void setStatisticsEnabled(bool value);
    210211    void setStatisticsDebugMode(bool value);
    211212    void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName);
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r252259 r252623  
    10721072    }
    10731073
     1074    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsEnabled")) {
     1075        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     1076        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
     1077        TestController::singleton().setStatisticsEnabled(WKBooleanGetValue(value));
     1078        return nullptr;
     1079    }
     1080
    10741081    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsDebugMode")) {
    10751082        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
Note: See TracChangeset for help on using the changeset viewer.