Diff
Modified: trunk/LayoutTests/ChangeLog (222395 => 222396)
--- trunk/LayoutTests/ChangeLog 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/LayoutTests/ChangeLog 2017-09-22 18:53:32 UTC (rev 222396)
@@ -1,3 +1,29 @@
+2017-09-22 John Wilander <[email protected]>
+
+ Non-prevalent resources should be allowed access to existing cookies in a third-party context
+ https://bugs.webkit.org/show_bug.cgi?id=177336
+ <rdar://problem/34578257>
+
+ Reviewed by Brent Fulgham.
+
+ This patch restructures what is communicated to the network process,
+ from two vectors - with user interaction and without user interaction -
+ to three vectors - to partition, to block, to neither partition nor block.
+ The previous two vectors did not allow proper categorization into which
+ domains should be partitioned, blocked, or left alone. That was the cause
+ of the regression where non-prevalent third-party domains erroneously had
+ their cookies blocked when they should fall back to the old behavior of
+ access but no new cookies allowed to be set.
+
+ See follow-up bug to assess these tests:
+ https://bugs.webkit.org/show_bug.cgi?id=177337
+
+ * http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-network-process-crash.html:
+ * http/tests/loading/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html:
+ * platform/mac-wk2/TestExpectations:
+ Marked two new failures since the need to be reworked in:
+ https://bugs.webkit.org/show_bug.cgi?id=177337
+
2017-09-22 Ryan Haddad <[email protected]>
Move test expectations from 'ios-11' to 'ios' directory.
Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-network-process-crash.html (222395 => 222396)
--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-network-process-crash.html 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-network-process-crash.html 2017-09-22 18:53:32 UTC (rev 222396)
@@ -77,7 +77,7 @@
});
if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
testFailed("Host was no longer prevalent resource.");
- testRunner.statisticsFireDataModificationHandler();
+ testRunner.statisticsProcessStatisticsAndDataRecords();
break;
case "#step7":
// Set first-party cookie for prevalent resource.
@@ -97,7 +97,7 @@
if (document.location.host === partitionHost && document.location.hash === "" && window.testRunner && window.internals) {
- testRunner.statisticsFireShouldPartitionCookiesHandlerForOneDomain("localhost", true);
+ testRunner.statisticsSetShouldPartitionCookiesForHost("localhost", true);
testRunner.setStatisticsPrevalentResource("http://localhost", true);
if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
testFailed("Host did not get set as prevalent resource.");
Modified: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html (222395 => 222396)
--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html 2017-09-22 18:53:32 UTC (rev 222396)
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
- <title>Test for Partitioned Cookies With and Without User Interaction</title>
+ <title>Test to ensure non-prevalent resources can access their cookies in a third party context</title>
<script src=""
</head>
<body>
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (222395 => 222396)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-09-22 18:53:32 UTC (rev 222396)
@@ -794,8 +794,8 @@
[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html [ Pass ]
[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html [ Pass ]
[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html [ Pass ]
-[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html [ Pass ]
-[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html [ Pass ]
+[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html [ Pass Failure ]
+[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html [ Pass Failure ]
# <rdar://problem/33555759>
[ HighSierra+ ] http/tests/media/video-buffered-range-contains-currentTime.html [ Pass ImageOnlyFailure ]
Modified: trunk/Source/WebCore/ChangeLog (222395 => 222396)
--- trunk/Source/WebCore/ChangeLog 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebCore/ChangeLog 2017-09-22 18:53:32 UTC (rev 222396)
@@ -1,3 +1,42 @@
+2017-09-22 John Wilander <[email protected]>
+
+ Non-prevalent resources should be allowed access to existing cookies in a third-party context
+ https://bugs.webkit.org/show_bug.cgi?id=177336
+ <rdar://problem/34578257>
+
+ Reviewed by Brent Fulgham.
+
+ No new tests. I will update existing tests and add at least
+ one new test in a follow-up patch,
+ see https://bugs.webkit.org/show_bug.cgi?id=177337. Need to
+ land this to meet submission deadline and fix the regression.
+
+ This patch restructures what is communicated to the network process,
+ from two vectors - with user interaction and without user interaction -
+ to three vectors - to partition, to block, to neither partition nor block.
+ The previous two vectors did not allow proper categorization into which
+ domains should be partitioned, blocked, or left alone. That was the cause
+ of the regression where non-prevalent third-party domains erroneously had
+ their cookies blocked when they should fall back to the old behavior of
+ access but no new cookies allowed to be set.
+
+ * loader/ResourceLoadStatistics.cpp:
+ (WebCore::ResourceLoadStatistics::toString const):
+ (WebCore::ResourceLoadStatistics::merge):
+ * loader/ResourceLoadStatistics.h:
+ * platform/network/NetworkStorageSession.h:
+ * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+ (WebCore::NetworkStorageSession::shouldPartitionCookies const):
+ (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookies const):
+ (WebCore::NetworkStorageSession::shouldBlockCookies const):
+ (WebCore::NetworkStorageSession::setPrevalentDomainsToPartitionOrBlockCookies):
+ (WebCore::NetworkStorageSession::removePrevalentDomains):
+ (WebCore::NetworkStorageSession::shouldAllowThirdPartyCookies const): Deleted.
+ (WebCore::NetworkStorageSession::setPrevalentDomainsWithAndWithoutInteraction): Deleted.
+ * platform/network/mac/CookieJarMac.mm:
+ (WebCore::cookiesInBlockedForURL):
+ (WebCore::cookiesForURL):
+
2017-09-22 Fujii Hironori <[email protected]>
[CMake][Win] EventTargetInterfaces.h are generated twice
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp (222395 => 222396)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2017-09-22 18:53:32 UTC (rev 222396)
@@ -229,6 +229,7 @@
// In-memory only
appendBoolean(builder, "isMarkedForCookiePartitioning", isMarkedForCookiePartitioning);
+ appendBoolean(builder, "isMarkedForCookieBlocking", isMarkedForCookieBlocking);
builder.append('\n');
builder.append('\n');
@@ -287,6 +288,7 @@
// In-memory only
isMarkedForCookiePartitioning |= other.isMarkedForCookiePartitioning;
+ isMarkedForCookieBlocking |= other.isMarkedForCookieBlocking;
}
String ResourceLoadStatistics::primaryDomain(const URL& url)
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (222395 => 222396)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2017-09-22 18:53:32 UTC (rev 222396)
@@ -86,6 +86,7 @@
// In-memory only
bool isMarkedForCookiePartitioning { false };
+ bool isMarkedForCookieBlocking { false };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (222395 => 222396)
--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2017-09-22 18:53:32 UTC (rev 222396)
@@ -91,8 +91,9 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
WEBCORE_EXPORT String cookieStoragePartition(const ResourceRequest&) const;
WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&) const;
+ bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource) const;
String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource) const;
- WEBCORE_EXPORT void setPrevalentDomainsWithAndWithoutInteraction(const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, bool clearFirst);
+ WEBCORE_EXPORT void setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst);
WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains);
#endif
#elif USE(SOUP)
@@ -148,9 +149,9 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
bool shouldPartitionCookies(const String& topPrivatelyControlledDomain) const;
- bool shouldAllowThirdPartyCookies(const String& topPrivatelyControlledDomain) const;
- HashSet<String> m_prevalentTopPrivatelyControlledDomainsWithoutInteraction;
- HashSet<String> m_prevalentTopPrivatelyControlledDomainsWithInteraction;
+ bool shouldBlockThirdPartyCookies(const String& topPrivatelyControlledDomain) const;
+ HashSet<String> m_topPrivatelyControlledDomainsToPartition;
+ HashSet<String> m_topPrivatelyControlledDomainsToBlock;
#endif
#if PLATFORM(COCOA)
Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (222395 => 222396)
--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp 2017-09-22 18:53:32 UTC (rev 222396)
@@ -205,15 +205,15 @@
if (topPrivatelyControlledDomain.isEmpty())
return false;
- return m_prevalentTopPrivatelyControlledDomainsWithoutInteraction.contains(topPrivatelyControlledDomain);
+ return m_topPrivatelyControlledDomainsToPartition.contains(topPrivatelyControlledDomain);
}
-bool NetworkStorageSession::shouldAllowThirdPartyCookies(const String& topPrivatelyControlledDomain) const
+bool NetworkStorageSession::shouldBlockThirdPartyCookies(const String& topPrivatelyControlledDomain) const
{
if (topPrivatelyControlledDomain.isEmpty())
return false;
- return m_prevalentTopPrivatelyControlledDomainsWithInteraction.contains(topPrivatelyControlledDomain);
+ return m_topPrivatelyControlledDomainsToBlock.contains(topPrivatelyControlledDomain);
}
bool NetworkStorageSession::shouldBlockCookies(const ResourceRequest& request) const
@@ -221,11 +221,19 @@
if (!cookieStoragePartitioningEnabled)
return false;
- auto firstPartyDomain = getPartitioningDomain(request.firstPartyForCookies());
+ return shouldBlockCookies(request.firstPartyForCookies(), request.url());
+}
+
+bool NetworkStorageSession::shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource) const
+{
+ if (!cookieStoragePartitioningEnabled)
+ return false;
+
+ auto firstPartyDomain = getPartitioningDomain(firstPartyForCookies);
if (firstPartyDomain.isEmpty())
return false;
- auto resourceDomain = getPartitioningDomain(request.url());
+ auto resourceDomain = getPartitioningDomain(resource);
if (resourceDomain.isEmpty())
return false;
@@ -232,37 +240,41 @@
if (firstPartyDomain == resourceDomain)
return false;
- if (shouldPartitionCookies(resourceDomain))
- return false;
-
- return !shouldAllowThirdPartyCookies(resourceDomain);
+ return shouldBlockThirdPartyCookies(resourceDomain);
}
-void NetworkStorageSession::setPrevalentDomainsWithAndWithoutInteraction(const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, bool clearFirst)
+void NetworkStorageSession::setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst)
{
if (clearFirst) {
- m_prevalentTopPrivatelyControlledDomainsWithoutInteraction.clear();
- m_prevalentTopPrivatelyControlledDomainsWithInteraction.clear();
+ m_topPrivatelyControlledDomainsToPartition.clear();
+ m_topPrivatelyControlledDomainsToBlock.clear();
}
- for (auto& domain : domainsWithInteraction) {
+ for (auto& domain : domainsToPartition) {
+ m_topPrivatelyControlledDomainsToPartition.add(domain);
if (!clearFirst)
- m_prevalentTopPrivatelyControlledDomainsWithoutInteraction.remove(domain);
- m_prevalentTopPrivatelyControlledDomainsWithInteraction.add(domain);
+ m_topPrivatelyControlledDomainsToBlock.remove(domain);
}
- for (auto& domain : domainsWithoutInteraction) {
- m_prevalentTopPrivatelyControlledDomainsWithoutInteraction.add(domain);
+ for (auto& domain : domainsToBlock) {
+ m_topPrivatelyControlledDomainsToBlock.add(domain);
if (!clearFirst)
- m_prevalentTopPrivatelyControlledDomainsWithInteraction.remove(domain);
+ m_topPrivatelyControlledDomainsToPartition.remove(domain);
}
+
+ if (!clearFirst) {
+ for (auto& domain : domainsToNeitherPartitionNorBlock) {
+ m_topPrivatelyControlledDomainsToPartition.remove(domain);
+ m_topPrivatelyControlledDomainsToBlock.remove(domain);
+ }
+ }
}
void NetworkStorageSession::removePrevalentDomains(const Vector<String>& domains)
{
for (auto& domain : domains) {
- m_prevalentTopPrivatelyControlledDomainsWithoutInteraction.remove(domain);
- m_prevalentTopPrivatelyControlledDomainsWithInteraction.remove(domain);
+ m_topPrivatelyControlledDomainsToPartition.remove(domain);
+ m_topPrivatelyControlledDomainsToBlock.remove(domain);
}
}
Modified: trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm (222395 => 222396)
--- trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm 2017-09-22 18:53:32 UTC (rev 222396)
@@ -101,6 +101,11 @@
return partitionedCookies;
}
+static bool cookiesAreBlockedForURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+ return session.shouldBlockCookies(firstParty, url);
+}
+
static NSArray *cookiesInPartitionForURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
{
String partition = session.cookieStoragePartition(firstParty, url);
@@ -130,6 +135,9 @@
static NSArray *cookiesForURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
{
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ if (cookiesAreBlockedForURL(session, firstParty, url))
+ return nil;
+
if (NSArray *cookies = cookiesInPartitionForURL(session, firstParty, url))
return cookies;
#endif
Modified: trunk/Source/WebKit/ChangeLog (222395 => 222396)
--- trunk/Source/WebKit/ChangeLog 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/ChangeLog 2017-09-22 18:53:32 UTC (rev 222396)
@@ -1,3 +1,45 @@
+2017-09-22 John Wilander <[email protected]>
+
+ Non-prevalent resources should be allowed access to existing cookies in a third-party context
+ https://bugs.webkit.org/show_bug.cgi?id=177336
+ <rdar://problem/34578257>
+
+ Reviewed by Brent Fulgham.
+
+ This patch restructures what is communicated to the network process,
+ from two vectors - with user interaction and without user interaction -
+ to three vectors - to partition, to block, to neither partition nor block.
+ The previous two vectors did not allow proper categorization into which
+ domains should be partitioned, blocked, or left alone. That was the cause
+ of the regression where non-prevalent third-party domains erroneously had
+ their cookies blocked when they should fall back to the old behavior of
+ access but no new cookies allowed to be set.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::updatePrevalentDomainsToPartitionOrBlockCookies):
+ (WebKit::NetworkProcess::updatePrevalentDomainsWithAndWithoutInteraction): Deleted.
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]):
+ * UIProcess/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+ (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
+ (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
+ (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
+ (WebKit::WebResourceLoadStatisticsStore::shouldPartitionCookies const):
+ (WebKit::WebResourceLoadStatisticsStore::shouldBlockCookies const):
+ (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
+ (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
+ (WebKit::WebResourceLoadStatisticsStore::clearPartitioningStateForDomains):
+ (WebKit::WebResourceLoadStatisticsStore::resetCookiePartitioningState):
+ * UIProcess/WebResourceLoadStatisticsStore.h:
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::updatePrevalentDomainsToPartitionOrBlockCookies):
+ (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):
+ (WebKit::WebsiteDataStore::updatePrevalentDomainsWithAndWithoutInteraction): Deleted.
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
2017-09-22 Tim Horton <[email protected]> and Michael Catanzaro <[email protected]>
Remove build-webkit's notion of feature flags having a default value
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (222395 => 222396)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2017-09-22 18:53:32 UTC (rev 222396)
@@ -321,10 +321,10 @@
}
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-void NetworkProcess::updatePrevalentDomainsWithAndWithoutInteraction(PAL::SessionID sessionID, const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, bool shouldClearFirst)
+void NetworkProcess::updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst)
{
if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
- networkStorageSession->setPrevalentDomainsWithAndWithoutInteraction(domainsWithInteraction, domainsWithoutInteraction, shouldClearFirst);
+ networkStorageSession->setPrevalentDomainsToPartitionOrBlockCookies(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst);
}
void NetworkProcess::removePrevalentDomains(PAL::SessionID sessionID, const Vector<String>& domains)
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (222395 => 222396)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2017-09-22 18:53:32 UTC (rev 222396)
@@ -130,7 +130,7 @@
void grantSandboxExtensionsToStorageProcessForBlobs(const Vector<String>& filenames, Function<void ()>&& completionHandler);
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- void updatePrevalentDomainsWithAndWithoutInteraction(PAL::SessionID, const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, bool shouldClearFirst);
+ void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst);
void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains);
#endif
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (222395 => 222396)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2017-09-22 18:53:32 UTC (rev 222396)
@@ -83,7 +83,7 @@
DidGrantSandboxExtensionsToStorageProcessForBlobs(uint64_t requestID)
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- UpdatePrevalentDomainsWithAndWithoutInteraction(PAL::SessionID sessionID, Vector<String> domainsWithInteraction, Vector<String> domainsWithoutInteraction, bool shouldClearFirst)
+ UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst)
RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction);
#endif
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (222395 => 222396)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2017-09-22 18:53:32 UTC (rev 222396)
@@ -421,7 +421,7 @@
return;
if (value)
- store->scheduleCookiePartitioningUpdateForDomains({ }, { host }, WebKit::ShouldClearFirst::No);
+ store->scheduleCookiePartitioningUpdateForDomains({ host }, { }, { }, WebKit::ShouldClearFirst::No);
else
store->scheduleClearPartitioningStateForDomains({ host });
}
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (222395 => 222396)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2017-09-22 18:53:32 UTC (rev 222396)
@@ -145,10 +145,10 @@
return mergedDates;
}
-WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory, Function<void (const String&)>&& testingCallback, UpdatePrevalentDomainsWithAndWithoutInteractionHandler&& updatePrevalentDomainsWithAndWithoutInteractionHandler, RemovePrevalentDomainsHandler&& removeDomainsHandler)
+WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory, Function<void (const String&)>&& testingCallback, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&& updatePrevalentDomainsToPartitionOrBlockCookiesHandler, RemovePrevalentDomainsHandler&& removeDomainsHandler)
: m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility))
, m_persistentStorage(*this, resourceLoadStatisticsDirectory)
- , m_updatePrevalentDomainsWithAndWithoutInteractionHandler(WTFMove(updatePrevalentDomainsWithAndWithoutInteractionHandler))
+ , m_updatePrevalentDomainsToPartitionOrBlockCookiesHandler(WTFMove(updatePrevalentDomainsToPartitionOrBlockCookiesHandler))
, m_removeDomainsHandler(WTFMove(removeDomainsHandler))
, m_dailyTasksTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::performDailyTasks)
, m_statisticsTestingCallback(WTFMove(testingCallback))
@@ -309,7 +309,7 @@
statistics.hadUserInteraction = true;
statistics.mostRecentUserInteractionTime = WallTime::now();
- updateCookiePartitioningForDomains({ primaryDomain }, { }, ShouldClearFirst::No);
+ updateCookiePartitioningForDomains({ }, { }, { primaryDomain }, ShouldClearFirst::No);
});
}
@@ -460,12 +460,12 @@
});
}
-void WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, ShouldClearFirst shouldClearFirst)
+void WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst)
{
// Helper function used by testing system. Should only be called from the main thread.
ASSERT(RunLoop::isMain());
- m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), domainsToRemove = crossThreadCopy(domainsToRemove), domainsToAdd = crossThreadCopy(domainsToAdd), shouldClearFirst] {
- updateCookiePartitioningForDomains(domainsToRemove, domainsToAdd, shouldClearFirst);
+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock), shouldClearFirst] {
+ updateCookiePartitioningForDomains(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst);
});
}
@@ -631,7 +631,7 @@
m_resourceStatisticsMap.clear();
m_operatingDates.clear();
- updateCookiePartitioningForDomains({ }, { }, ShouldClearFirst::Yes);
+ updateCookiePartitioningForDomains({ }, { }, { }, ShouldClearFirst::Yes);
}
void WebResourceLoadStatisticsStore::mergeStatistics(Vector<ResourceLoadStatistics>&& statistics)
@@ -646,55 +646,74 @@
}
}
-inline bool WebResourceLoadStatisticsStore::shouldPartitionCookies(const ResourceLoadStatistics& statistic) const
+bool WebResourceLoadStatisticsStore::shouldPartitionCookies(const ResourceLoadStatistics& statistic) const
{
- return statistic.isPrevalentResource && (!statistic.hadUserInteraction || WallTime::now() > statistic.mostRecentUserInteractionTime + m_parameters.timeToLiveCookiePartitionFree);
+ return statistic.isPrevalentResource && statistic.hadUserInteraction && WallTime::now() > statistic.mostRecentUserInteractionTime + m_parameters.timeToLiveCookiePartitionFree;
}
+bool WebResourceLoadStatisticsStore::shouldBlockCookies(const ResourceLoadStatistics& statistic) const
+{
+ return statistic.isPrevalentResource && !statistic.hadUserInteraction;
+}
+
void WebResourceLoadStatisticsStore::updateCookiePartitioning()
{
ASSERT(!RunLoop::isMain());
- Vector<String> domainsWithoutInteraction;
- Vector<String> domainsWithInteraction;
+ Vector<String> domainsToPartition;
+ Vector<String> domainsToBlock;
+ Vector<String> domainsToNeitherPartitionNorBlock;
for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
+
bool shouldPartition = shouldPartitionCookies(resourceStatistic);
- if (resourceStatistic.isMarkedForCookiePartitioning && !shouldPartition) {
+ bool shouldBlock = shouldBlockCookies(resourceStatistic);
+
+ if (shouldPartition && !resourceStatistic.isMarkedForCookiePartitioning) {
+ domainsToPartition.append(resourceStatistic.highLevelDomain);
+ resourceStatistic.isMarkedForCookiePartitioning = true;
+ } else if (shouldBlock && !resourceStatistic.isMarkedForCookieBlocking) {
+ domainsToBlock.append(resourceStatistic.highLevelDomain);
+ resourceStatistic.isMarkedForCookieBlocking = true;
+ } else if (!shouldPartition && !shouldBlock && resourceStatistic.isPrevalentResource) {
+ domainsToNeitherPartitionNorBlock.append(resourceStatistic.highLevelDomain);
resourceStatistic.isMarkedForCookiePartitioning = false;
- domainsWithInteraction.append(resourceStatistic.highLevelDomain);
- } else if (!resourceStatistic.isMarkedForCookiePartitioning && shouldPartition) {
- resourceStatistic.isMarkedForCookiePartitioning = true;
- domainsWithoutInteraction.append(resourceStatistic.highLevelDomain);
+ resourceStatistic.isMarkedForCookieBlocking = false;
}
}
- if (domainsWithInteraction.isEmpty() && domainsWithoutInteraction.isEmpty())
+ if (domainsToPartition.isEmpty() && domainsToBlock.isEmpty() && domainsToNeitherPartitionNorBlock.isEmpty())
return;
- RunLoop::main().dispatch([this, protectedThis = makeRef(*this), domainsWithInteraction = crossThreadCopy(domainsWithInteraction), domainsWithoutInteraction = crossThreadCopy(domainsWithoutInteraction)] () {
- m_updatePrevalentDomainsWithAndWithoutInteractionHandler(domainsWithInteraction, domainsWithoutInteraction, ShouldClearFirst::No);
+ RunLoop::main().dispatch([this, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock)] () {
+ m_updatePrevalentDomainsToPartitionOrBlockCookiesHandler(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, ShouldClearFirst::No);
});
}
-void WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains(const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, ShouldClearFirst shouldClearFirst)
+void WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst)
{
ASSERT(!RunLoop::isMain());
- if (domainsWithInteraction.isEmpty() && domainsWithoutInteraction.isEmpty())
+ if (domainsToPartition.isEmpty() && domainsToBlock.isEmpty() && domainsToNeitherPartitionNorBlock.isEmpty())
return;
- RunLoop::main().dispatch([this, shouldClearFirst, protectedThis = makeRef(*this), domainsWithInteraction = crossThreadCopy(domainsWithInteraction), domainsWithoutInteraction = crossThreadCopy(domainsWithoutInteraction)] () {
- m_updatePrevalentDomainsWithAndWithoutInteractionHandler(domainsWithInteraction, domainsWithoutInteraction, shouldClearFirst);
+ RunLoop::main().dispatch([this, shouldClearFirst, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock)] () {
+ m_updatePrevalentDomainsToPartitionOrBlockCookiesHandler(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst);
});
if (shouldClearFirst == ShouldClearFirst::Yes)
resetCookiePartitioningState();
else {
- for (auto& domain : domainsWithInteraction)
- ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookiePartitioning = false;
+ for (auto& domain : domainsToNeitherPartitionNorBlock) {
+ auto& statistic = ensureResourceStatisticsForPrimaryDomain(domain);
+ statistic.isMarkedForCookiePartitioning = false;
+ statistic.isMarkedForCookieBlocking = false;
+ }
}
- for (auto& domain : domainsWithoutInteraction)
+ for (auto& domain : domainsToPartition)
ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookiePartitioning = true;
+
+ for (auto& domain : domainsToBlock)
+ ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookieBlocking = true;
}
void WebResourceLoadStatisticsStore::clearPartitioningStateForDomains(const Vector<String>& domains)
@@ -707,15 +726,20 @@
m_removeDomainsHandler(domains);
});
- for (auto& domain : domains)
- ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookiePartitioning = false;
+ for (auto& domain : domains) {
+ auto& statistic = ensureResourceStatisticsForPrimaryDomain(domain);
+ statistic.isMarkedForCookiePartitioning = false;
+ statistic.isMarkedForCookieBlocking = false;
+ }
}
void WebResourceLoadStatisticsStore::resetCookiePartitioningState()
{
ASSERT(!RunLoop::isMain());
- for (auto& resourceStatistic : m_resourceStatisticsMap.values())
+ for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
resourceStatistic.isMarkedForCookiePartitioning = false;
+ resourceStatistic.isMarkedForCookieBlocking = false;
+ }
}
void WebResourceLoadStatisticsStore::processStatistics(const WTF::Function<void (const ResourceLoadStatistics&)>& processFunction) const
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (222395 => 222396)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2017-09-22 18:53:32 UTC (rev 222396)
@@ -59,11 +59,11 @@
class WebResourceLoadStatisticsStore final : public IPC::Connection::WorkQueueMessageReceiver {
public:
- using UpdatePrevalentDomainsWithAndWithoutInteractionHandler = WTF::Function<void(const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, ShouldClearFirst)>;
+ using UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler = WTF::Function<void(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst)>;
using RemovePrevalentDomainsHandler = WTF::Function<void (const Vector<String>&)>;
- static Ref<WebResourceLoadStatisticsStore> create(const String& resourceLoadStatisticsDirectory, Function<void (const String&)>&& testingCallback, UpdatePrevalentDomainsWithAndWithoutInteractionHandler&& updateCookiePartitioningForDomainsHandler = [](const Vector<String>&, const Vector<String>&, ShouldClearFirst) { }, RemovePrevalentDomainsHandler&& removeDomainsHandler = [] (const Vector<String>&) { })
+ static Ref<WebResourceLoadStatisticsStore> create(const String& resourceLoadStatisticsDirectory, Function<void (const String&)>&& testingCallback, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&& updatePrevalentDomainsToPartitionOrBlockCookiesHandler = [](const Vector<String>&, const Vector<String>&, const Vector<String>&, ShouldClearFirst) { }, RemovePrevalentDomainsHandler&& removeDomainsHandler = [] (const Vector<String>&) { })
{
- return adoptRef(*new WebResourceLoadStatisticsStore(resourceLoadStatisticsDirectory, WTFMove(testingCallback), WTFMove(updateCookiePartitioningForDomainsHandler), WTFMove(removeDomainsHandler)));
+ return adoptRef(*new WebResourceLoadStatisticsStore(resourceLoadStatisticsDirectory, WTFMove(testingCallback), WTFMove(updatePrevalentDomainsToPartitionOrBlockCookiesHandler), WTFMove(removeDomainsHandler)));
}
~WebResourceLoadStatisticsStore();
@@ -96,7 +96,7 @@
void setSubresourceUnderTopFrameOrigin(const WebCore::URL& subresource, const WebCore::URL& topFrame);
void setSubresourceUniqueRedirectTo(const WebCore::URL& subresource, const WebCore::URL& hostNameRedirectedTo);
void scheduleCookiePartitioningUpdate();
- void scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, ShouldClearFirst);
+ void scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst);
void scheduleClearPartitioningStateForDomains(const Vector<String>& domains);
void scheduleStatisticsAndDataRecordsProcessing();
void submitTelemetry();
@@ -132,7 +132,7 @@
void logTestingEvent(const String&);
private:
- WebResourceLoadStatisticsStore(const String&, Function<void (const String&)>&& testingCallback, UpdatePrevalentDomainsWithAndWithoutInteractionHandler&&, RemovePrevalentDomainsHandler&&);
+ WebResourceLoadStatisticsStore(const String&, Function<void (const String&)>&& testingCallback, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&&, RemovePrevalentDomainsHandler&&);
void removeDataRecords();
@@ -144,12 +144,13 @@
void setDataRecordsBeingRemoved(bool);
bool shouldPartitionCookies(const WebCore::ResourceLoadStatistics&) const;
+ bool shouldBlockCookies(const WebCore::ResourceLoadStatistics&) const;
bool hasStatisticsExpired(const WebCore::ResourceLoadStatistics&) const;
bool hasHadUnexpiredRecentUserInteraction(WebCore::ResourceLoadStatistics&) const;
void includeTodayAsOperatingDateIfNecessary();
Vector<String> topPrivatelyControlledDomainsToRemoveWebsiteDataFor();
void updateCookiePartitioning();
- void updateCookiePartitioningForDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, ShouldClearFirst);
+ void updateCookiePartitioningForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst);
void clearPartitioningStateForDomains(const Vector<String>& domains);
void mergeStatistics(Vector<WebCore::ResourceLoadStatistics>&&);
WebCore::ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
@@ -183,7 +184,7 @@
ResourceLoadStatisticsPersistentStorage m_persistentStorage;
Vector<OperatingDate> m_operatingDates;
- UpdatePrevalentDomainsWithAndWithoutInteractionHandler m_updatePrevalentDomainsWithAndWithoutInteractionHandler;
+ UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler m_updatePrevalentDomainsToPartitionOrBlockCookiesHandler;
RemovePrevalentDomainsHandler m_removeDomainsHandler;
WallTime m_endOfGrandfatheringTimestamp;
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (222395 => 222396)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-09-22 18:53:32 UTC (rev 222396)
@@ -1114,10 +1114,10 @@
}
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-void WebsiteDataStore::updatePrevalentDomainsWithAndWithoutInteraction(const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, ShouldClearFirst shouldClearFirst)
+void WebsiteDataStore::updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst)
{
for (auto& processPool : processPools())
- processPool->sendToNetworkingProcess(Messages::NetworkProcess::UpdatePrevalentDomainsWithAndWithoutInteraction(m_sessionID, domainsWithInteraction, domainsWithoutInteraction, shouldClearFirst == ShouldClearFirst::Yes));
+ processPool->sendToNetworkingProcess(Messages::NetworkProcess::UpdatePrevalentDomainsToPartitionOrBlockCookies(m_sessionID, domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst == ShouldClearFirst::Yes));
}
void WebsiteDataStore::removePrevalentDomains(const Vector<String>& domains)
@@ -1311,8 +1311,8 @@
}
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory, WTFMove(callback), [this] (const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, ShouldClearFirst shouldClearFirst) {
- updatePrevalentDomainsWithAndWithoutInteraction(domainsWithInteraction, domainsWithoutInteraction, shouldClearFirst);
+ m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory, WTFMove(callback), [this] (const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst) {
+ updatePrevalentDomainsToPartitionOrBlockCookies(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst);
}, [this] (const Vector<String>& domainsToRemove) {
removePrevalentDomains(domainsToRemove);
});
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (222395 => 222396)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2017-09-22 18:44:54 UTC (rev 222395)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2017-09-22 18:53:32 UTC (rev 222396)
@@ -105,7 +105,7 @@
void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler);
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- void updatePrevalentDomainsWithAndWithoutInteraction(const Vector<String>& domainsWithInteraction, const Vector<String>& domainsWithoutInteraction, ShouldClearFirst);
+ void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst);
void removePrevalentDomains(const Vector<String>& domains);
#endif
void networkProcessDidCrash();