Diff
Modified: trunk/LayoutTests/ChangeLog (237303 => 237304)
--- trunk/LayoutTests/ChangeLog 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/ChangeLog 2018-10-19 21:37:54 UTC (rev 237304)
@@ -1,3 +1,31 @@
+2018-10-19 John Wilander <wilan...@apple.com>
+
+ 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.
+
+ 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.
+
2018-10-19 Commit Queue <commit-qu...@webkit.org>
Unreviewed, rolling out r237254.
Modified: trunk/LayoutTests/TestExpectations (237303 => 237304)
--- trunk/LayoutTests/TestExpectations 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/TestExpectations 2018-10-19 21:37:54 UTC (rev 237304)
@@ -153,7 +153,6 @@
http/tests/loading/basic-auth-remove-credentials.html [ Skip ]
http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Skip ]
http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Skip ]
-http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Skip ]
# ApplePay is only available on iOS (greater than iOS 10) and macOS (greater than macOS 10.12) and only for WebKit2.
http/tests/ssl/applepay/ [ Skip ]
Deleted: trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt (237303 => 237304)
--- trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt 2018-10-19 21:37:54 UTC (rev 237304)
@@ -1,11 +0,0 @@
-Check that cookies created by _javascript_ with max-age or expiry longer than a week get capped to a week.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS The two short-lived cookies don't expire after more than 172830 seconds.
-PASS The two long-lived cookies don't expire after more than 604830 seconds.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
Deleted: trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html (237303 => 237304)
--- trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html 2018-10-19 21:37:54 UTC (rev 237304)
@@ -1,73 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <script src=""
- <script src=""
-</head>
-<body>
-<script>
- description("Check that cookies created by _javascript_ with max-age or expiry longer than a week get capped to a week.");
- jsTestIsAsync = true;
-
- let passedTests = 0;
- function checkThatCookieDoesNotExpireAfter(cookieData, maxAgeInSeconds) {
- let now = new Date();
- let maxExpiryDateInMilliseconds = now.getTime() + (maxAgeInSeconds * 1000);
-
- if (maxExpiryDateInMilliseconds > cookieData["expires"])
- ++passedTests;
- else
- testFailed("Cookie named " + cookieData["name"] + " expires in more than " + maxAgeInSeconds + " seconds.");
- }
-
- const twoDaysInSeconds = 2 * 24 * 60 * 60;
- const shortLivedCookieMaxAge = { name : "shortLivedCookieMaxAge", lifetime : "Max-Age=" + twoDaysInSeconds + ";" };
- document.cookie = shortLivedCookieMaxAge.name + "=foobar; " + shortLivedCookieMaxAge.lifetime + " path=/";
-
- const twoDaysAsExpiresDate = createExpiresDateFromMaxAge(twoDaysInSeconds);
- const shortLivedCookieExpires = { name : "shortLivedCookieExpires", lifetime : "Expires=" + twoDaysAsExpiresDate + ";" };
- document.cookie = shortLivedCookieExpires.name + "=foobar; " + shortLivedCookieExpires.lifetime + " path=/";
-
- const _oneWeekInSeconds_ = 7 * 24 * 60 * 60;
- const twoWeeksInSeconds = 2 * oneWeekInSeconds;
- const longLivedCookieMaxAge = { name : "longLivedCookieMaxAge", lifetime : "Max-Age=" + twoWeeksInSeconds + ";" };
- document.cookie = longLivedCookieMaxAge.name + "=foobar; " + longLivedCookieMaxAge.lifetime + " path=/";
-
- const twoWeeksAsExpiresDate = createExpiresDateFromMaxAge(twoWeeksInSeconds);
- const longLivedCookieExpires = { name : "longLivedCookieExpires", lifetime : "Expires=" + twoWeeksAsExpiresDate + ";" };
- document.cookie = longLivedCookieExpires.name + "=foobar; " + longLivedCookieExpires.lifetime + " path=/";
-
- const overTwoDaysInSeconds = twoDaysInSeconds + 30;
- const overOneWeekInSeconds = oneWeekInSeconds + 30;
- if (internals) {
- let cookies = internals.getCookies();
- if (!cookies.length)
- testFailed("No cookies found.");
- for (let cookie of cookies) {
- switch (cookie.name) {
- case shortLivedCookieMaxAge.name:
- checkThatCookieDoesNotExpireAfter(cookie, overTwoDaysInSeconds);
- break;
- case shortLivedCookieExpires.name:
- checkThatCookieDoesNotExpireAfter(cookie, overTwoDaysInSeconds);
- break;
- case longLivedCookieMaxAge.name:
- checkThatCookieDoesNotExpireAfter(cookie, overOneWeekInSeconds);
- break;
- case longLivedCookieExpires.name:
- checkThatCookieDoesNotExpireAfter(cookie, overOneWeekInSeconds);
- break;
- }
- }
- if (passedTests === 4) {
- testPassed("The two short-lived cookies don't expire after more than " + overTwoDaysInSeconds + " seconds.");
- testPassed("The two long-lived cookies don't expire after more than " + overOneWeekInSeconds + " seconds.");
- } else
- testFailed("At least one cookie's expiry attribute was beyond the test thresholds.");
- } else
- testFailed("No internals object.");
-
- finishJSTest();
-</script>
-</body>
-</html>
Copied: trunk/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt (from rev 237303, trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt) (0 => 237304)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt 2018-10-19 21:37:54 UTC (rev 237304)
@@ -0,0 +1,11 @@
+Check that cookies created by _javascript_ with max-age or expiry longer than a week get capped to a week.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The two short-lived cookies don't expire after more than 172830 seconds.
+PASS The two long-lived cookies don't expire after more than 604830 seconds.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: trunk/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html (from rev 237303, trunk/LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html) (0 => 237304)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html 2018-10-19 21:37:54 UTC (rev 237304)
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+</head>
+<body>
+<script>
+ description("Check that cookies created by _javascript_ with max-age or expiry longer than a week get capped to a week.");
+ jsTestIsAsync = true;
+
+ if (internals)
+ internals.setResourceLoadStatisticsEnabled(true);
+
+ let passedTests = 0;
+ function checkThatCookieDoesNotExpireAfter(cookieData, maxAgeInSeconds) {
+ let now = new Date();
+ let maxExpiryDateInMilliseconds = now.getTime() + (maxAgeInSeconds * 1000);
+
+ if (maxExpiryDateInMilliseconds > cookieData["expires"])
+ ++passedTests;
+ else
+ testFailed("Cookie named " + cookieData["name"] + " expires in more than " + maxAgeInSeconds + " seconds.");
+ }
+
+ const twoDaysInSeconds = 2 * 24 * 60 * 60;
+ const shortLivedCookieMaxAge = { name : "shortLivedCookieMaxAge", lifetime : "Max-Age=" + twoDaysInSeconds + ";" };
+ document.cookie = shortLivedCookieMaxAge.name + "=foobar; " + shortLivedCookieMaxAge.lifetime + " path=/";
+
+ const twoDaysAsExpiresDate = createExpiresDateFromMaxAge(twoDaysInSeconds);
+ const shortLivedCookieExpires = { name : "shortLivedCookieExpires", lifetime : "Expires=" + twoDaysAsExpiresDate + ";" };
+ document.cookie = shortLivedCookieExpires.name + "=foobar; " + shortLivedCookieExpires.lifetime + " path=/";
+
+ const _oneWeekInSeconds_ = 7 * 24 * 60 * 60;
+ const twoWeeksInSeconds = 2 * oneWeekInSeconds;
+ const longLivedCookieMaxAge = { name : "longLivedCookieMaxAge", lifetime : "Max-Age=" + twoWeeksInSeconds + ";" };
+ document.cookie = longLivedCookieMaxAge.name + "=foobar; " + longLivedCookieMaxAge.lifetime + " path=/";
+
+ const twoWeeksAsExpiresDate = createExpiresDateFromMaxAge(twoWeeksInSeconds);
+ const longLivedCookieExpires = { name : "longLivedCookieExpires", lifetime : "Expires=" + twoWeeksAsExpiresDate + ";" };
+ document.cookie = longLivedCookieExpires.name + "=foobar; " + longLivedCookieExpires.lifetime + " path=/";
+
+ const overTwoDaysInSeconds = twoDaysInSeconds + 30;
+ const overOneWeekInSeconds = oneWeekInSeconds + 30;
+ if (internals) {
+ let cookies = internals.getCookies();
+ if (!cookies.length)
+ testFailed("No cookies found.");
+ for (let cookie of cookies) {
+ switch (cookie.name) {
+ case shortLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwoDaysInSeconds);
+ break;
+ case shortLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwoDaysInSeconds);
+ break;
+ case longLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneWeekInSeconds);
+ break;
+ case longLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneWeekInSeconds);
+ break;
+ }
+ }
+ if (passedTests === 4) {
+ testPassed("The two short-lived cookies don't expire after more than " + overTwoDaysInSeconds + " seconds.");
+ testPassed("The two long-lived cookies don't expire after more than " + overOneWeekInSeconds + " seconds.");
+ } else
+ testFailed("At least one cookie's expiry attribute was beyond the test thresholds.");
+ } else
+ testFailed("No internals object.");
+
+ if (internals)
+ internals.setResourceLoadStatisticsEnabled(false);
+
+ finishJSTest();
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt (237303 => 237304)
--- trunk/LayoutTests/http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt 2018-10-19 21:37:54 UTC (rev 237304)
@@ -9,7 +9,6 @@
isPrevalentResource: No
isVeryPrevalentResource: No
dataRecordsRemoved: 0
- isMarkedForCookieBlocking: No
fontsSuccessfullyLoaded:
Helvetica
Times
Modified: trunk/LayoutTests/http/tests/webAPIStatistics/font-load-data-collection-expected.txt (237303 => 237304)
--- trunk/LayoutTests/http/tests/webAPIStatistics/font-load-data-collection-expected.txt 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/http/tests/webAPIStatistics/font-load-data-collection-expected.txt 2018-10-19 21:37:54 UTC (rev 237304)
@@ -11,7 +11,6 @@
isPrevalentResource: No
isVeryPrevalentResource: No
dataRecordsRemoved: 0
- isMarkedForCookieBlocking: No
fontsFailedToLoad:
Fransiscan
Andale
Modified: trunk/LayoutTests/http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt (237303 => 237304)
--- trunk/LayoutTests/http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt 2018-10-19 21:37:54 UTC (rev 237304)
@@ -9,7 +9,6 @@
isPrevalentResource: No
isVeryPrevalentResource: No
dataRecordsRemoved: 0
- isMarkedForCookieBlocking: No
fontsSuccessfullyLoaded:
Times
topFrameRegistrableDomainsWhichAccessedWebAPIs:
Modified: trunk/LayoutTests/http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt (237303 => 237304)
--- trunk/LayoutTests/http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt 2018-10-19 21:37:54 UTC (rev 237304)
@@ -9,7 +9,6 @@
isPrevalentResource: No
isVeryPrevalentResource: No
dataRecordsRemoved: 0
- isMarkedForCookieBlocking: No
fontsSuccessfullyLoaded:
Times
topFrameRegistrableDomainsWhichAccessedWebAPIs:
Modified: trunk/LayoutTests/platform/ios/TestExpectations (237303 => 237304)
--- trunk/LayoutTests/platform/ios/TestExpectations 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2018-10-19 21:37:54 UTC (rev 237304)
@@ -2817,7 +2817,6 @@
http/tests/storageAccess/deny-storage-access-under-opener.html [ Pass ]
http/tests/storageAccess/deny-storage-access-under-opener-if-auto-dismiss.html [ Pass ]
http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html [ Pass ]
-http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ]
# Skipped in general expectations since they only work on iOS and Mac, WK2.
http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (237303 => 237304)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2018-10-19 21:37:54 UTC (rev 237304)
@@ -772,7 +772,6 @@
[ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html [ Pass ]
[ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html [ Pass ]
[ HighSierra+ ] http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html [ Pass ]
-http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ]
# Skipped in general expectations since they only work on iOS and Mac, WK2.
http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
Modified: trunk/Source/WebCore/ChangeLog (237303 => 237304)
--- trunk/Source/WebCore/ChangeLog 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebCore/ChangeLog 2018-10-19 21:37:54 UTC (rev 237304)
@@ -1,3 +1,32 @@
+2018-10-19 John Wilander <wilan...@apple.com>
+
+ 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.
+
+ 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):
+
2018-10-19 Zalan Bujtas <za...@apple.com>
[LFC][IFC] RenderReplaced renderer should create InlineBox
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp (237303 => 237304)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -425,10 +425,6 @@
builder.appendNumber(dataRecordsRemoved);
builder.append('\n');
- // In-memory only
- appendBoolean(builder, "isMarkedForCookieBlocking", isMarkedForCookieBlocking);
- builder.append('\n');
-
appendHashSet(builder, "fontsFailedToLoad", fontsFailedToLoad);
appendHashSet(builder, "fontsSuccessfullyLoaded", fontsSuccessfullyLoaded);
appendHashCountedSet(builder, "topFrameRegistrableDomainsWhichAccessedWebAPIs", topFrameRegistrableDomainsWhichAccessedWebAPIs);
@@ -497,9 +493,6 @@
isVeryPrevalentResource |= other.isVeryPrevalentResource;
dataRecordsRemoved = std::max(dataRecordsRemoved, other.dataRecordsRemoved);
- // In-memory only
- isMarkedForCookieBlocking |= other.isMarkedForCookieBlocking;
-
mergeHashSet(fontsFailedToLoad, other.fontsFailedToLoad);
mergeHashSet(fontsSuccessfullyLoaded, other.fontsSuccessfullyLoaded);
mergeHashCountedSet(topFrameRegistrableDomainsWhichAccessedWebAPIs, other.topFrameRegistrableDomainsWhichAccessedWebAPIs);
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (237303 => 237304)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-10-19 21:37:54 UTC (rev 237304)
@@ -96,9 +96,6 @@
unsigned timesAccessedAsFirstPartyDueToUserInteraction { 0 };
unsigned timesAccessedAsFirstPartyDueToStorageAccessAPI { 0 };
- // In-memory only
- bool isMarkedForCookieBlocking { false };
-
// This set represents the registrable domain of the top frame where web API
// were used in the top frame or one of its subframes.
HashCountedSet<String> topFrameRegistrableDomainsWhichAccessedWebAPIs;
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (237303 => 237304)
--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2018-10-19 21:37:54 UTC (rev 237304)
@@ -102,7 +102,8 @@
#if ENABLE(RESOURCE_LOAD_STATISTICS)
WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
- WEBCORE_EXPORT void setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, bool clearFirst);
+ WEBCORE_EXPORT void setPrevalentDomainsToBlockCookiesFor(const Vector<String>&);
+ WEBCORE_EXPORT void setShouldCapLifetimeForClientSideCookies(bool value);
WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains);
WEBCORE_EXPORT bool hasStorageAccess(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID) const;
WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const;
@@ -191,6 +192,7 @@
HashMap<uint64_t, HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_framesGrantedStorageAccess;
HashMap<uint64_t, HashMap<String, String>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_pagesGrantedStorageAccess;
std::optional<Seconds> m_cacheMaxAgeCapForPrevalentResources { };
+ bool m_shouldCapLifetimeForClientSideCookies { false };
#endif
#if PLATFORM(COCOA)
Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (237303 => 237304)
--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -273,13 +273,14 @@
return std::nullopt;
}
-void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domains, bool clearFirst)
+void NetworkStorageSession::setShouldCapLifetimeForClientSideCookies(bool value)
{
- if (clearFirst) {
- m_topPrivatelyControlledDomainsToBlock.clear();
- m_framesGrantedStorageAccess.clear();
- }
+ m_shouldCapLifetimeForClientSideCookies = value;
+}
+void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domains)
+{
+ m_topPrivatelyControlledDomainsToBlock.clear();
m_topPrivatelyControlledDomainsToBlock.add(domains.begin(), domains.end());
}
Modified: trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm (237303 => 237304)
--- trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm 2018-10-19 21:37:54 UTC (rev 237304)
@@ -260,7 +260,7 @@
return cookiesForURL(nsCookieStorage.get(), url, firstParty, sameSiteInfo);
}
-static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies)
+static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies, bool shouldCapLifetime)
{
ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
NSUInteger count = [unfilteredCookies count];
@@ -281,7 +281,7 @@
continue;
// Cap lifetime of persistent, client-side cookies to a week.
- if (![cookie isSessionOnly]) {
+ if (shouldCapLifetime && ![cookie isSessionOnly]) {
if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > secondsPerWeek) {
RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> properties = adoptNS([[cookie properties] mutableCopy]);
RetainPtr<NSDate> dateInAWeek = adoptNS([[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerWeek]);
@@ -404,7 +404,11 @@
NSArray *unfilteredCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:cookieURL];
#endif
- RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies);
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, m_shouldCapLifetimeForClientSideCookies);
+#else
+ RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);
+#endif
ASSERT([filteredCookies.get() count] <= 1);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
Modified: trunk/Source/WebKit/ChangeLog (237303 => 237304)
--- trunk/Source/WebKit/ChangeLog 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/ChangeLog 2018-10-19 21:37:54 UTC (rev 237304)
@@ -1,3 +1,69 @@
+2018-10-19 John Wilander <wilan...@apple.com>
+
+ 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.
+
+ 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:
+
2018-10-19 Alex Christensen <achristen...@webkit.org>
Rebase python tests.
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (237303 => 237304)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -500,13 +500,20 @@
}
#if ENABLE(RESOURCE_LOAD_STATISTICS)
-void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, bool shouldClearFirst, uint64_t contextId)
+void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, uint64_t contextId)
{
if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
- networkStorageSession->setPrevalentDomainsToBlockCookiesFor(domainsToBlock, shouldClearFirst);
+ networkStorageSession->setPrevalentDomainsToBlockCookiesFor(domainsToBlock);
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateBlockCookies(contextId), 0);
}
+void NetworkProcess::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId)
+{
+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
+ networkStorageSession->setShouldCapLifetimeForClientSideCookies(value);
+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetShouldCapLifetimeForClientSideCookies(contextId), 0);
+}
+
void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
{
if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
@@ -568,7 +575,7 @@
ASSERT_NOT_REACHED();
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidResetCacheMaxAgeCapForPrevalentResources(contextId), 0);
}
-#endif
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
bool NetworkProcess::sessionIsControlledByAutomation(PAL::SessionID sessionID) const
{
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (237303 => 237304)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-10-19 21:37:54 UTC (rev 237304)
@@ -157,7 +157,8 @@
void addWebsiteDataStore(WebsiteDataStoreParameters&&);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
- void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, bool shouldClearFirst, uint64_t contextId);
+ void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, uint64_t contextId);
+ void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, bool value, uint64_t contextId);
void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId);
void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (237303 => 237304)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-10-19 21:37:54 UTC (rev 237304)
@@ -78,7 +78,8 @@
PreconnectTo(WebCore::URL url, enum:bool WebCore::StoredCredentialsPolicy storedCredentialsPolicy);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
- UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<String> domainsToBlock, bool shouldClearFirst, uint64_t contextId)
+ UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<String> domainsToBlock, uint64_t contextId)
+ SetShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId)
HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId)
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -395,7 +395,7 @@
}
#if ENABLE(RESOURCE_LOAD_STATISTICS)
-void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
{
if (!canSendMessage()) {
completionHandler();
@@ -407,7 +407,7 @@
completionHandler();
});
ASSERT_UNUSED(addResult, addResult.isNewEntry);
- send(Messages::NetworkProcess::UpdatePrevalentDomainsToBlockCookiesFor(sessionID, domainsToBlock, shouldClearFirst == ShouldClearFirst::Yes, callbackId), 0);
+ send(Messages::NetworkProcess::UpdatePrevalentDomainsToBlockCookiesFor(sessionID, domainsToBlock, callbackId), 0);
}
void NetworkProcessProxy::didUpdateBlockCookies(uint64_t callbackId)
@@ -415,6 +415,26 @@
m_updateBlockCookiesCallbackMap.take(callbackId)();
}
+void NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
+{
+ if (!canSendMessage()) {
+ completionHandler();
+ return;
+ }
+
+ auto callbackId = generateCallbackID();
+ auto addResult = m_updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {
+ completionHandler();
+ });
+ ASSERT_UNUSED(addResult, addResult.isNewEntry);
+ send(Messages::NetworkProcess::SetShouldCapLifetimeForClientSideCookies(sessionID, shouldCapLifetime == ShouldCapLifetimeForClientSideCookies::Yes, callbackId), 0);
+}
+
+void NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
+{
+ m_updateBlockCookiesCallbackMap.take(callbackId)();
+}
+
void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback)
{
auto contextId = generateCallbackID();
@@ -507,7 +527,7 @@
auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId);
completionHandler();
}
-#endif
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
void NetworkProcessProxy::sendProcessWillSuspendImminently()
{
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-10-19 21:37:54 UTC (rev 237304)
@@ -78,7 +78,8 @@
void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&&);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
- void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+ void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
+ void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&);
void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&);
void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
@@ -144,6 +145,7 @@
void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
void didUpdateBlockCookies(uint64_t contextId);
+ void didSetShouldCapLifetimeForClientSideCookies(uint64_t contextId);
void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
void didRemoveAllStorageAccess(uint64_t contextId);
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-10-19 21:37:54 UTC (rev 237304)
@@ -43,6 +43,7 @@
#if ENABLE(RESOURCE_LOAD_STATISTICS)
DidUpdateBlockCookies(uint64_t callbackId)
+ DidSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
DidRemoveAllStorageAccess(uint64_t contextId)
Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -952,7 +952,7 @@
removeAllStorageAccess([callbackAggregator = callbackAggregator.copyRef()] { });
auto primaryDomainsToBlock = ensurePrevalentResourcesForDebugMode();
- updateCookieBlockingForDomains(primaryDomainsToBlock, ShouldClearFirst::Yes, [callbackAggregator = callbackAggregator.copyRef()] { });
+ updateCookieBlockingForDomains(primaryDomainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { });
}
bool ResourceLoadStatisticsMemoryStore::wasAccessedAsFirstPartyDueToUserInteraction(const ResourceLoadStatistics& current, const ResourceLoadStatistics& updated) const
@@ -1035,10 +1035,8 @@
Vector<String> domainsToBlock;
for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
- if (resourceStatistic.isPrevalentResource && !resourceStatistic.isMarkedForCookieBlocking) {
+ if (resourceStatistic.isPrevalentResource)
domainsToBlock.append(resourceStatistic.highLevelDomain);
- resourceStatistic.isMarkedForCookieBlocking = true;
- }
}
if (domainsToBlock.isEmpty()) {
@@ -1050,7 +1048,7 @@
debugLogDomainsInBatches("block", domainsToBlock);
RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), store = makeRef(m_store), domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
- store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, ShouldClearFirst::No, [weakThis = WTFMove(weakThis), store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
+ store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, [weakThis = WTFMove(weakThis), store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
store->statisticsQueue().dispatch([weakThis = WTFMove(weakThis), completionHandler = WTFMove(completionHandler)]() mutable {
completionHandler();
if (!weakThis)
@@ -1063,23 +1061,12 @@
});
}
-void ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
{
ASSERT(!RunLoop::isMain());
- if (domainsToBlock.isEmpty() && shouldClearFirst == ShouldClearFirst::No) {
- completionHandler();
- return;
- }
-
- if (shouldClearFirst == ShouldClearFirst::Yes)
- resetCookieBlockingState();
-
- for (auto& domain : domainsToBlock)
- ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookieBlocking = true;
-
- RunLoop::main().dispatch([store = makeRef(m_store), shouldClearFirst, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
- store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, shouldClearFirst, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
+ RunLoop::main().dispatch([store = makeRef(m_store), domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
+ store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
store->statisticsQueue().dispatch([completionHandler = WTFMove(completionHandler)]() mutable {
completionHandler();
});
@@ -1100,22 +1087,9 @@
store->callRemoveDomainsHandler(domains);
});
- for (auto& domain : domains) {
- auto& statistic = ensureResourceStatisticsForPrimaryDomain(domain);
- statistic.isMarkedForCookieBlocking = false;
- }
-
completionHandler();
}
-void ResourceLoadStatisticsMemoryStore::resetCookieBlockingState()
-{
- ASSERT(!RunLoop::isMain());
-
- for (auto& resourceStatistic : m_resourceStatisticsMap.values())
- resourceStatistic.isMarkedForCookieBlocking = false;
-}
-
void ResourceLoadStatisticsMemoryStore::processStatistics(const Function<void(const ResourceLoadStatistics&)>& processFunction) const
{
ASSERT(!RunLoop::isMain());
Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h 2018-10-19 21:37:54 UTC (rev 237304)
@@ -64,9 +64,8 @@
void mergeStatistics(Vector<WebCore::ResourceLoadStatistics>&&);
void processStatistics(const Function<void(const WebCore::ResourceLoadStatistics&)>&) const;
- void resetCookieBlockingState();
void updateCookieBlocking(CompletionHandler<void()>&&);
- void updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+ void updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
void clearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
void includeTodayAsOperatingDateIfNecessary();
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -560,8 +560,6 @@
if (m_didNetworkProcessCrash) {
m_didNetworkProcessCrash = false;
reinstateNetworkProcessAssertionState(*m_networkProcess);
- if (m_websiteDataStore)
- m_websiteDataStore->websiteDataStore().networkProcessDidCrash();
}
if (withWebsiteDataStore) {
@@ -569,6 +567,9 @@
withWebsiteDataStore->clearPendingCookies();
}
+ if (m_websiteDataStore)
+ m_websiteDataStore->websiteDataStore().didCreateNetworkProcess();
+
return *m_networkProcess;
}
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -38,6 +38,7 @@
#include "WebsiteDataFetchOption.h"
#include "WebsiteDataStore.h"
#include <WebCore/ResourceLoadStatistics.h>
+#include <wtf/CallbackAggregator.h>
#include <wtf/CrossThreadCopier.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/threads/BinarySemaphore.h>
@@ -321,6 +322,22 @@
callback(false);
}
+void WebResourceLoadStatisticsStore::didCreateNetworkProcess()
+{
+ ASSERT(RunLoop::isMain());
+
+ postTask([this] {
+ if (!m_memoryStore)
+ return;
+ m_memoryStore->updateCookieBlocking([]() { });
+ });
+
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ if (m_websiteDataStore)
+ m_websiteDataStore->setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies::Yes, []() { });
+#endif
+}
+
void WebResourceLoadStatisticsStore::removeAllStorageAccess(CompletionHandler<void()>&& completionHandler)
{
ASSERT(RunLoop::isMain());
@@ -716,17 +733,17 @@
});
}
-void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
{
// Helper function used by testing system. Should only be called from the main thread.
ASSERT(RunLoop::isMain());
- postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), shouldClearFirst, completionHandler = WTFMove(completionHandler)] () mutable {
+ postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
if (!m_memoryStore) {
postTaskReply(WTFMove(completionHandler));
return;
}
- m_memoryStore->updateCookieBlockingForDomains(domainsToBlock, shouldClearFirst, [completionHandler = WTFMove(completionHandler)]() mutable {
+ m_memoryStore->updateCookieBlockingForDomains(domainsToBlock, [completionHandler = WTFMove(completionHandler)]() mutable {
postTaskReply(WTFMove(completionHandler));
});
});
@@ -748,17 +765,6 @@
});
}
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-void WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset()
-{
- ASSERT(RunLoop::isMain());
- postTask([this] {
- if (m_memoryStore)
- m_memoryStore->resetCookieBlockingState();
- });
-}
-#endif
-
void WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler)
{
ASSERT(RunLoop::isMain());
@@ -836,13 +842,13 @@
completionHandler();
}
-void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
{
ASSERT(RunLoop::isMain());
#if ENABLE(RESOURCE_LOAD_STATISTICS)
if (m_websiteDataStore) {
- m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, shouldClearFirst, WTFMove(completionHandler));
+ m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, WTFMove(completionHandler));
return;
}
#endif
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-10-19 21:37:54 UTC (rev 237304)
@@ -53,7 +53,6 @@
class WebProcessProxy;
class WebsiteDataStore;
-enum class ShouldClearFirst;
enum class StorageAccessStatus {
CannotRequestAccess,
RequiresUserPrompt,
@@ -107,14 +106,11 @@
void setTopFrameUniqueRedirectTo(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedTo);
void setTopFrameUniqueRedirectFrom(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedFrom);
void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
- void scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+ void scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
void scheduleClearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
void scheduleStatisticsAndDataRecordsProcessing();
void submitTelemetry();
- void scheduleCookieBlockingStateReset();
- void scheduleClearInMemory(CompletionHandler<void()>&&);
-
enum class ShouldGrandfather {
No,
Yes,
@@ -138,10 +134,12 @@
void logTestingEvent(const String&);
void callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
void removeAllStorageAccess(CompletionHandler<void()>&&);
- void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+ void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
void callRemoveDomainsHandler(const Vector<String>& domains);
void callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
+ void didCreateNetworkProcess();
+
private:
explicit WebResourceLoadStatisticsStore(WebsiteDataStore&);
@@ -171,6 +169,8 @@
bool m_hasScheduledProcessStats { false };
WTF::Function<void(const String&)> m_statisticsTestingCallback;
+
+ bool m_firstNetworkProcessCreated { false };
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-10-19 21:37:54 UTC (rev 237304)
@@ -1256,16 +1256,26 @@
}
#if ENABLE(RESOURCE_LOAD_STATISTICS)
-void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
{
auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
for (auto& processPool : processPools()) {
if (auto* process = processPool->networkProcess())
- process->updatePrevalentDomainsToBlockCookiesFor(m_sessionID, domainsToBlock, shouldClearFirst, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
+ process->updatePrevalentDomainsToBlockCookiesFor(m_sessionID, domainsToBlock, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
}
}
+void WebsiteDataStore::setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
+{
+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
+
+ for (auto& processPool : processPools()) {
+ if (auto* process = processPool->networkProcess())
+ process->setShouldCapLifetimeForClientSideCookies(m_sessionID, shouldCapLifetime, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
+ }
+}
+
void WebsiteDataStore::hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& completionHandler)
{
auto* webPage = WebProcessProxy::webPage(pageID);
@@ -1347,7 +1357,7 @@
m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
}
-#endif
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
void WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds, CompletionHandler<void()>&& completionHandler)
{
@@ -1378,14 +1388,6 @@
#endif
}
-void WebsiteDataStore::networkProcessDidCrash()
-{
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
- if (m_resourceLoadStatistics)
- m_resourceLoadStatistics->scheduleCookieBlockingStateReset();
-#endif
-}
-
void WebsiteDataStore::webPageWasAdded(WebPageProxy& webPageProxy)
{
if (m_storageManager)
@@ -1687,4 +1689,10 @@
}
#endif
+void WebsiteDataStore::didCreateNetworkProcess()
+{
+ if (m_resourceLoadStatistics)
+ m_resourceLoadStatistics->didCreateNetworkProcess();
}
+
+}
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (237303 => 237304)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-10-19 21:29:13 UTC (rev 237303)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-10-19 21:37:54 UTC (rev 237304)
@@ -74,7 +74,7 @@
struct PluginModuleInfo;
#endif
-enum class ShouldClearFirst { No, Yes };
+enum class ShouldCapLifetimeForClientSideCookies { No, Yes };
class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore>, public CanMakeWeakPtr<WebsiteDataStore> {
public:
@@ -137,7 +137,8 @@
void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
- void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+ void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
+ void setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&);
void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&&);
void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&);
void grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&&);
@@ -149,7 +150,6 @@
#endif
void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&);
void resetCacheMaxAgeCapForPrevalentResources(CompletionHandler<void()>&&);
- void networkProcessDidCrash();
void resolveDirectoriesIfNecessary();
const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration.applicationCacheDirectory; }
const String& resolvedMediaCacheDirectory() const { return m_resolvedConfiguration.mediaCacheDirectory; }
@@ -199,6 +199,8 @@
void setMockWebAuthenticationConfiguration(MockWebAuthenticationConfiguration&&);
#endif
+ void didCreateNetworkProcess();
+
private:
explicit WebsiteDataStore(PAL::SessionID);
explicit WebsiteDataStore(Configuration, PAL::SessionID);