WebKit Bugzilla
Attachment 345884 Details for
Bug 188080
: Add tests to ensure that Same-Site cookies are stored when set as the first party
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Layout tests
bug-188080-20180726154752.patch (text/plain), 10.61 KB, created by
Daniel Bates
on 2018-07-26 15:47:53 PDT
(
hide
)
Description:
Layout tests
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-07-26 15:47:53 PDT
Size:
10.61 KB
patch
obsolete
>Subversion Revision: 234197 >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 7cfd5dc1aad14adf8bd8fafd70f03f7478ff9be2..d3c2db8e702a34e80763b2b5e3bfe810a4af974c 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,23 @@ >+2018-07-26 Daniel Bates <dabates@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * 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-07-25 Ms2ger <Ms2ger@igalia.com> > > [GTK][WPE] Unreviewed test gardening >diff --git a/LayoutTests/http/tests/cookies/resources/cookie-utilities.js b/LayoutTests/http/tests/cookies/resources/cookie-utilities.js >index 0b8fb34eb09afcb07648f48715d295cc13568a5c..07c0c03b70a294ec764a7bc23c50264d8e6cc8cb 100644 >--- a/LayoutTests/http/tests/cookies/resources/cookie-utilities.js >+++ b/LayoutTests/http/tests/cookies/resources/cookie-utilities.js >@@ -32,6 +32,8 @@ function getDOMCookies() > { > if (!g_baseDocumentWhenFetchingDOMCookies) > g_baseDocumentWhenFetchingDOMCookies = document; >+ if (!g_baseDocumentWhenFetchingDOMCookies.cookie) >+ return {}; > let cookies = g_baseDocumentWhenFetchingDOMCookies.cookie.split("; "); > let result = {}; > for (let keyAndValuePair of cookies) { >diff --git a/LayoutTests/http/tests/cookies/resources/cookie-utilities.php b/LayoutTests/http/tests/cookies/resources/cookie-utilities.php >new file mode 100644 >index 0000000000000000000000000000000000000000..4a2595ea2a5ec3124eafcd2b8e479032661ea491 >--- /dev/null >+++ b/LayoutTests/http/tests/cookies/resources/cookie-utilities.php >@@ -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); >+} >+?> >diff --git a/LayoutTests/http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php b/LayoutTests/http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php >new file mode 100644 >index 0000000000000000000000000000000000000000..e144052973e41e4b2e3b5e688901dec122ef416a >--- /dev/null >+++ b/LayoutTests/http/tests/cookies/resources/echo-http-and-dom-cookies-and-notify-done.php >@@ -0,0 +1,35 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="cookie-utilities.js"></script> >+<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> >diff --git a/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt b/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a806257c827af52fa4268e81e1d44fd82b2098c0 >--- /dev/null >+++ b/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies-expected.txt >@@ -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 >+ >diff --git a/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php b/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php >new file mode 100644 >index 0000000000000000000000000000000000000000..cce9e5a32fa1099c361b42285cfcee9d77a5984d >--- /dev/null >+++ b/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php >@@ -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> >diff --git a/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt b/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a806257c827af52fa4268e81e1d44fd82b2098c0 >--- /dev/null >+++ b/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies-expected.txt >@@ -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 >+ >diff --git a/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php b/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php >new file mode 100644 >index 0000000000000000000000000000000000000000..6d582d457f9890f003d6445caa3eea00bce3fe2a >--- /dev/null >+++ b/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php >@@ -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> >diff --git a/LayoutTests/platform/ios-12/TestExpectations b/LayoutTests/platform/ios-12/TestExpectations >index e9fd61d6a984f845d07be6e58e931e3632d336f5..0d2042c723ea251f4e6c617deec502984d7b1363 100644 >--- a/LayoutTests/platform/ios-12/TestExpectations >+++ b/LayoutTests/platform/ios-12/TestExpectations >@@ -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 ] > >diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations >index 038bed1fee6a10f43eeabb32ad77ba488319047f..e7592c98e73dab42d38f4c4be6abbb0394965498 100644 >--- a/LayoutTests/platform/mac/TestExpectations >+++ b/LayoutTests/platform/mac/TestExpectations >@@ -1792,6 +1792,10 @@ webkit.org/b/187393 imported/w3c/web-platform-tests/2dcontext/imagebitmap/create > > [ 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/39118706> REGRESSION (Mojave): LayoutTest fast/css/test-setting-canvas-color.html is failing > [ Mojave+ ] fast/css/test-setting-canvas-color.html [ Failure ] >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ap
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188080
: 345884