Title: [240060] branches/safari-607-branch
Revision
240060
Author
[email protected]
Date
2019-01-16 15:27:06 -0800 (Wed, 16 Jan 2019)

Log Message

Cherry-pick r239832. rdar://problem/47260343

    Override the session configuration for cookieAcceptPolicy
    https://bugs.webkit.org/show_bug.cgi?id=190925
    <rdar://problem/45497382>

    Patch by John Wilander <[email protected]> on 2019-01-10
    Reviewed by Alexey Proskuryakov and Alex Christensen.

    Source/WebCore/PAL:

    * pal/spi/cf/CFNetworkSPI.h:
        Declaration of _overrideSessionCookieAcceptPolicy on NSHTTPCookieStorage.

    Source/WebKit:

    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
    (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
        Now sets cookieStorage._overrideSessionCookieAcceptPolicy to YES.

    Source/WTF:

    * wtf/Platform.h:
        Definition of HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY.

    Tools:

    Test infrastructure for setting a first-party-only cookie policy.

    * DumpRenderTree/TestRunner.cpp:
    (setOnlyAcceptFirstPartyCookiesCallback):
    (TestRunner::staticFunctions):
    * DumpRenderTree/TestRunner.h:
    * DumpRenderTree/mac/TestRunnerMac.mm:
    (TestRunner::setOnlyAcceptFirstPartyCookies):
    * DumpRenderTree/win/TestRunnerWin.cpp:
    (TestRunner::setOnlyAcceptFirstPartyCookies):
    * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
    * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
    (WTR::TestRunner::setOnlyAcceptFirstPartyCookies):
    * WebKitTestRunner/InjectedBundle/TestRunner.h:
    * WebKitTestRunner/TestInvocation.cpp:
    (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

    LayoutTests:

    * TestExpectations:
        Skipped since this cookie policy is only supported on Cocoa platforms.
    * http/tests/cookies/only-accept-first-party-cookies-expected.txt: Added.
    * http/tests/cookies/only-accept-first-party-cookies.html: Added.
    * http/tests/cookies/resources/reset-cookies.html: Added.
        To support reset of third-party cookies in an iframe.
    * http/tests/cookies/resources/set-cookie-and-redirect-back.php: Added.
        A simple bounce to set a cookie.
    * platform/ios/TestExpectations:
        Skipped for now. Will be fixed in <rdar://problem/47165939>.
    * platform/mac/TestExpectations:
        Skipped for now. Will be fixed in <rdar://problem/47165939>.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239832 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-607-branch/LayoutTests/ChangeLog (240059 => 240060)


--- branches/safari-607-branch/LayoutTests/ChangeLog	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/LayoutTests/ChangeLog	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1,5 +1,89 @@
 2019-01-15  Alan Coon  <[email protected]>
 
+        Cherry-pick r239832. rdar://problem/47260343
+
+    Override the session configuration for cookieAcceptPolicy
+    https://bugs.webkit.org/show_bug.cgi?id=190925
+    <rdar://problem/45497382>
+    
+    Patch by John Wilander <[email protected]> on 2019-01-10
+    Reviewed by Alexey Proskuryakov and Alex Christensen.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CFNetworkSPI.h:
+        Declaration of _overrideSessionCookieAcceptPolicy on NSHTTPCookieStorage.
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        Now sets cookieStorage._overrideSessionCookieAcceptPolicy to YES.
+    
+    Source/WTF:
+    
+    * wtf/Platform.h:
+        Definition of HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY.
+    
+    Tools:
+    
+    Test infrastructure for setting a first-party-only cookie policy.
+    
+    * DumpRenderTree/TestRunner.cpp:
+    (setOnlyAcceptFirstPartyCookiesCallback):
+    (TestRunner::staticFunctions):
+    * DumpRenderTree/TestRunner.h:
+    * DumpRenderTree/mac/TestRunnerMac.mm:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * DumpRenderTree/win/TestRunnerWin.cpp:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+    * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+    (WTR::TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/TestRunner.h:
+    * WebKitTestRunner/TestInvocation.cpp:
+    (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+    
+    LayoutTests:
+    
+    * TestExpectations:
+        Skipped since this cookie policy is only supported on Cocoa platforms.
+    * http/tests/cookies/only-accept-first-party-cookies-expected.txt: Added.
+    * http/tests/cookies/only-accept-first-party-cookies.html: Added.
+    * http/tests/cookies/resources/reset-cookies.html: Added.
+        To support reset of third-party cookies in an iframe.
+    * http/tests/cookies/resources/set-cookie-and-redirect-back.php: Added.
+        A simple bounce to set a cookie.
+    * platform/ios/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    * platform/mac/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-10  John Wilander  <[email protected]>
+
+            Override the session configuration for cookieAcceptPolicy
+            https://bugs.webkit.org/show_bug.cgi?id=190925
+            <rdar://problem/45497382>
+
+            Reviewed by Alexey Proskuryakov and Alex Christensen.
+
+            * TestExpectations:
+                Skipped since this cookie policy is only supported on Cocoa platforms.
+            * http/tests/cookies/only-accept-first-party-cookies-expected.txt: Added.
+            * http/tests/cookies/only-accept-first-party-cookies.html: Added.
+            * http/tests/cookies/resources/reset-cookies.html: Added.
+                To support reset of third-party cookies in an iframe.
+            * http/tests/cookies/resources/set-cookie-and-redirect-back.php: Added.
+                A simple bounce to set a cookie.
+            * platform/ios/TestExpectations:
+                Skipped for now. Will be fixed in <rdar://problem/47165939>.
+            * platform/mac/TestExpectations:
+                Skipped for now. Will be fixed in <rdar://problem/47165939>.
+
+2019-01-15  Alan Coon  <[email protected]>
+
         Cherry-pick r239786. rdar://problem/47260219
 
     [Datalist] Crash when input with datalist is dynamically added.

Modified: branches/safari-607-branch/LayoutTests/TestExpectations (240059 => 240060)


--- branches/safari-607-branch/LayoutTests/TestExpectations	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/LayoutTests/TestExpectations	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1972,6 +1972,9 @@
 webkit.org/b/3652 http/tests/misc/link-rel-prefetch-and-subresource.html [ Skip ]
 webkit.org/b/3652 http/tests/misc/prefetch-purpose.html [ Skip ]
 
+# First-party-only cookie policy only supported on Cocoa platforms.
+http/tests/cookies/only-accept-first-party-cookies.html [ Skip ]
+
 # Disabled WPT tests
 webkit.org/b/185939 imported/w3c/web-platform-tests/css/WOFF2 [ Skip ]
 

Added: branches/safari-607-branch/LayoutTests/http/tests/cookies/only-accept-first-party-cookies-expected.txt (0 => 240060)


--- branches/safari-607-branch/LayoutTests/http/tests/cookies/only-accept-first-party-cookies-expected.txt	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/cookies/only-accept-first-party-cookies-expected.txt	2019-01-16 23:27:06 UTC (rev 240060)
@@ -0,0 +1,29 @@
+Tests the first-party-only cookie policy.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Cookies are: test_cookie = 1
+
+--------
+Frame: '<!--frame2-->'
+--------
+Cookies are:
+
+--------
+Frame: '<!--frame3-->'
+--------
+Cookies are: test_cookie = 1
+
+--------
+Frame: '<!--frame4-->'
+--------
+

Added: branches/safari-607-branch/LayoutTests/http/tests/cookies/only-accept-first-party-cookies.html (0 => 240060)


--- branches/safari-607-branch/LayoutTests/http/tests/cookies/only-accept-first-party-cookies.html	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/cookies/only-accept-first-party-cookies.html	2019-01-16 23:27:06 UTC (rev 240060)
@@ -0,0 +1,73 @@
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests the first-party-only cookie policy.");
+        jsTestIsAsync = true;
+
+        const iframeUrls = {
+            echoCookies : "http://localhost:8000/cookies/resources/echo-cookies.php",
+            resetCookies : "http://localhost:8000/cookies/resources/reset-cookies.html"
+        };
+
+        function injectThirdPartyIframe(url) {
+            let iframeElement = document.createElement("iframe");
+            iframeElement.src = ""
+            iframeElement._onload_ = runNextTestOrFinish;
+            document.body.appendChild(iframeElement);
+        }
+
+        function setCookieInRedirect(hashValue) {
+            document.location.href = "" + hashValue;
+        }
+
+        function runNextTestOrFinish() {
+            if (!window.testRunner) {
+                testFailed("No testRunner.");
+                finishJSTest();
+            }
+
+            switch (document.location.hash) {
+                case "":
+                    testRunner.dumpChildFramesAsText();
+                    document.location.hash = "1";
+                    injectThirdPartyIframe(iframeUrls.resetCookies);
+                    break;
+                case "#1":
+                    setCookieInRedirect(2);
+                    break;
+                case "#2":
+                    document.location.hash = "3";
+                    // Should see one cookie.
+                    injectThirdPartyIframe(iframeUrls.echoCookies);
+                    break;
+                case "#3":
+                    document.location.hash = "4";
+                    testRunner.setOnlyAcceptFirstPartyCookies(true);
+                    // Should not see any cookies.
+                    injectThirdPartyIframe(iframeUrls.echoCookies);
+                    break;
+                case "#4":
+                    document.location.hash = "5";
+                    // Should see one cookie.
+                    testRunner.setOnlyAcceptFirstPartyCookies(false);
+                    injectThirdPartyIframe(iframeUrls.echoCookies);
+                    break;
+                case "#5":
+                    document.location.hash = "6";
+                    injectThirdPartyIframe(iframeUrls.resetCookies);
+                    break;
+                case "#6":
+                    finishJSTest();
+                    break;
+                default:
+                    testFailed("Unknown location hash value.");
+                    finishJSTest();
+            }
+        }
+    </script>
+</head>
+<body _onload_="runNextTestOrFinish()">
+</body>
+</html>

Added: branches/safari-607-branch/LayoutTests/http/tests/cookies/resources/reset-cookies.html (0 => 240060)


--- branches/safari-607-branch/LayoutTests/http/tests/cookies/resources/reset-cookies.html	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/cookies/resources/reset-cookies.html	2019-01-16 23:27:06 UTC (rev 240060)
@@ -0,0 +1,10 @@
+<html>
+<head>
+    <script src=""
+</head>
+<body>
+    <script>
+        resetCookies();
+    </script>
+</body>
+</html>

Added: branches/safari-607-branch/LayoutTests/http/tests/cookies/resources/set-cookie-and-redirect-back.php (0 => 240060)


--- branches/safari-607-branch/LayoutTests/http/tests/cookies/resources/set-cookie-and-redirect-back.php	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/cookies/resources/set-cookie-and-redirect-back.php	2019-01-16 23:27:06 UTC (rev 240060)
@@ -0,0 +1,10 @@
+<?php
+if ($_GET['redirectBackTo']) {
+  header("HTTP/1.0 302 Found");
+  setcookie("test_cookie", "1", time() + 86400);
+  header('Location: ' . $_GET['redirectBackTo']);
+} else {
+  header("HTTP/1.0 200 OK");
+  echo "FAILED: No redirectBackTo parameter found.\n";
+}
+?>

Modified: branches/safari-607-branch/LayoutTests/platform/ios/TestExpectations (240059 => 240060)


--- branches/safari-607-branch/LayoutTests/platform/ios/TestExpectations	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/LayoutTests/platform/ios/TestExpectations	2019-01-16 23:27:06 UTC (rev 240060)
@@ -3174,6 +3174,9 @@
 
 http/tests/cookies/same-site [ Pass ]
 
+# FIXME: Mark as Pass once <rdar://problem/47165939> is fixed.
+http/tests/cookies/only-accept-first-party-cookies.html [ Skip ]
+
 system-preview [ Pass ]
 
 editing/selection/character-granularity-rect.html [ Pass ]

Modified: branches/safari-607-branch/LayoutTests/platform/mac/TestExpectations (240059 => 240060)


--- branches/safari-607-branch/LayoutTests/platform/mac/TestExpectations	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/LayoutTests/platform/mac/TestExpectations	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1733,6 +1733,9 @@
 
 [ Mojave+ ] http/tests/cookies/same-site [ Pass ]
 
+# FIXME: Mark as Pass once <rdar://problem/47165939> is fixed.
+[ Mojave+ ] http/tests/cookies/only-accept-first-party-cookies.html [ Skip ]
+
 # FIXME: Mark as Pass once the fix for <rdar://problem/42255251> is shipped.
 [ Mojave+ ] http/tests/cookies/same-site/set-first-party-cross-site-cookies.php [ Skip ]
 [ Mojave+ ] http/tests/cookies/same-site/set-first-party-same-site-cookies.php [ Skip ]

Modified: branches/safari-607-branch/Source/WTF/ChangeLog (240059 => 240060)


--- branches/safari-607-branch/Source/WTF/ChangeLog	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Source/WTF/ChangeLog	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1,5 +1,79 @@
 2019-01-15  Alan Coon  <[email protected]>
 
+        Cherry-pick r239832. rdar://problem/47260343
+
+    Override the session configuration for cookieAcceptPolicy
+    https://bugs.webkit.org/show_bug.cgi?id=190925
+    <rdar://problem/45497382>
+    
+    Patch by John Wilander <[email protected]> on 2019-01-10
+    Reviewed by Alexey Proskuryakov and Alex Christensen.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CFNetworkSPI.h:
+        Declaration of _overrideSessionCookieAcceptPolicy on NSHTTPCookieStorage.
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        Now sets cookieStorage._overrideSessionCookieAcceptPolicy to YES.
+    
+    Source/WTF:
+    
+    * wtf/Platform.h:
+        Definition of HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY.
+    
+    Tools:
+    
+    Test infrastructure for setting a first-party-only cookie policy.
+    
+    * DumpRenderTree/TestRunner.cpp:
+    (setOnlyAcceptFirstPartyCookiesCallback):
+    (TestRunner::staticFunctions):
+    * DumpRenderTree/TestRunner.h:
+    * DumpRenderTree/mac/TestRunnerMac.mm:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * DumpRenderTree/win/TestRunnerWin.cpp:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+    * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+    (WTR::TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/TestRunner.h:
+    * WebKitTestRunner/TestInvocation.cpp:
+    (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+    
+    LayoutTests:
+    
+    * TestExpectations:
+        Skipped since this cookie policy is only supported on Cocoa platforms.
+    * http/tests/cookies/only-accept-first-party-cookies-expected.txt: Added.
+    * http/tests/cookies/only-accept-first-party-cookies.html: Added.
+    * http/tests/cookies/resources/reset-cookies.html: Added.
+        To support reset of third-party cookies in an iframe.
+    * http/tests/cookies/resources/set-cookie-and-redirect-back.php: Added.
+        A simple bounce to set a cookie.
+    * platform/ios/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    * platform/mac/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-10  John Wilander  <[email protected]>
+
+            Override the session configuration for cookieAcceptPolicy
+            https://bugs.webkit.org/show_bug.cgi?id=190925
+            <rdar://problem/45497382>
+
+            Reviewed by Alexey Proskuryakov and Alex Christensen.
+
+            * wtf/Platform.h:
+                Definition of HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY.
+
+2019-01-15  Alan Coon  <[email protected]>
+
         Cherry-pick r239787. rdar://problem/47260350
 
     Gigacage disabling checks should handle the GIGACAGE_ALLOCATION_CAN_FAIL case properly.

Modified: branches/safari-607-branch/Source/WTF/wtf/Platform.h (240059 => 240060)


--- branches/safari-607-branch/Source/WTF/wtf/Platform.h	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Source/WTF/wtf/Platform.h	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1466,3 +1466,7 @@
 #if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400)
 #define HAVE_AUTHORIZATION_STATUS_FOR_MEDIA_TYPE 1
 #endif
+
+#if (PLATFORM(MAC) && (__MAC_OS_X_VERSION_MIN_REQUIRED == 101200 || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101404))) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000 && __IPHONE_OS_VERSION_MAX_ALLOWED >= 120200) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 50000 && __WATCH_OS_VERSION_MAX_ALLOWED >= 50200) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 120000 && __TV_OS_VERSION_MAX_ALLOWED >= 120200)
+#define HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY 1
+#endif

Modified: branches/safari-607-branch/Source/WebCore/PAL/ChangeLog (240059 => 240060)


--- branches/safari-607-branch/Source/WebCore/PAL/ChangeLog	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Source/WebCore/PAL/ChangeLog	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1,3 +1,77 @@
+2019-01-15  Alan Coon  <[email protected]>
+
+        Cherry-pick r239832. rdar://problem/47260343
+
+    Override the session configuration for cookieAcceptPolicy
+    https://bugs.webkit.org/show_bug.cgi?id=190925
+    <rdar://problem/45497382>
+    
+    Patch by John Wilander <[email protected]> on 2019-01-10
+    Reviewed by Alexey Proskuryakov and Alex Christensen.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CFNetworkSPI.h:
+        Declaration of _overrideSessionCookieAcceptPolicy on NSHTTPCookieStorage.
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        Now sets cookieStorage._overrideSessionCookieAcceptPolicy to YES.
+    
+    Source/WTF:
+    
+    * wtf/Platform.h:
+        Definition of HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY.
+    
+    Tools:
+    
+    Test infrastructure for setting a first-party-only cookie policy.
+    
+    * DumpRenderTree/TestRunner.cpp:
+    (setOnlyAcceptFirstPartyCookiesCallback):
+    (TestRunner::staticFunctions):
+    * DumpRenderTree/TestRunner.h:
+    * DumpRenderTree/mac/TestRunnerMac.mm:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * DumpRenderTree/win/TestRunnerWin.cpp:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+    * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+    (WTR::TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/TestRunner.h:
+    * WebKitTestRunner/TestInvocation.cpp:
+    (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+    
+    LayoutTests:
+    
+    * TestExpectations:
+        Skipped since this cookie policy is only supported on Cocoa platforms.
+    * http/tests/cookies/only-accept-first-party-cookies-expected.txt: Added.
+    * http/tests/cookies/only-accept-first-party-cookies.html: Added.
+    * http/tests/cookies/resources/reset-cookies.html: Added.
+        To support reset of third-party cookies in an iframe.
+    * http/tests/cookies/resources/set-cookie-and-redirect-back.php: Added.
+        A simple bounce to set a cookie.
+    * platform/ios/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    * platform/mac/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-10  John Wilander  <[email protected]>
+
+            Override the session configuration for cookieAcceptPolicy
+            https://bugs.webkit.org/show_bug.cgi?id=190925
+            <rdar://problem/45497382>
+
+            Reviewed by Alexey Proskuryakov and Alex Christensen.
+
+            * pal/spi/cf/CFNetworkSPI.h:
+                Declaration of _overrideSessionCookieAcceptPolicy on NSHTTPCookieStorage.
+
 2019-01-04  Jer Noble  <[email protected]>
 
         Web Content process main thread blocked beneath ImageDecoderAVFObjC::readSamples for many seconds on imgur.com

Modified: branches/safari-607-branch/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (240059 => 240060)


--- branches/safari-607-branch/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2019-01-16 23:27:06 UTC (rev 240060)
@@ -126,6 +126,9 @@
 #if HAVE(FOUNDATION_WITH_SAVE_COOKIES_WITH_COMPLETION_HANDLER)
 - (void)_saveCookies:(dispatch_block_t) completionHandler;
 #endif
+#if HAVE(CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY)
+@property (nonatomic, readwrite) BOOL _overrideSessionCookieAcceptPolicy;
+#endif
 @end
 
 @interface NSURLConnection ()

Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (240059 => 240060)


--- branches/safari-607-branch/Source/WebKit/ChangeLog	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1,5 +1,80 @@
 2019-01-15  Alan Coon  <[email protected]>
 
+        Cherry-pick r239832. rdar://problem/47260343
+
+    Override the session configuration for cookieAcceptPolicy
+    https://bugs.webkit.org/show_bug.cgi?id=190925
+    <rdar://problem/45497382>
+    
+    Patch by John Wilander <[email protected]> on 2019-01-10
+    Reviewed by Alexey Proskuryakov and Alex Christensen.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CFNetworkSPI.h:
+        Declaration of _overrideSessionCookieAcceptPolicy on NSHTTPCookieStorage.
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        Now sets cookieStorage._overrideSessionCookieAcceptPolicy to YES.
+    
+    Source/WTF:
+    
+    * wtf/Platform.h:
+        Definition of HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY.
+    
+    Tools:
+    
+    Test infrastructure for setting a first-party-only cookie policy.
+    
+    * DumpRenderTree/TestRunner.cpp:
+    (setOnlyAcceptFirstPartyCookiesCallback):
+    (TestRunner::staticFunctions):
+    * DumpRenderTree/TestRunner.h:
+    * DumpRenderTree/mac/TestRunnerMac.mm:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * DumpRenderTree/win/TestRunnerWin.cpp:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+    * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+    (WTR::TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/TestRunner.h:
+    * WebKitTestRunner/TestInvocation.cpp:
+    (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+    
+    LayoutTests:
+    
+    * TestExpectations:
+        Skipped since this cookie policy is only supported on Cocoa platforms.
+    * http/tests/cookies/only-accept-first-party-cookies-expected.txt: Added.
+    * http/tests/cookies/only-accept-first-party-cookies.html: Added.
+    * http/tests/cookies/resources/reset-cookies.html: Added.
+        To support reset of third-party cookies in an iframe.
+    * http/tests/cookies/resources/set-cookie-and-redirect-back.php: Added.
+        A simple bounce to set a cookie.
+    * platform/ios/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    * platform/mac/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-10  John Wilander  <[email protected]>
+
+            Override the session configuration for cookieAcceptPolicy
+            https://bugs.webkit.org/show_bug.cgi?id=190925
+            <rdar://problem/45497382>
+
+            Reviewed by Alexey Proskuryakov and Alex Christensen.
+
+            * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+            (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+                Now sets cookieStorage._overrideSessionCookieAcceptPolicy to YES.
+
+2019-01-15  Alan Coon  <[email protected]>
+
         Apply patch. rdar://problem/47260255
 
     2019-01-15  Chris Dumez  <[email protected]>

Modified: branches/safari-607-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (240059 => 240060)


--- branches/safari-607-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2019-01-16 23:27:06 UTC (rev 240060)
@@ -696,9 +696,21 @@
 
     auto* storageSession = WebCore::NetworkStorageSession::storageSession(parameters.sessionID);
     RELEASE_ASSERT(storageSession);
-    if (CFHTTPCookieStorageRef storage = storageSession->cookieStorage().get())
-        configuration.HTTPCookieStorage = [[[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:storage] autorelease];
 
+    NSHTTPCookieStorage* cookieStorage;
+    if (CFHTTPCookieStorageRef storage = storageSession->cookieStorage().get()) {
+        cookieStorage = [[[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:storage] autorelease];
+        configuration.HTTPCookieStorage = cookieStorage;
+    } else
+        cookieStorage = storageSession->nsCookieStorage();
+
+#if HAVE(CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY)
+    // We still need to check the selector since CFNetwork updates and WebKit updates are separate
+    // on older macOS.
+    if ([cookieStorage respondsToSelector:@selector(_overrideSessionCookieAcceptPolicy)])
+        cookieStorage._overrideSessionCookieAcceptPolicy = YES;
+#endif
+
     m_sessionWithCredentialStorageDelegate = adoptNS([[WKNetworkSessionDelegate alloc] initWithNetworkSession:*this withCredentials:true]);
     m_sessionWithCredentialStorage = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_sessionWithCredentialStorageDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]];
     LOG(NetworkSession, "Created NetworkSession with cookieAcceptPolicy %lu", configuration.HTTPCookieStorage.cookieAcceptPolicy);

Modified: branches/safari-607-branch/Tools/ChangeLog (240059 => 240060)


--- branches/safari-607-branch/Tools/ChangeLog	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/ChangeLog	2019-01-16 23:27:06 UTC (rev 240060)
@@ -1,3 +1,91 @@
+2019-01-15  Alan Coon  <[email protected]>
+
+        Cherry-pick r239832. rdar://problem/47260343
+
+    Override the session configuration for cookieAcceptPolicy
+    https://bugs.webkit.org/show_bug.cgi?id=190925
+    <rdar://problem/45497382>
+    
+    Patch by John Wilander <[email protected]> on 2019-01-10
+    Reviewed by Alexey Proskuryakov and Alex Christensen.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CFNetworkSPI.h:
+        Declaration of _overrideSessionCookieAcceptPolicy on NSHTTPCookieStorage.
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        Now sets cookieStorage._overrideSessionCookieAcceptPolicy to YES.
+    
+    Source/WTF:
+    
+    * wtf/Platform.h:
+        Definition of HAVE_CFNETWORK_OVERRIDE_SESSION_COOKIE_ACCEPT_POLICY.
+    
+    Tools:
+    
+    Test infrastructure for setting a first-party-only cookie policy.
+    
+    * DumpRenderTree/TestRunner.cpp:
+    (setOnlyAcceptFirstPartyCookiesCallback):
+    (TestRunner::staticFunctions):
+    * DumpRenderTree/TestRunner.h:
+    * DumpRenderTree/mac/TestRunnerMac.mm:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * DumpRenderTree/win/TestRunnerWin.cpp:
+    (TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+    * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+    (WTR::TestRunner::setOnlyAcceptFirstPartyCookies):
+    * WebKitTestRunner/InjectedBundle/TestRunner.h:
+    * WebKitTestRunner/TestInvocation.cpp:
+    (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+    
+    LayoutTests:
+    
+    * TestExpectations:
+        Skipped since this cookie policy is only supported on Cocoa platforms.
+    * http/tests/cookies/only-accept-first-party-cookies-expected.txt: Added.
+    * http/tests/cookies/only-accept-first-party-cookies.html: Added.
+    * http/tests/cookies/resources/reset-cookies.html: Added.
+        To support reset of third-party cookies in an iframe.
+    * http/tests/cookies/resources/set-cookie-and-redirect-back.php: Added.
+        A simple bounce to set a cookie.
+    * platform/ios/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    * platform/mac/TestExpectations:
+        Skipped for now. Will be fixed in <rdar://problem/47165939>.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-10  John Wilander  <[email protected]>
+
+            Override the session configuration for cookieAcceptPolicy
+            https://bugs.webkit.org/show_bug.cgi?id=190925
+            <rdar://problem/45497382>
+
+            Reviewed by Alexey Proskuryakov and Alex Christensen.
+
+            Test infrastructure for setting a first-party-only cookie policy.
+
+            * DumpRenderTree/TestRunner.cpp:
+            (setOnlyAcceptFirstPartyCookiesCallback):
+            (TestRunner::staticFunctions):
+            * DumpRenderTree/TestRunner.h:
+            * DumpRenderTree/mac/TestRunnerMac.mm:
+            (TestRunner::setOnlyAcceptFirstPartyCookies):
+            * DumpRenderTree/win/TestRunnerWin.cpp:
+            (TestRunner::setOnlyAcceptFirstPartyCookies):
+            * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+            * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+            (WTR::TestRunner::setOnlyAcceptFirstPartyCookies):
+            * WebKitTestRunner/InjectedBundle/TestRunner.h:
+            * WebKitTestRunner/TestInvocation.cpp:
+            (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2019-01-14  Ryan Haddad  <[email protected]>
 
         Cherry-pick r239939. rdar://problem/47255372

Modified: branches/safari-607-branch/Tools/DumpRenderTree/TestRunner.cpp (240059 => 240060)


--- branches/safari-607-branch/Tools/DumpRenderTree/TestRunner.cpp	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/DumpRenderTree/TestRunner.cpp	2019-01-16 23:27:06 UTC (rev 240060)
@@ -810,6 +810,17 @@
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setOnlyAcceptFirstPartyCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
+    controller->setOnlyAcceptFirstPartyCookies(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac implementation
@@ -2195,6 +2206,7 @@
         { "setNeedsStorageAccessFromFileURLsQuirk", setNeedsStorageAccessFromFileURLsQuirkCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAllowsAnySSLCertificate", setAllowsAnySSLCertificateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setOnlyAcceptFirstPartyCookies", setOnlyAcceptFirstPartyCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAudioResult", setAudioResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },

Modified: branches/safari-607-branch/Tools/DumpRenderTree/TestRunner.h (240059 => 240060)


--- branches/safari-607-branch/Tools/DumpRenderTree/TestRunner.h	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/DumpRenderTree/TestRunner.h	2019-01-16 23:27:06 UTC (rev 240060)
@@ -272,7 +272,8 @@
 
     bool alwaysAcceptCookies() const { return m_alwaysAcceptCookies; }
     void setAlwaysAcceptCookies(bool);
-    
+    void setOnlyAcceptFirstPartyCookies(bool);
+
     bool rejectsProtectionSpaceAndContinueForAuthenticationChallenges() const { return m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges; }
     void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool value) { m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = value; }
     

Modified: branches/safari-607-branch/Tools/DumpRenderTree/mac/TestRunnerMac.mm (240059 => 240060)


--- branches/safari-607-branch/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2019-01-16 23:27:06 UTC (rev 240060)
@@ -72,6 +72,7 @@
 #import <WebKit/WebStorageManagerPrivate.h>
 #import <WebKit/WebView.h>
 #import <WebKit/WebViewPrivate.h>
+#import <pal/spi/cf/CFNetworkSPI.h>
 #import <wtf/HashMap.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/WallTime.h>
@@ -400,6 +401,15 @@
     [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:cookieAcceptPolicy];
 }
 
+void TestRunner::setOnlyAcceptFirstPartyCookies(bool onlyAcceptFirstPartyCookies)
+{
+    if (onlyAcceptFirstPartyCookies)
+        m_alwaysAcceptCookies = NO;
+
+    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = onlyAcceptFirstPartyCookies ? static_cast<NSHTTPCookieAcceptPolicy>(NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain) : NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+    [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:cookieAcceptPolicy];
+}
+
 void TestRunner::setAppCacheMaximumSize(unsigned long long size)
 {
     [WebApplicationCache setMaximumSize:size];

Modified: branches/safari-607-branch/Tools/DumpRenderTree/win/TestRunnerWin.cpp (240059 => 240060)


--- branches/safari-607-branch/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2019-01-16 23:27:06 UTC (rev 240060)
@@ -397,6 +397,12 @@
     m_alwaysAcceptCookies = alwaysAcceptCookies;
 }
 
+void TestRunner::setOnlyAcceptFirstPartyCookies(bool onlyAcceptFirstPartyCookies)
+{
+    // FIXME: Implement.
+    fprintf(testResult, "ERROR: TestRunner::setOnlyAcceptFirstPartyCookies() not implemented\n");
+}
+
 void TestRunner::setAppCacheMaximumSize(unsigned long long size)
 {
     COMPtr<IWebApplicationCache> applicationCache;

Modified: branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (240059 => 240060)


--- branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2019-01-16 23:27:06 UTC (rev 240060)
@@ -187,6 +187,7 @@
 
     // Cookies testing
     void setAlwaysAcceptCookies(boolean accept);
+    void setOnlyAcceptFirstPartyCookies(boolean accept);
 
     void overridePreference(DOMString preference, DOMString value);
 

Modified: branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (240059 => 240060)


--- branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2019-01-16 23:27:06 UTC (rev 240060)
@@ -926,6 +926,15 @@
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
 
+void TestRunner::setOnlyAcceptFirstPartyCookies(bool accept)
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetOnlyAcceptFirstPartyCookies"));
+    
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(accept));
+    
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
 double TestRunner::preciseTime()
 {
     return WallTime::now().secondsSinceEpoch().seconds();

Modified: branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (240059 => 240060)


--- branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2019-01-16 23:27:06 UTC (rev 240060)
@@ -294,6 +294,7 @@
 
     // Cookies testing
     void setAlwaysAcceptCookies(bool);
+    void setOnlyAcceptFirstPartyCookies(bool);
 
     // Custom full screen behavior.
     void setHasCustomFullScreenBehavior(bool value) { m_customFullScreenBehavior = value; }

Modified: branches/safari-607-branch/Tools/WebKitTestRunner/TestInvocation.cpp (240059 => 240060)


--- branches/safari-607-branch/Tools/WebKitTestRunner/TestInvocation.cpp	2019-01-16 23:26:58 UTC (rev 240059)
+++ branches/safari-607-branch/Tools/WebKitTestRunner/TestInvocation.cpp	2019-01-16 23:27:06 UTC (rev 240060)
@@ -874,6 +874,14 @@
         return nullptr;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "SetOnlyAcceptFirstPartyCookies")) {
+        WKBooleanRef accept = static_cast<WKBooleanRef>(messageBody);
+        WKHTTPCookieAcceptPolicy policy = WKBooleanGetValue(accept) ? kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain : kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+        // FIXME: This updates the policy in WebProcess and in NetworkProcess asynchronously, which might break some tests' expectations.
+        WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), policy);
+        return nullptr;
+    }
+    
     if (WKStringIsEqualToUTF8CString(messageName, "SetCustomUserAgent")) {
         WKStringRef userAgent = static_cast<WKStringRef>(messageBody);
         WKPageSetCustomUserAgent(TestController::singleton().mainWebView()->page(), userAgent);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to