Resource Load Statistics: Block cookies for prevalent resources without user interaction
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jan 2018 01:58:05 +0000 (01:58 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jan 2018 01:58:05 +0000 (01:58 +0000)
commitb54d6da659d879a56965a3030bc7d27a5c6ed07a
tree570faea8233eea21d48e6a69b1db846ffd305e2f
parent4de1733394a760020e4dc5179693c09c8a3639bc
Resource Load Statistics: Block cookies for prevalent resources without user interaction
https://bugs.webkit.org/show_bug.cgi?id=177394
<rdar://problem/34613960>

Reviewed by Alex Christensen.

Source/WebCore:

Tests: http/tests/resourceLoadStatistics/add-blocking-to-redirect.html
       http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html
       http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html
       http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html

* platform/network/NetworkStorageSession.h:
    Now exports NetworkStorageSession::nsCookieStorage().
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::setPrevalentDomainsToPartitionOrBlockCookies):
    Fixes the FIXME.

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:
    Declaration of _initWithIdentifier() on NSHTTPCookieStorage.

Source/WebKit:

* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
    Now has m_hasBeenSetToUseStatelessCookieStorage to handle
    cookie blocking.
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::statelessCookieStorage):
    Returns singleton empty, deny-all cookie storage for cookie blocking.
    The ugly pragma instructions for clang are because the NSString
    parameter for _initWithIdentifier was not marked nullable pre-Sierra.
(WebKit::NetworkDataTaskCocoa::applyCookieBlockingPolicy):
    Instead of just decision making, this now applies the policy.
(WebKit::NetworkDataTaskCocoa::applyCookiePartitioningPolicy):
    New method.
(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
    Now blocks cookies for domains where cookies will be purged anyway.
(WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
    Now blocks cookies for domains where cookies will be purged anyway.
(WebKit::shouldChangePartition): Deleted.
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
    Now downgrades for blocked cookies instead of partitioned cookies.
(-[WKNetworkSessionDelegate URLSession:task:_schemeUpgraded:completionHandler:]):
    Now downgrades for blocked cookies instead of partitioned cookies.

LayoutTests:

* http/tests/resourceLoadStatistics/add-blocking-to-redirect-expected.txt: Added.
* http/tests/resourceLoadStatistics/add-blocking-to-redirect.html: Added.
* http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html:
* http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context-expected.txt: Added.
* http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html: Added.
* http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html:
* http/tests/resourceLoadStatistics/remove-blocking-in-redirect-expected.txt: Added.
* http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html: Added.
* http/tests/resourceLoadStatistics/remove-partitioning-from-redirect-expected.txt: Removed.
* http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html: Removed.
    Test case reworked and is now remove-partitioning-in-redirect.html.
* http/tests/resourceLoadStatistics/remove-partitioning-in-redirect-expected.txt: Added.
* http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html: Added.
* platform/ios/TestExpectations:
    New tests marked as [ Pass ] for iOS.
* platform/mac-wk2/TestExpectations:
    New tests marked as [ Pass ] for High Sierra+.
* platform/wk2/TestExpectations:
    New tests skipped for WK2 in general.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/resourceLoadStatistics/add-blocking-to-redirect-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/add-blocking-to-redirect.html [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html
LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html
LayoutTests/http/tests/resourceLoadStatistics/remove-blocking-in-redirect-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/remove-partitioning-from-redirect-expected.txt [deleted file]
LayoutTests/http/tests/resourceLoadStatistics/remove-partitioning-in-redirect-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html [moved from LayoutTests/http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html with 54% similarity]
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm