Diff
Added: branches/safari-606-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt (0 => 239403)
--- branches/safari-606-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt (rev 0)
+++ branches/safari-606-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt 2018-12-20 00:07:32 UTC (rev 239403)
@@ -0,0 +1,22 @@
+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
+
+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
+
Added: branches/safari-606-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html (0 => 239403)
--- branches/safari-606-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html (rev 0)
+++ branches/safari-606-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html 2018-12-20 00:07:32 UTC (rev 239403)
@@ -0,0 +1,158 @@
+<!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>
+<!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: branches/safari-606-branch/Source/WebCore/ChangeLog (239402 => 239403)
--- branches/safari-606-branch/Source/WebCore/ChangeLog 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog 2018-12-20 00:07:32 UTC (rev 239403)
@@ -1,3 +1,27 @@
+2018-12-19 Alan Coon <alanc...@apple.com>
+
+ Apply patch. rdar://problem/46848447
+
+ 2018-12-19 Brent Fulgham <bfulg...@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
+
+ * platform/network/NetworkStorageSession.cpp:
+ (WebCore::NetworkStorageSession::setShouldCapLifetimeForClientSideCookies):
+ (WebCore::NetworkStorageSession::shouldCapLifetimeForClientSideCookies const):
+ * platform/network/NetworkStorageSession.h:
+ * platform/network/mac/CookieJarMac.mm:
+ (WebCore::filterCookies):
+ (WebCore::setCookiesFromDOM): Now consults the new NetworkStorageSession's
+ m_shouldCapLifetimeForClientSideCookies member variable before capping the
+ lifetime of cookies.
+
2018-12-19 Kocsen Chung <kocsen_ch...@apple.com>
Apply patch. rdar://problem/46848447
Modified: branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp (239402 => 239403)
--- branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp 2018-12-20 00:07:32 UTC (rev 239403)
@@ -74,4 +74,14 @@
removeProcessPrivilege(ProcessPrivilege::CanAccessRawCookies);
}
+void NetworkStorageSession::setShouldCapLifetimeForClientSideCookies(bool value)
+{
+ m_shouldCapLifetimeForClientSideCookies = value;
}
+
+bool NetworkStorageSession::shouldCapLifetimeForClientSideCookies() const
+{
+ return m_shouldCapLifetimeForClientSideCookies;
+}
+
+}
Modified: branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h (239402 => 239403)
--- branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h 2018-12-20 00:07:32 UTC (rev 239403)
@@ -101,6 +101,8 @@
WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource) const;
WEBCORE_EXPORT String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
WEBCORE_EXPORT void setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst);
+ WEBCORE_EXPORT void setShouldCapLifetimeForClientSideCookies(bool);
+ WEBCORE_EXPORT bool shouldCapLifetimeForClientSideCookies() const;
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;
@@ -175,6 +177,7 @@
HashSet<String> m_topPrivatelyControlledDomainsToBlock;
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;
+ bool m_shouldCapLifetimeForClientSideCookies { false };
#endif
#if PLATFORM(COCOA)
Modified: branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm (239402 => 239403)
--- branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm 2018-12-20 00:07:32 UTC (rev 239403)
@@ -145,7 +145,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];
@@ -166,7 +166,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]);
@@ -335,7 +335,11 @@
NSArray *unfilteredCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:cookieURL];
#endif
- RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies);
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, session.shouldCapLifetimeForClientSideCookies());
+#else
+ RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);
+#endif
ASSERT([filteredCookies.get() count] <= 1);
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/ChangeLog 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog 2018-12-20 00:07:32 UTC (rev 239403)
@@ -1,3 +1,50 @@
+2018-12-19 Alan Coon <alanc...@apple.com>
+
+ Apply patch. rdar://problem/46848447
+
+ 2018-12-19 Brent Fulgham <bfulg...@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>
+
+ 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:
+
+ * 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::setShouldCapLifetimeForClientSideCookies):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies):
+ (WebKit::NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies):
+ * UIProcess/Network/NetworkProcessProxy.h:
+ * UIProcess/Network/NetworkProcessProxy.messages.in:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::ensureNetworkProcess):
+ * UIProcess/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::didCreateNetworkProcess):
+ * UIProcess/WebResourceLoadStatisticsStore.h:
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::setShouldCapLifetimeForClientSideCookies):
+ (WebKit::WebsiteDataStore::didCreateNetworkProcess):
+ (WebKit::WebsiteDataStore::networkProcessDidCrash): Deleted.
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
2018-12-05 Alan Coon <alanc...@apple.com>
Apply patch. rdar://problem/45997392
Modified: branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-12-20 00:07:32 UTC (rev 239403)
@@ -426,6 +426,13 @@
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdatePartitionOrBlockCookies(callbackId), 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))
Modified: branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-12-20 00:07:32 UTC (rev 239403)
@@ -132,6 +132,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId);
+ 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: branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-12-20 00:07:32 UTC (rev 239403)
@@ -85,6 +85,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId)
+ 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: branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-12-20 00:07:32 UTC (rev 239403)
@@ -444,6 +444,26 @@
m_updatePartitionOrBlockCookiesCallbackMap.take(callbackId)();
}
+void NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
+{
+ if (!canSendMessage()) {
+ completionHandler();
+ return;
+ }
+
+ auto callbackId = generateCallbackID();
+ auto addResult = m_updatePartitionOrBlockCookiesCallbackMap.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_updatePartitionOrBlockCookiesCallbackMap.take(callbackId)();
+}
+
static uint64_t nextRequestStorageAccessContextId()
{
static uint64_t nextContextId = 0;
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-12-20 00:07:32 UTC (rev 239403)
@@ -79,6 +79,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, 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);
@@ -148,6 +149,7 @@
#endif
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void didUpdatePartitionOrBlockCookies(uint64_t callbackId);
+ void didSetShouldCapLifetimeForClientSideCookies(uint64_t contextId);
void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
#endif
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-12-20 00:07:32 UTC (rev 239403)
@@ -48,6 +48,7 @@
#endif
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
DidUpdatePartitionOrBlockCookies(uint64_t callbackId)
+ DidSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
#endif
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-12-20 00:07:32 UTC (rev 239403)
@@ -530,8 +530,6 @@
if (m_didNetworkProcessCrash) {
m_didNetworkProcessCrash = false;
reinstateNetworkProcessAssertionState(*m_networkProcess);
- if (m_websiteDataStore)
- m_websiteDataStore->websiteDataStore().networkProcessDidCrash();
}
if (withWebsiteDataStore) {
@@ -539,6 +537,9 @@
withWebsiteDataStore->clearPendingCookies();
}
+ if (m_websiteDataStore)
+ m_websiteDataStore->websiteDataStore().didCreateNetworkProcess();
+
return *m_networkProcess;
}
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-12-20 00:07:32 UTC (rev 239403)
@@ -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>
@@ -317,6 +318,22 @@
callback(false);
}
+void WebResourceLoadStatisticsStore::didCreateNetworkProcess()
+{
+ ASSERT(RunLoop::isMain());
+
+ postTask([this] {
+ if (!m_memoryStore)
+ return;
+ m_memoryStore->updateCookiePartitioning([]() { });
+ });
+
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ if (m_websiteDataStore)
+ m_websiteDataStore->setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies::Yes, []() { });
+#endif
+}
+
void WebResourceLoadStatisticsStore::removeAllStorageAccess()
{
ASSERT(RunLoop::isMain());
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-12-20 00:07:32 UTC (rev 239403)
@@ -140,6 +140,8 @@
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&);
@@ -169,6 +171,8 @@
bool m_hasScheduledProcessStats { false };
WTF::Function<void(const String&)> m_statisticsTestingCallback;
+
+ bool m_firstNetworkProcessCreated { false };
};
} // namespace WebKit
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-12-20 00:07:32 UTC (rev 239403)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -1244,6 +1244,16 @@
}
}
+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);
@@ -1325,14 +1335,6 @@
}
#endif
-void WebsiteDataStore::networkProcessDidCrash()
-{
-#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- if (m_resourceLoadStatistics)
- m_resourceLoadStatistics->scheduleCookiePartitioningStateReset();
-#endif
-}
-
void WebsiteDataStore::webPageWasAdded(WebPageProxy& webPageProxy)
{
if (m_storageManager)
@@ -1623,4 +1625,12 @@
}
#endif
+void WebsiteDataStore::didCreateNetworkProcess()
+{
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ if (m_resourceLoadStatistics)
+ m_resourceLoadStatistics->didCreateNetworkProcess();
+#endif
}
+
+}
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (239402 => 239403)
--- branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-12-19 23:51:03 UTC (rev 239402)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-12-20 00:07:32 UTC (rev 239403)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -72,6 +72,7 @@
#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:
@@ -131,6 +132,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, 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)>&&);
@@ -140,7 +142,6 @@
void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
#endif
- void networkProcessDidCrash();
void resolveDirectoriesIfNecessary();
const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration.applicationCacheDirectory; }
const String& resolvedMediaCacheDirectory() const { return m_resolvedConfiguration.mediaCacheDirectory; }
@@ -184,6 +185,8 @@
void addSecKeyProxyStore(Ref<SecKeyProxyStore>&&);
#endif
+ void didCreateNetworkProcess();
+
private:
explicit WebsiteDataStore(PAL::SessionID);
explicit WebsiteDataStore(Configuration, PAL::SessionID);