Title: [234629] trunk/LayoutTests
Revision
234629
Author
[email protected]
Date
2018-08-06 15:21:25 -0700 (Mon, 06 Aug 2018)

Log Message

Add tests to ensure that Same-Site cookies are stored when set as the first party
https://bugs.webkit.org/show_bug.cgi?id=188080

Reviewed by Alexey Proskuryakov.

* http/tests/cookies/resources/cookie-utilities.js:
(getDOMCookies): Return an empty dictionary when there are no DOM cookies. Currently we
return {"": undefined}.
* http/tests/cookies/resources/cookie-utilities.php: Added.
* http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php: Added.
* http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt: Added.
* http/tests/cookies/same-site/set-first-party-cross-site-cookies.php: Added.
* http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt: Added.
* http/tests/cookies/same-site/set-first-party-same-site-cookies.php: Added.
* platform/ios-12/TestExpectations: Skip the tests until the fix for <rdar://problem/42255251>
is shipped.
* platform/mac/TestExpectations: Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234628 => 234629)


--- trunk/LayoutTests/ChangeLog	2018-08-06 22:16:30 UTC (rev 234628)
+++ trunk/LayoutTests/ChangeLog	2018-08-06 22:21:25 UTC (rev 234629)
@@ -1,3 +1,23 @@
+2018-08-06  Daniel Bates  <[email protected]>
+
+        Add tests to ensure that Same-Site cookies are stored when set as the first party
+        https://bugs.webkit.org/show_bug.cgi?id=188080
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/cookies/resources/cookie-utilities.js:
+        (getDOMCookies): Return an empty dictionary when there are no DOM cookies. Currently we
+        return {"": undefined}.
+        * http/tests/cookies/resources/cookie-utilities.php: Added.
+        * http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php: Added.
+        * http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt: Added.
+        * http/tests/cookies/same-site/set-first-party-cross-site-cookies.php: Added.
+        * http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt: Added.
+        * http/tests/cookies/same-site/set-first-party-same-site-cookies.php: Added.
+        * platform/ios-12/TestExpectations: Skip the tests until the fix for <rdar://problem/42255251>
+        is shipped.
+        * platform/mac/TestExpectations: Ditto.
+
 2018-08-06  Ryosuke Niwa  <[email protected]>
 
         fast/custom-elements/custom-element-registry-wrapper-should-stay-alive.html always timeouts on debug bots

Modified: trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.js (234628 => 234629)


--- trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.js	2018-08-06 22:16:30 UTC (rev 234628)
+++ trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.js	2018-08-06 22:21:25 UTC (rev 234629)
@@ -32,6 +32,8 @@
 {
     if (!g_baseDocumentWhenFetchingDOMCookies)
         g_baseDocumentWhenFetchingDOMCookies = document;
+    if (!g_baseDocumentWhenFetchingDOMCookies.cookie)
+        return {};
     let cookies = g_baseDocumentWhenFetchingDOMCookies.cookie.split("; ");
     let result = {};
     for (let keyAndValuePair of cookies) {

Added: trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.php (0 => 234629)


--- trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.php	2018-08-06 22:21:25 UTC (rev 234629)
@@ -0,0 +1,53 @@
+<?php
+function startsWith($string, $substring)
+{
+    return substr($string, 0, strlen($substring)) === $substring;
+}
+
+function hostnameIsEqualToString($hostname)
+{
+    return startsWith($_SERVER["HTTP_HOST"], $hostname);
+}
+
+function resetCookies()
+{
+    if (hostnameIsEqualToString("127.0.0.1")) {
+        resetCookiesForCurrentOrigin();
+        header("Location: http://localhost:8000" . $_SERVER["PHP_SELF"]);
+    } elseif (hostnameIsEqualToString("localhost")) {
+        resetCookiesForCurrentOrigin();
+        header("Location: http://127.0.0.1:8000" . $_SERVER["PHP_SELF"] . "?runTest");
+    }
+}
+
+function shouldResetCookies()
+{
+    return empty($_SERVER["QUERY_STRING"]);
+}
+
+function wkSetCookie($name, $value, $additionalProperties)
+{
+    $cookieValue = $name . "=" . $value;
+    foreach ($additionalProperties as $name => $value) {
+        $cookieValue .= "; " . $name;
+        if (isset($value))
+            $cookieValue .= "=" . $value;
+    }
+    header("Set-Cookie: " . $cookieValue, FALSE /* replace */);
+}
+
+function deleteCookie($name)
+{
+    setcookie($name, "deleted", time() - 86400, "/");
+}
+
+function _deleteCookieCallback($value, $name)
+{
+    deleteCookie($name);
+}
+
+function resetCookiesForCurrentOrigin()
+{
+    array_walk($_COOKIE, _deleteCookieCallback);
+}
+?>

Added: trunk/LayoutTests/http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php (0 => 234629)


--- trunk/LayoutTests/http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php	2018-08-06 22:21:25 UTC (rev 234629)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function logDOMCookie(name, value)
+{
+    document.getElementById("dom-cookies-output").appendChild(document.createTextNode(`${name} = ${value}\n`));
+}
+
+window._onload_ = () => {
+    let domCookies = getDOMCookies();
+    for (let name of Object.keys(domCookies).sort())
+        logDOMCookie(name, domCookies[name]);
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+};
+</script>
+</head>
+<body>
+<p>HTTP sent cookies:</p>
+<pre>
+<?php
+$sortedCookieNames = array_keys($_COOKIE);
+sort($sortedCookieNames);
+
+foreach ($sortedCookieNames as $name)
+    echo "$name = $_COOKIE[$name]\n";
+?>
+</pre>
+<p>DOM cookies:</p>
+<pre id="dom-cookies-output"></pre>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt (0 => 234629)


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt	2018-08-06 22:21:25 UTC (rev 234629)
@@ -0,0 +1,15 @@
+HTTP sent cookies:
+
+implicit-strict = 14
+lax = 14
+normal = 14
+strict = 14
+strict-because-invalid-SameSite-value = 14
+DOM cookies:
+
+implicit-strict = 14
+lax = 14
+normal = 14
+strict = 14
+strict-because-invalid-SameSite-value = 14
+

Added: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php (0 => 234629)


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php	2018-08-06 22:21:25 UTC (rev 234629)
@@ -0,0 +1,30 @@
+<?php
+    include_once("../resources/cookie-utilities.php");
+
+    if (shouldResetCookies()) {
+        resetCookies();
+        exit(0);
+    }
+    if (hostnameIsEqualToString("127.0.0.1")) {
+        header("Location: http://localhost:8000" . $_SERVER["REQUEST_URI"]);
+        exit(0);
+    }
+    wkSetCookie("strict", "14", Array("SameSite" => "Strict", "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("implicit-strict", "14", Array("SameSite" => NULL, "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("strict-because-invalid-SameSite-value", "14", Array("SameSite" => "invalid", "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("lax", "14", Array("SameSite" => "Lax", "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("normal", "14", Array("Max-Age" => 100, "path" => "/"));
+
+?>
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+</script>
+<meta http-equiv="refresh" content="0;http://localhost:8000/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php">
+</head>
+</html>

Added: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt (0 => 234629)


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt	2018-08-06 22:21:25 UTC (rev 234629)
@@ -0,0 +1,15 @@
+HTTP sent cookies:
+
+implicit-strict = 14
+lax = 14
+normal = 14
+strict = 14
+strict-because-invalid-SameSite-value = 14
+DOM cookies:
+
+implicit-strict = 14
+lax = 14
+normal = 14
+strict = 14
+strict-because-invalid-SameSite-value = 14
+

Added: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php (0 => 234629)


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php	2018-08-06 22:21:25 UTC (rev 234629)
@@ -0,0 +1,27 @@
+<?php
+    include_once("../resources/cookie-utilities.php");
+
+    if (shouldResetCookies()) {
+        resetCookies();
+        exit(0);
+    }
+
+    wkSetCookie("strict", "14", Array("SameSite" => "Strict", "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("implicit-strict", "14", Array("SameSite" => NULL, "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("strict-because-invalid-SameSite-value", "14", Array("SameSite" => "invalid", "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("lax", "14", Array("SameSite" => "Lax", "Max-Age" => 100, "path" => "/"));
+    wkSetCookie("normal", "14", Array("Max-Age" => 100, "path" => "/"));
+
+?>
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+</script>
+<meta http-equiv="refresh" content="0;http://127.0.0.1:8000/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php">
+</head>
+</html>

Modified: trunk/LayoutTests/platform/ios-12/TestExpectations (234628 => 234629)


--- trunk/LayoutTests/platform/ios-12/TestExpectations	2018-08-06 22:16:30 UTC (rev 234628)
+++ trunk/LayoutTests/platform/ios-12/TestExpectations	2018-08-06 22:21:25 UTC (rev 234629)
@@ -1,4 +1,9 @@
 http/tests/cookies/same-site [ Pass ]
+
+# FIXME: Mark as Pass once the fix for <rdar://problem/42255251> is shipped.
+http/tests/cookies/same-site/set-first-party-cross-site-cookies.php [ Skip ]
+http/tests/cookies/same-site/set-first-party-same-site-cookies.php [ Skip ]
+
 system-preview [ Pass ]
 editing/selection/character-granularity-rect.html [ Pass ]
 

Modified: trunk/LayoutTests/platform/mac/TestExpectations (234628 => 234629)


--- trunk/LayoutTests/platform/mac/TestExpectations	2018-08-06 22:16:30 UTC (rev 234628)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2018-08-06 22:21:25 UTC (rev 234629)
@@ -1792,6 +1792,10 @@
 
 [ Mojave+ ] http/tests/cookies/same-site [ Pass ]
 
+# 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 ]
+
 # <rdar://problem/36639117> REGRESSION (Mojave): LayoutTest svg/custom/subpaths-moveto-only-rendering.svg is failing
 [ Mojave+ ] svg/custom/subpaths-moveto-only-rendering.svg [ Failure ]
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to