Title: [252612] branches/safari-608-branch

Diff

Modified: branches/safari-608-branch/LayoutTests/ChangeLog (252611 => 252612)


--- branches/safari-608-branch/LayoutTests/ChangeLog	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/LayoutTests/ChangeLog	2019-11-19 01:12:50 UTC (rev 252612)
@@ -1,5 +1,20 @@
 2019-11-18  Alan Coon  <[email protected]>
 
+        Apply patch. rdar://problem/57257755
+
+    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=204109
+            <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  Alan Coon  <[email protected]>
+
         Cherry-pick r251680. rdar://problem/57283563
 
     Hidden framesets should provide default edgeInfo value

Added: branches/safari-608-branch/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt (0 => 252612)


--- branches/safari-608-branch/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off-expected.txt	2019-11-19 01:12:50 UTC (rev 252612)
@@ -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: branches/safari-608-branch/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html (0 => 252612)


--- branches/safari-608-branch/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html	2019-11-19 01:12:50 UTC (rev 252612)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <script src=""
+    <script src=""
+</head>
+<body>
+<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");
+        element.src = ""
+        if (onLoadHandler) {
+            element._onload_ = onLoadHandler;
+        }
+        document.body.appendChild(element);
+    }
+
+    function runTest() {
+        switch (document.location.hash) {
+            case "#step1":
+                // Set first-party cookie for localhost.
+                document.location.href = "" + subPathToSetFirstPartyCookie + "#" + returnUrl + "#step2";
+                break;
+            case "#step2":
+                document.location.hash = "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.setStatisticsShouldBlockThirdPartyCookies(false, function() {
+                        testRunner.setStatisticsEnabled(true);
+                        finishJSTest();
+                    });
+                });
+                break;
+        }
+    }
+
+    if (document.location.hash === "") {
+        setEnableFeature(false, function () {
+            testRunner.setStatisticsEnabled(false);
+            testRunner.dumpChildFramesAsText();
+            // Enable the flag even though ITP is off.
+            testRunner.setStatisticsShouldBlockThirdPartyCookies(true, runTest);
+            document.location.hash = "step1";
+            runTest();
+        });
+    } else {
+        runTest();
+    }
+</script>
+</body>
+</html>

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (252611 => 252612)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-11-19 01:12:50 UTC (rev 252612)
@@ -1,5 +1,42 @@
 2019-11-18  Alan Coon  <[email protected]>
 
+        Apply patch. rdar://problem/57257755
+
+    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=204109
+            <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 is branch-specific and expected to not
+            apply to trunk.
+
+            Test: http/tests/resourceLoadStatistics/no-third-party-cookie-blocking-when-itp-is-off.html
+
+            * platform/network/NetworkStorageSession.cpp:
+            (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookies const):
+            (WebCore::NetworkStorageSession::shouldBlockCookies const):
+                Now checks whether ITP is on or off.
+            * platform/network/NetworkStorageSession.h:
+            (WebCore::NetworkStorageSession::setResourceLoadStatisticsEnabled):
+
+2019-11-18  Alan Coon  <[email protected]>
+
         Cherry-pick r251680. rdar://problem/57283563
 
     Hidden framesets should provide default edgeInfo value

Modified: branches/safari-608-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp (252611 => 252612)


--- branches/safari-608-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp	2019-11-19 01:12:50 UTC (rev 252612)
@@ -60,7 +60,7 @@
 
 bool NetworkStorageSession::shouldBlockThirdPartyCookies(const RegistrableDomain& registrableDomain) const
 {
-    if (registrableDomain.isEmpty())
+    if (!m_isResourceLoadStatisticsEnabled || registrableDomain.isEmpty())
         return false;
 
     return m_registrableDomainsToBlockCookieFor.contains(registrableDomain);
@@ -76,11 +76,17 @@
 
 bool NetworkStorageSession::shouldBlockCookies(const ResourceRequest& request, Optional<uint64_t> 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<uint64_t> frameID, Optional<PageIdentifier> pageID) const
 {
+    if (!m_isResourceLoadStatisticsEnabled)
+        return false;
+
     RegistrableDomain firstPartyDomain { firstPartyForCookies };
     if (firstPartyDomain.isEmpty())
         return false;

Modified: branches/safari-608-branch/Source/WebCore/platform/network/NetworkStorageSession.h (252611 => 252612)


--- branches/safari-608-branch/Source/WebCore/platform/network/NetworkStorageSession.h	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Source/WebCore/platform/network/NetworkStorageSession.h	2019-11-19 01:12:50 UTC (rev 252612)
@@ -165,6 +165,7 @@
     WEBCORE_EXPORT void didCommitCrossSiteLoadWithDataTransferFromPrevalentResource(const RegistrableDomain& toDomain, PageIdentifier);
     WEBCORE_EXPORT void resetCrossSiteLoadsWithLinkDecorationForTesting();
     void setIsThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled(bool enabled) { m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled = enabled; }
+    void setResourceLoadStatisticsEnabled(bool enabled) { m_isResourceLoadStatisticsEnabled = enabled; }
 #endif
 
 private:
@@ -199,6 +200,7 @@
     HashMap<WebCore::PageIdentifier, RegistrableDomain> m_navigatedToWithLinkDecorationByPrevalentResource;
     bool m_navigationWithLinkDecorationTestMode = false;
     bool m_isThirdPartyCookieBlockingOnSitesWithoutUserInteractionEnabled = true;
+    bool m_isResourceLoadStatisticsEnabled = false;
 #endif
 
 #if PLATFORM(COCOA)

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (252611 => 252612)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-11-19 01:12:50 UTC (rev 252612)
@@ -1,5 +1,38 @@
 2019-11-18  Alan Coon  <[email protected]>
 
+        Apply patch. rdar://problem/57257755
+
+    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=204109
+            <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 is branch-specific and expected to not
+            apply to trunk.
+
+            * NetworkProcess/NetworkSession.cpp:
+            (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
+                Now tells WebCore::NetworkStorageSession the status of
+                ITP.
+
+2019-11-18  Alan Coon  <[email protected]>
+
         Apply patch. rdar://problem/57123571
 
     2019-11-18  Chris Dumez  <[email protected]>

Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkSession.cpp (252611 => 252612)


--- branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkSession.cpp	2019-11-19 01:12:50 UTC (rev 252612)
@@ -130,6 +130,8 @@
 void NetworkSession::setResourceLoadStatisticsEnabled(bool enable)
 {
     ASSERT(!m_isInvalidated);
+    if (auto* storageSession = networkStorageSession())
+        storageSession->setResourceLoadStatisticsEnabled(enable);
     if (!enable) {
         destroyResourceLoadStatistics();
         return;

Modified: branches/safari-608-branch/Tools/ChangeLog (252611 => 252612)


--- branches/safari-608-branch/Tools/ChangeLog	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Tools/ChangeLog	2019-11-19 01:12:50 UTC (rev 252612)
@@ -1,3 +1,29 @@
+2019-11-18  Alan Coon  <[email protected]>
+
+        Apply patch. rdar://problem/57257755
+
+    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=204109
+            <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-15  Alan Coon  <[email protected]>
 
         Cherry-pick r252248. rdar://problem/57058392

Modified: branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (252611 => 252612)


--- branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2019-11-19 01:12:50 UTC (rev 252612)
@@ -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: branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (252611 => 252612)


--- branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2019-11-19 01:12:50 UTC (rev 252612)
@@ -1377,6 +1377,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);
@@ -1384,7 +1391,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: branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (252611 => 252612)


--- branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2019-11-19 01:12:50 UTC (rev 252612)
@@ -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: branches/safari-608-branch/Tools/WebKitTestRunner/TestController.cpp (252611 => 252612)


--- branches/safari-608-branch/Tools/WebKitTestRunner/TestController.cpp	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/TestController.cpp	2019-11-19 01:12:50 UTC (rev 252612)
@@ -3210,6 +3210,12 @@
     context->testController.notifyDone();
 }
 
+void TestController::setStatisticsEnabled(bool value)
+{
+    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+    WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(dataStore, value);
+}
+
 void TestController::setStatisticsDebugMode(bool value)
 {
     auto* dataStore = WKContextGetWebsiteDataStore(platformContext());

Modified: branches/safari-608-branch/Tools/WebKitTestRunner/TestController.h (252611 => 252612)


--- branches/safari-608-branch/Tools/WebKitTestRunner/TestController.h	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/TestController.h	2019-11-19 01:12:50 UTC (rev 252612)
@@ -204,6 +204,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: branches/safari-608-branch/Tools/WebKitTestRunner/TestInvocation.cpp (252611 => 252612)


--- branches/safari-608-branch/Tools/WebKitTestRunner/TestInvocation.cpp	2019-11-19 01:12:45 UTC (rev 252611)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/TestInvocation.cpp	2019-11-19 01:12:50 UTC (rev 252612)
@@ -1061,6 +1061,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);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to