Only cap lifetime of persistent cookies created client-side through document.cookie...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 21:37:54 +0000 (21:37 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 21:37:54 +0000 (21:37 +0000)
commitb852d4ce1e36901aa3ca3ec1041afb93ad3ccf71
tree47a3cfef66a8dcdd5ef5209eda32a89737445a91
parentd2fbd03ae203b80a114adbdd1de37eb5ae5f9b01
Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled
https://bugs.webkit.org/show_bug.cgi?id=190687
<rdar://problem/45349024>

Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html

NetworkStorageSession::setCookiesFromDOM() now consults the new
m_shouldCapLifetimeForClientSideCookies member variable before
capping the lifetime of cookies.

* loader/ResourceLoadStatistics.cpp:
(WebCore::ResourceLoadStatistics::toString const):
(WebCore::ResourceLoadStatistics::merge):
    Removal of the isMarkedForCookieBlocking member.
* loader/ResourceLoadStatistics.h:
    Removal of the isMarkedForCookieBlocking member.
* platform/network/NetworkStorageSession.h:
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::setShouldCapLifetimeForClientSideCookies):
(WebCore::NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor):
    No longer takes the boolean clearFirst parameter and now always clears first.
* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::filterCookies):
(WebCore::NetworkStorageSession::setCookiesFromDOM const):

Source/WebKit:

This patch adds the following:
- The WebProcessPool now tells the WebsiteDataStore when a network process has
    been created.
- The WebsiteDataStore in turn tells the WebResourceLoadStatisticsStore when
    a network process has been created.
- The WebResourceLoadStatisticsStore makes sure to update the network processes
    with its cookie policy when it's notified that a network process has been
    created.

In addition, this patch changes the following:
- The ResourceLoadStatisticsMemoryStore no longer keeps track of which domains
    it has told the network process to block cookies for. The reason is that
    we cannot assume that there is only one network process so we should
    always send complete blocking data.
- The ResourceLoadStatisticsMemoryStore's functions for communicating cookie
    blocking state to the network process no longer take and forward the
    "clear first" parameter. This is because complete data is sent every time
    and thus the network process' set is always cleared on an update.
- Removes WebsiteDataStore::networkProcessDidCrash() and
    WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset() since
    the call site---WebProcessPool::ensureNetworkProcess()---now calls
    WebsiteDataStore::didCreateNetworkProcess() after a network process
    crash and the state sync for cookie blocking is triggered.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::NetworkProcess::setShouldCapLifetimeForClientSideCookies):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies):
(WebKit::NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::clear):
(WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking):
(WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains):
(WebKit::ResourceLoadStatisticsMemoryStore::clearBlockingStateForDomains):
(WebKit::ResourceLoadStatisticsMemoryStore::resetCookieBlockingState): Deleted.
* UIProcess/ResourceLoadStatisticsMemoryStore.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::didCreateNetworkProcess):
(WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains):
(WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
(WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
(WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset): Deleted.
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::WebsiteDataStore::setShouldCapLifetimeForClientSideCookies):
(WebKit::WebsiteDataStore::didCreateNetworkProcess):
(WebKit::WebsiteDataStore::networkProcessDidCrash): Deleted.
* UIProcess/WebsiteData/WebsiteDataStore.h:

LayoutTests:

The test case now makes use of internals.setResourceLoadStatisticsEnabled()
and was thus moved to http/tests/resourceLoadStatistics/.

* TestExpectations:
    Removed skip of previous test location.
* http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt: Renamed from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt.
* http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html: Renamed from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html.
* http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* http/tests/webAPIStatistics/font-load-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* platform/ios/TestExpectations:
    Removed pass of previous test location. The whole http/tests/resourceLoadStatistics/ is marked pass for relevant platforms.
* platform/mac-wk2/TestExpectations:
    Removed pass of previous test location. The whole http/tests/resourceLoadStatistics/ is marked pass for relevant platforms.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt [moved from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt with 100% similarity]
LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html [moved from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html with 93% similarity]
LayoutTests/http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt
LayoutTests/http/tests/webAPIStatistics/font-load-data-collection-expected.txt
LayoutTests/http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt
LayoutTests/http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadStatistics.cpp
Source/WebCore/loader/ResourceLoadStatistics.h
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h