Diff
Modified: trunk/LayoutTests/ChangeLog (252622 => 252623)
--- trunk/LayoutTests/ChangeLog 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/LayoutTests/ChangeLog 2019-11-19 06:30:46 UTC (rev 252623)
@@ -1,3 +1,14 @@
+2019-11-18 John Wilander <[email protected]>
+
+ Check if ITP is on before applying third-party cookie blocking
+ https://bugs.webkit.org/show_bug.cgi?id=204322
+ <rdar://problem/57120772>
+
+ Reviewed by Chris Dumez and Alexey Proskuryakov.
+
+ * http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html: Added.
+
2019-11-18 Simon Fraser <[email protected]>
-webkit-font-smoothing: none leaves subsequent elements unantialiased
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt (0 => 252623)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt 2019-11-19 06:30:46 UTC (rev 252623)
@@ -0,0 +1,16 @@
+Tests that existing third-party cookies are not blocked when ITP is off.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Should receive its cookie.
+Received cookie named 'firstPartyCookie'.
+Client-side document.cookie: firstPartyCookie=value
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html (0 => 252623)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html 2019-11-19 06:30:46 UTC (rev 252623)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <script src=""
+ <script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+ description("Tests that existing third-party cookies are not blocked when ITP is off.");
+ jsTestIsAsync = true;
+
+ const partitionHost = "127.0.0.1:8000";
+ const partitionOrigin = "http://" + partitionHost;
+ const thirdPartyOrigin = "http://localhost:8000";
+ const resourcePath = "/resourceLoadStatistics/resources";
+ const thirdPartyBaseUrl = thirdPartyOrigin + resourcePath;
+ const firstPartyCookieName = "firstPartyCookie";
+ const subPathToSetFirstPartyCookie = "/set-cookie.php?name=" + firstPartyCookieName + "&value=value";
+ const returnUrl = partitionOrigin + "/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html";
+ const subPathToGetCookies = "/get-cookies.php?name1=" + firstPartyCookieName;
+
+ function openIframe(url, onLoadHandler) {
+ const element = document.createElement("iframe");
+ if (onLoadHandler) {
+ element._onload_ = onLoadHandler;
+ }
+ element.src = ""
+ document.body.appendChild(element);
+ }
+
+ function runTest() {
+ switch (document.location.hash) {
+ case "":
+ document.location.hash = "step2";
+ testRunner.dumpChildFramesAsText();
+ // Enable the flag even though ITP will be turned off.
+ testRunner.setStatisticsShouldBlockThirdPartyCookies(true, function () {
+ testRunner.setStatisticsEnabled(false);
+ runTest();
+ });
+ break;
+ case "#step2":
+ // Set first-party cookie for localhost.
+ document.location.href = "" + subPathToSetFirstPartyCookie + "#" + returnUrl + "#step3";
+ break;
+ case "#step3":
+ // Check that the cookie is not blocked for localhost under 127.0.0.1.
+ openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive its cookie.", function() {
+ testRunner.setStatisticsEnabled(true);
+ testRunner.setStatisticsShouldBlockThirdPartyCookies(false, function() {
+ finishJSTest();
+ });
+ });
+ break;
+ }
+ }
+</script>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (252622 => 252623)
--- trunk/Source/WebCore/ChangeLog 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Source/WebCore/ChangeLog 2019-11-19 06:30:46 UTC (rev 252623)
@@ -1,3 +1,37 @@
+2019-11-18 John Wilander <[email protected]>
+
+ Check if ITP is on before applying third-party cookie blocking
+ https://bugs.webkit.org/show_bug.cgi?id=204322
+ <rdar://problem/57120772>
+
+ Reviewed by Chris Dumez and Alexey Proskuryakov.
+
+ This change makes sure WebCore::NetworkStorageSession knows
+ whether ITP is on or off and checks that first thing in
+ WebCore::NetworkStorageSession::shouldBlockCookies().
+
+ This check was never needed before since if ITP was off,
+ there would be no classified domains and thus the function
+ would always return false. However,
+ https://trac.webkit.org/changeset/251353/webkit introduced
+ full third-party cookie blocking for websites without user
+ interaction and that rule is checked before checking domain
+ classification. The effect was unconditional third-party
+ cookie blocking if ITP is off. This changes fixes that bug.
+
+ Note that this patch already landed as branch-specific in
+ https://trac.webkit.org/changeset/252549/webkit
+
+ Test: http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html
+
+ * platform/network/NetworkStorageSession.cpp:
+ (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookies const):
+ (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor const):
+ (WebCore::NetworkStorageSession::shouldBlockCookies const):
+ Now checks whether ITP is on or off.
+ * platform/network/NetworkStorageSession.h:
+ (WebCore::NetworkStorageSession::setResourceLoadStatisticsEnabled):
+
2019-11-18 Simon Fraser <[email protected]>
-webkit-font-smoothing: none leaves subsequent elements unantialiased
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp (252622 => 252623)
--- trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp 2019-11-19 06:30:46 UTC (rev 252623)
@@ -59,7 +59,7 @@
bool NetworkStorageSession::shouldBlockThirdPartyCookies(const RegistrableDomain& registrableDomain) const
{
- if (registrableDomain.isEmpty())
+ if (!m_isResourceLoadStatisticsEnabled || registrableDomain.isEmpty())
return false;
ASSERT(!(m_registrableDomainsToBlockAndDeleteCookiesFor.contains(registrableDomain) && m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain)));
@@ -70,7 +70,7 @@
bool NetworkStorageSession::shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(const RegistrableDomain& registrableDomain) const
{
- if (registrableDomain.isEmpty())
+ if (!m_isResourceLoadStatisticsEnabled || registrableDomain.isEmpty())
return false;
ASSERT(!(m_registrableDomainsToBlockAndDeleteCookiesFor.contains(registrableDomain) && m_registrableDomainsToBlockButKeepCookiesFor.contains(registrableDomain)));
@@ -88,11 +88,17 @@
bool NetworkStorageSession::shouldBlockCookies(const ResourceRequest& request, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID) const
{
+ if (!m_isResourceLoadStatisticsEnabled)
+ return false;
+
return shouldBlockCookies(request.firstPartyForCookies(), request.url(), frameID, pageID);
}
bool NetworkStorageSession::shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID) const
{
+ if (!m_isResourceLoadStatisticsEnabled)
+ return false;
+
RegistrableDomain firstPartyDomain { firstPartyForCookies };
if (firstPartyDomain.isEmpty())
return false;
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (252622 => 252623)
--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2019-11-19 06:30:46 UTC (rev 252623)
@@ -143,6 +143,7 @@
WEBCORE_EXPORT std::pair<String, bool> cookieRequestHeaderFieldValue(const CookieRequestHeaderFieldProxy&) const;
#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ void setResourceLoadStatisticsEnabled(bool enabled) { m_isResourceLoadStatisticsEnabled = enabled; }
WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&, Optional<FrameIdentifier>, Optional<PageIdentifier>) const;
WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, Optional<FrameIdentifier>, Optional<PageIdentifier>) const;
WEBCORE_EXPORT bool shouldBlockThirdPartyCookies(const RegistrableDomain&) const;
@@ -188,6 +189,7 @@
CredentialStorage m_credentialStorage;
#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ bool m_isResourceLoadStatisticsEnabled = false;
Optional<Seconds> clientSideCookieCap(const RegistrableDomain& firstParty, Optional<PageIdentifier>) const;
HashSet<RegistrableDomain> m_registrableDomainsToBlockAndDeleteCookiesFor;
HashSet<RegistrableDomain> m_registrableDomainsToBlockButKeepCookiesFor;
Modified: trunk/Source/WebKit/ChangeLog (252622 => 252623)
--- trunk/Source/WebKit/ChangeLog 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Source/WebKit/ChangeLog 2019-11-19 06:30:46 UTC (rev 252623)
@@ -1,3 +1,32 @@
+2019-11-18 John Wilander <[email protected]>
+
+ Check if ITP is on before applying third-party cookie blocking
+ https://bugs.webkit.org/show_bug.cgi?id=204322
+ <rdar://problem/57120772>
+
+ Reviewed by Chris Dumez and Alexey Proskuryakov.
+
+ This change makes sure WebCore::NetworkStorageSession knows
+ whether ITP is on or off and checks that first thing in
+ WebCore::NetworkStorageSession::shouldBlockCookies().
+
+ This check was never needed before since if ITP was off,
+ there would be no classified domains and thus the function
+ would always return false. However,
+ https://trac.webkit.org/changeset/251353/webkit introduced
+ full third-party cookie blocking for websites without user
+ interaction and that rule is checked before checking domain
+ classification. The effect was unconditional third-party
+ cookie blocking if ITP is off. This changes fixes that bug.
+
+ Note that this patch already landed as branch-specific in
+ https://trac.webkit.org/changeset/252549/webkit
+
+ * NetworkProcess/NetworkSession.cpp:
+ (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
+ Now tells WebCore::NetworkStorageSession the status of
+ ITP.
+
2019-11-18 David Kilzer <[email protected]>
IPC::Decoder should use nullptr as invalid value
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (252622 => 252623)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2019-11-19 06:30:46 UTC (rev 252623)
@@ -153,6 +153,8 @@
void NetworkSession::setResourceLoadStatisticsEnabled(bool enable)
{
ASSERT(!m_isInvalidated);
+ if (auto* storageSession = networkStorageSession())
+ storageSession->setResourceLoadStatisticsEnabled(enable);
if (!enable) {
destroyResourceLoadStatistics();
return;
Modified: trunk/Tools/ChangeLog (252622 => 252623)
--- trunk/Tools/ChangeLog 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Tools/ChangeLog 2019-11-19 06:30:46 UTC (rev 252623)
@@ -1,3 +1,25 @@
+2019-11-18 John Wilander <[email protected]>
+
+ Check if ITP is on before applying third-party cookie blocking
+ https://bugs.webkit.org/show_bug.cgi?id=204322
+ <rdar://problem/57120772>
+
+ Reviewed by Chris Dumez and Alexey Proskuryakov.
+
+ This is test infrastructure to allow a layout test to
+ disable ITP in the network process.
+
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::setStatisticsEnabled):
+ (WTR::TestRunner::setStatisticsDebugMode):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::setStatisticsEnabled):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
2019-11-18 Fujii Hironori <[email protected]>
[Win] kill-old-processes should kill WebKitWebProcess.exe and WebKitNetworkProcess.exe
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (252622 => 252623)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2019-11-19 06:30:46 UTC (rev 252623)
@@ -292,6 +292,7 @@
void disconnectMockGamepad(unsigned long index);
// Resource Load Statistics
+ void setStatisticsEnabled(boolean value);
void installStatisticsDidModifyDataRecordsCallback(object callback);
void installStatisticsDidScanDataRecordsCallback(object callback);
void installStatisticsDidRunTelemetryCallback(object callback);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (252622 => 252623)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2019-11-19 06:30:46 UTC (rev 252623)
@@ -1408,6 +1408,13 @@
callTestRunnerCallback(DidRemoveSwipeSnapshotCallbackID);
}
+void TestRunner::setStatisticsEnabled(bool value)
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsEnabled"));
+ WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value));
+ WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
void TestRunner::setStatisticsDebugMode(bool value, JSValueRef completionHandler)
{
cacheTestRunnerCallback(SetStatisticsDebugModeCallbackID, completionHandler);
@@ -1415,7 +1422,6 @@
WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsDebugMode"));
WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value));
WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
-
}
void TestRunner::statisticsCallDidSetDebugModeCallback()
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (252622 => 252623)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2019-11-19 06:30:46 UTC (rev 252623)
@@ -380,6 +380,7 @@
void setMockGamepadButtonValue(unsigned index, unsigned buttonIndex, double value);
// Resource Load Statistics
+ void setStatisticsEnabled(bool value);
void installStatisticsDidModifyDataRecordsCallback(JSValueRef callback);
void installStatisticsDidScanDataRecordsCallback(JSValueRef callback);
void installStatisticsDidRunTelemetryCallback(JSValueRef callback);
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (252622 => 252623)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2019-11-19 06:30:46 UTC (rev 252623)
@@ -3254,6 +3254,11 @@
context->testController.notifyDone();
}
+void TestController::setStatisticsEnabled(bool value)
+{
+ WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(TestController::websiteDataStore(), value);
+}
+
void TestController::setStatisticsDebugMode(bool value)
{
ResourceStatisticsCallbackContext context(*this);
Modified: trunk/Tools/WebKitTestRunner/TestController.h (252622 => 252623)
--- trunk/Tools/WebKitTestRunner/TestController.h 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2019-11-19 06:30:46 UTC (rev 252623)
@@ -207,6 +207,7 @@
void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; }
void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; }
+ void setStatisticsEnabled(bool value);
void setStatisticsDebugMode(bool value);
void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName);
void setStatisticsLastSeen(WKStringRef hostName, double seconds);
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (252622 => 252623)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2019-11-19 03:38:09 UTC (rev 252622)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2019-11-19 06:30:46 UTC (rev 252623)
@@ -1071,6 +1071,13 @@
return result;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsEnabled")) {
+ ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+ WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
+ TestController::singleton().setStatisticsEnabled(WKBooleanGetValue(value));
+ return nullptr;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsDebugMode")) {
ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);