Title: [275762] trunk/LayoutTests
Revision
275762
Author
cgambr...@apple.com
Date
2021-04-09 08:02:25 -0700 (Fri, 09 Apr 2021)

Log Message

[LayoutTests] Convert http/tests/cookies convert PHP to Python
https://bugs.webkit.org/show_bug.cgi?id=223891
<rdar://problem/75965634>

Reviewed by Jonathan Bedard.

* http/tests/cookies/multiple-redirect-and-set-cookie.php: Removed.
* http/tests/cookies/multiple-redirect-and-set-cookie.py: Added.
(redirect_url):
(redirect_to_step):
(step0):
(step2):
* http/tests/cookies/resources/cookie-utilities.php: Removed.
* http/tests/cookies/resources/cookie_utilities.py: Added.
(hostname_is_equal_to_string):
(reset_cookies_for_current_origin):
(reset_cookies):
(should_reset_cookies):
(wk_set_cookie):
* http/tests/cookies/same-site/set-first-party-cross-site-cookies.php: Removed.
* http/tests/cookies/same-site/set-first-party-cross-site-cookies.py: Added.
* http/tests/cookies/same-site/set-first-party-same-site-cookies.php: Removed.
* http/tests/cookies/same-site/set-first-party-same-site-cookies.py: Added.
* http/tests/cookies/same-site/user-load-cross-site-redirect.php: Removed.
* http/tests/cookies/same-site/user-load-cross-site-redirect.py: Added.
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/wpe/TestExpectations:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (275761 => 275762)


--- trunk/LayoutTests/ChangeLog	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/ChangeLog	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1,3 +1,34 @@
+2021-04-09  Chris Gambrell  <cgambr...@apple.com>
+
+        [LayoutTests] Convert http/tests/cookies convert PHP to Python
+        https://bugs.webkit.org/show_bug.cgi?id=223891
+        <rdar://problem/75965634>
+
+        Reviewed by Jonathan Bedard.
+
+        * http/tests/cookies/multiple-redirect-and-set-cookie.php: Removed.
+        * http/tests/cookies/multiple-redirect-and-set-cookie.py: Added.
+        (redirect_url):
+        (redirect_to_step):
+        (step0):
+        (step2):
+        * http/tests/cookies/resources/cookie-utilities.php: Removed.
+        * http/tests/cookies/resources/cookie_utilities.py: Added.
+        (hostname_is_equal_to_string):
+        (reset_cookies_for_current_origin):
+        (reset_cookies):
+        (should_reset_cookies):
+        (wk_set_cookie):
+        * http/tests/cookies/same-site/set-first-party-cross-site-cookies.php: Removed.
+        * http/tests/cookies/same-site/set-first-party-cross-site-cookies.py: Added.
+        * http/tests/cookies/same-site/set-first-party-same-site-cookies.php: Removed.
+        * http/tests/cookies/same-site/set-first-party-same-site-cookies.py: Added.
+        * http/tests/cookies/same-site/user-load-cross-site-redirect.php: Removed.
+        * http/tests/cookies/same-site/user-load-cross-site-redirect.py: Added.
+        * platform/gtk/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/wpe/TestExpectations:
+
 2021-04-09  Philippe Normand  <pnorm...@igalia.com>
 
         [GStreamer] fast/canvas/canvas-createPattern-video-loading.html is failing since r218170

Deleted: trunk/LayoutTests/http/tests/cookies/multiple-redirect-and-set-cookie.php (275761 => 275762)


--- trunk/LayoutTests/http/tests/cookies/multiple-redirect-and-set-cookie.php	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/http/tests/cookies/multiple-redirect-and-set-cookie.php	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1,72 +0,0 @@
-<?php
-
-$expire = time() + 30;
-$step = empty($_GET['step']) ? '' : $_GET['step'];
-$cookie_name = empty($_GET['cookie_name']) ? md5(__FILE__ . time()) : $_GET['cookie_name'];
-
-if (!$step) {
-    // Step 0: Set cookie for following request.
-    setcookie($cookie_name, 'not sure, but something', $expire);
-    step0();
-} elseif ($step == 1) {
-    // Step 1: Request caused by JS. It is sent with Cookie header with value of step 0.
-    setcookie($cookie_name, '42', $expire);
-    redirect_to_step(2);
-} elseif ($step == 2) {
-    // Step 2: Redirected request should have only Cookie header with update value/
-    step2($_COOKIE[$cookie_name]);
-} else {
-    die("Error: unknown step: {$step}");
-}
-
-exit(0);
-
-function redirect_to_step($step) {
-    header("HTTP/1.0 302 Found");
-    header('Location: ' . redirect_url($step));
-}
-
-function redirect_url($step) {
-    global $cookie_name;
-    return "http://127.0.0.1:8000/cookies/" . basename(__FILE__) . "?step={$step}&cookie_name={$cookie_name}";
-}
-
-function step0() {
-?>
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<script>
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-}
-
-function gotoStep1() {
-    window.location = "<?php echo redirect_url(1); ?>";
-}
-</script>
-
-<body _onload_="gotoStep1()">
-</body>
-</html>
-<?php
-}
-
-function step2($result) {
-?>
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<script>
-function finish() {
-    if (window.testRunner)
-        testRunner.notifyDone();
-}
-</script>
-
-<body _onload_="finish()">
-Cookie: <?php echo $result; ?>
-</body>
-</html>
-<?php
-}
-?>

Added: trunk/LayoutTests/http/tests/cookies/multiple-redirect-and-set-cookie.py (0 => 275762)


--- trunk/LayoutTests/http/tests/cookies/multiple-redirect-and-set-cookie.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/multiple-redirect-and-set-cookie.py	2021-04-09 15:02:25 UTC (rev 275762)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python3
+
+import hashlib
+import os
+import sys
+from datetime import datetime, timedelta
+from urllib.parse import parse_qs
+
+file = __file__.split(':/cygwin')[-1]
+http_root = os.path.dirname(os.path.abspath(os.path.dirname(file)))
+sys.path.insert(0, http_root)
+
+from resources.portabilityLayer import get_cookies
+
+current_time = datetime.utcnow()
+expires = current_time + timedelta(seconds=1)
+
+query = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True)
+cookie_name = query.get('cookie_name', [hashlib.md5(bytes('{}{}'.format(__file__, current_time), 'utf-8')).hexdigest()])[0]
+step = query.get('step', [None])[0]
+
+cookies = get_cookies()
+
+
+def redirect_url(step):
+    return 'http://127.0.0.1:8000/cookies/{}?step={}&cookie_name={}'.format(__file__.split('/')[-1], step, cookie_name)
+
+
+def redirect_to_step(step):
+    sys.stdout.write(
+        'status: 302\r\n'
+        'Location: {}\r\n\r\n'.format(redirect_url(step))
+    )
+
+
+def step0():
+    sys.stdout.write(
+        '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">\n'
+        '<html>\n'
+        '<script>\n'
+        'if (window.testRunner) {{\n'
+        '    testRunner.dumpAsText();\n'
+        '    testRunner.waitUntilDone();\n'
+        '}}\n'
+        '\n'
+        'function gotoStep1() {{\n'
+        '    window.location = "{}";\n'
+        '}}\n'
+        '</script>\n'
+        '\n'
+        '<body _onload_="gotoStep1()">\n'
+        '</body>\n'
+        '</html>\n'.format(redirect_url(1))
+    )
+
+
+def step2(result):
+    sys.stdout.write(
+        '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">\n'
+        '<html>\n'
+        '<script>\n'
+        'function finish() {{\n'
+        '    if (window.testRunner)\n'
+        '        testRunner.notifyDone();\n'
+        '}}\n'
+        '</script>\n'
+        '\n'
+        '<body _onload_="finish()">\n'
+        'Cookie: {}\n'
+        '</body>\n'
+        '</html>\n'.format(result)
+    )
+
+
+sys.stdout.write('Content-Type: text/html\r\n')
+if step is None:
+    # Step 0: Set cookie for following request.
+    sys.stdout.write(
+        'Set-Cookie: {}=not+sure%2C+but+something; expires={} GMT; Max-Age=30\r\n\r\n'.format(cookie_name, expires.strftime('%a, %d-%b-%Y %H:%M:%S')))
+    step0()
+elif int(step) == 1:
+    # Step 1: Request caused by JS. It is sent with Cookie header with value of step 0.
+    sys.stdout.write('Set-Cookie: {}=42; expires={} GMT; Max-Age=30\r\n'.format(cookie_name, expires.strftime('%a, %d-%b-%Y %H:%M:%S')))
+    redirect_to_step(2)
+elif int(step) == 2:
+    # Step 2: Redirected request should have only Cookie header with update value.
+    sys.stdout.write('\r\n')
+    step2(cookies.get(cookie_name, ''))
+else:
+    sys.stdout.write('\r\n')
+    sys.exit('Error: unknown step: {}'.format(step))
+
+sys.exit(0)
Property changes on: trunk/LayoutTests/http/tests/cookies/multiple-redirect-and-set-cookie.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Deleted: trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.php (275761 => 275762)


--- trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.php	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/http/tests/cookies/resources/cookie-utilities.php	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1,53 +0,0 @@
-<?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/cookie_utilities.py (0 => 275762)


--- trunk/LayoutTests/http/tests/cookies/resources/cookie_utilities.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/resources/cookie_utilities.py	2021-04-09 15:02:25 UTC (rev 275762)
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+from datetime import datetime, timedelta
+
+file = __file__.split(':/cygwin')[-1]
+http_root = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(file))))
+sys.path.insert(0, http_root)
+
+from resources.portabilityLayer import get_cookies
+
+
+def hostname_is_equal_to_string(hostname):
+    return os.environ.get('HTTP_HOST', '').startswith(hostname)
+
+
+def reset_cookies_for_current_origin():
+    expires = datetime.utcnow() - timedelta(seconds=86400)
+    for cookie in get_cookies().keys():
+        sys.stdout.write('Set-Cookie: {}=deleted; expires={} GMT; Max-Age=0; path=/\r\n'.format(cookie, expires.strftime('%a, %d-%b-%Y %H:%M:%S')))
+
+
+def reset_cookies():
+    reset_cookies_for_current_origin()
+    if hostname_is_equal_to_string('127.0.0.1'):
+        sys.stdout.write('Location: http://localhost:8000{}\r\n'.format(os.environ.get('SCRIPT_URL', '')))
+    elif hostname_is_equal_to_string('localhost'):
+        sys.stdout.write('Location: http://127.0.0.1:8000{}?runTest\r\n'.format(os.environ.get('SCRIPT_URL', '')))
+
+
+def should_reset_cookies():
+    return os.environ.get('QUERY_STRING', None) is None
+
+
+def wk_set_cookie(name, value, additional_props):
+    cookie_value = '{}={}'.format(name, value)
+    for prop_name in additional_props:
+        cookie_value += '; {}'.format(prop_name)
+        if additional_props[prop_name]:
+            cookie_value += '={}'.format(additional_props[prop_name])
+    sys.stdout.write('Set-Cookie: {}\r\n'.format(cookie_value))
Property changes on: trunk/LayoutTests/http/tests/cookies/resources/cookie_utilities.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Deleted: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php (275761 => 275762)


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.php	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1,30 +0,0 @@
-<?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.py">
-</head>
-</html>

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


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.py	2021-04-09 15:02:25 UTC (rev 275762)
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+file = __file__.split(':/cygwin')[-1]
+http_root = os.path.dirname(os.path.abspath(os.path.dirname(file)))
+sys.path.insert(0, http_root)
+
+from resources.cookie_utilities import hostname_is_equal_to_string, reset_cookies, should_reset_cookies, wk_set_cookie
+
+sys.stdout.write('Content-Type: text/html\r\n')
+
+if should_reset_cookies():
+    reset_cookies()
+    sys.stdout.write('\r\n')
+    sys.exit(0)
+
+if hostname_is_equal_to_string('127.0.0.1'):
+    sys.stdout.write('Location: http://localhost:8000{}\r\n\r\n'.format(os.environ.get('REQUEST_URI')))
+    sys.exit(0)
+
+wk_set_cookie('strict', '14', {'SameSite': 'Strict', 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('implicit-strict', '14', {'SameSite': None, 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('strict-because-invalid-SameSite-value', '14', {'SameSite': 'invalid', 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('lax', '14', {'SameSite': 'Lax', 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('normal', '14', {'Max-Age': 100, 'path': '/'})
+sys.stdout.write('\r\n')
+
+print('''<!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.py">
+</head>
+</html>''')
Property changes on: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-cross-site-cookies.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Deleted: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php (275761 => 275762)


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.php	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1,27 +0,0 @@
-<?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.py">
-</head>
-</html>

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


--- trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.py	2021-04-09 15:02:25 UTC (rev 275762)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+file = __file__.split(':/cygwin')[-1]
+http_root = os.path.dirname(os.path.abspath(os.path.dirname(file)))
+sys.path.insert(0, http_root)
+
+from resources.cookie_utilities import reset_cookies, should_reset_cookies, wk_set_cookie
+
+sys.stdout.write('Content-Type: text/html\r\n')
+
+if should_reset_cookies():
+    reset_cookies()
+    sys.stdout.write('\r\n')
+    sys.exit(0)
+
+wk_set_cookie('strict', '14', {'SameSite': 'Strict', 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('implicit-strict', '14', {'SameSite': None, 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('strict-because-invalid-SameSite-value', '14', {'SameSite': 'invalid', 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('lax', '14', {'SameSite': 'Lax', 'Max-Age': 100, 'path': '/'})
+wk_set_cookie('normal', '14', {'Max-Age': 100, 'path': '/'})
+sys.stdout.write('\r\n')
+
+print('''<!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.py">
+</head>
+</html>''')
Property changes on: trunk/LayoutTests/http/tests/cookies/same-site/set-first-party-same-site-cookies.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Deleted: trunk/LayoutTests/http/tests/cookies/same-site/user-load-cross-site-redirect.php (275761 => 275762)


--- trunk/LayoutTests/http/tests/cookies/same-site/user-load-cross-site-redirect.php	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/http/tests/cookies/same-site/user-load-cross-site-redirect.php	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1,45 +0,0 @@
-<?php
-    include_once("../resources/cookie-utilities.php");
-
-    if (hostnameIsEqualToString("127.0.0.1") && empty($_SERVER["QUERY_STRING"])) {
-        wkSetCookie("strict", "27", Array("SameSite" => "Strict", "Max-Age" => 100, "path" => "/"));
-        wkSetCookie("lax", "27", Array("SameSite" => "Lax", "Max-Age" => 100, "path" => "/"));
-        wkSetCookie("normal", "27", Array("Max-Age" => 100, "path" => "/"));
-        header("Location: http://localhost:8000/resources/redirect.py?url="" . urlencode("http://127.0.0.1:8000" . $_SERVER["REQUEST_URI"] . "?check-cookies"));
-        exit(0);
-    }
-?>
-<!DOCTYPE html>
-<html>
-<head>
-<script src=""
-<script src=""
-<script>_setCachedCookiesJSON('<?php echo json_encode($_COOKIE); ?>')</script>
-</head>
-<body>
-<script>
-window.jsTestIsAsync = true;
-
-description("This test is representative of a user that loads a site, via the address bar or Command + clicking a hyperlink, that redirects to a cross-site page that expects its SameSite Lax cookies.");
-
-async function checkResult()
-{
-    debug("Cookies sent with HTTP request:");
-    // FIXME: Ensure that strict cookies are not sent. See <https://bugs.webkit.org/show_bug.cgi?id=194933>.
-    await shouldHaveCookieWithValue("lax", "27");
-    await shouldHaveCookieWithValue("normal", "27");
-
-    debug("<br>Cookies visible in DOM:");
-    shouldNotHaveDOMCookie("strict");
-    shouldHaveDOMCookieWithValue("lax", "27");
-    shouldHaveDOMCookieWithValue("normal", "27");
-
-    await resetCookies();
-    finishJSTest();
-}
-
-checkResult();
-</script>
-</body>
-</html>
-

Added: trunk/LayoutTests/http/tests/cookies/same-site/user-load-cross-site-redirect.py (0 => 275762)


--- trunk/LayoutTests/http/tests/cookies/same-site/user-load-cross-site-redirect.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/same-site/user-load-cross-site-redirect.py	2021-04-09 15:02:25 UTC (rev 275762)
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import sys
+from urllib.parse import quote
+
+file = __file__.split(':/cygwin')[-1]
+http_root = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(file))))
+sys.path.insert(0, http_root)
+
+from resources.portabilityLayer import get_cookies
+
+http_root = os.path.dirname(os.path.abspath(os.path.dirname(file)))
+sys.path.insert(0, http_root)
+
+from resources.cookie_utilities import hostname_is_equal_to_string, wk_set_cookie
+
+cookies = get_cookies()
+
+sys.stdout.write('Content-Type: text/html\r\n')
+
+if hostname_is_equal_to_string('127.0.0.1') and os.environ.get('QUERY_STRING', '') == '':
+    wk_set_cookie('strict', '27', {'SameSite': 'Strict', 'Max-Age': 100, 'path': '/'})
+    wk_set_cookie('lax', '27', {'SameSite': 'Lax', 'Max-Age': 100, 'path': '/'})
+    wk_set_cookie('normal', '27', {'Max-Age': 100, 'path': '/'})
+
+    path = quote('http://127.0.0.1:8000{}?check-cookies'.format(os.environ.get('REQUEST_URI')))
+    sys.stdout.write('Location: http://localhost:8000/resources/redirect.py?url=""
+    sys.exit(0)
+
+sys.stdout.write('\r\n')
+print('''<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>_setCachedCookiesJSON('{}')</script>
+</head>
+<body>
+<script>
+window.jsTestIsAsync = true;
+
+description("This test is representative of a user that loads a site, via the address bar or Command + clicking a hyperlink, that redirects to a cross-site page that expects its SameSite Lax cookies.");
+
+async function checkResult()
+{{
+    debug("Cookies sent with HTTP request:");
+    // FIXME: Ensure that strict cookies are not sent. See <https://bugs.webkit.org/show_bug.cgi?id=194933>.
+    await shouldHaveCookieWithValue("lax", "27");
+    await shouldHaveCookieWithValue("normal", "27");
+
+    debug("<br>Cookies visible in DOM:");
+    shouldNotHaveDOMCookie("strict");
+    shouldHaveDOMCookieWithValue("lax", "27");
+    shouldHaveDOMCookieWithValue("normal", "27");
+
+    await resetCookies();
+    finishJSTest();
+}}
+
+checkResult();
+</script>
+</body>
+</html>'''.format(json.dumps(cookies)))
Property changes on: trunk/LayoutTests/http/tests/cookies/same-site/user-load-cross-site-redirect.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (275761 => 275762)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2021-04-09 15:02:25 UTC (rev 275762)
@@ -2444,7 +2444,7 @@
 
 webkit.org/b/206264 imported/w3c/web-platform-tests/css/css-multicol/multicol-gap-percentage-001.html [ Failure ]
 
-webkit.org/b/194933 http/tests/cookies/same-site/user-load-cross-site-redirect.php [ Failure ]
+webkit.org/b/194933 http/tests/cookies/same-site/user-load-cross-site-redirect.py [ Failure ]
 
 webkit.org/b/211981 editing/pasteboard/data-transfer-get-data-on-pasting-html-uses-blob-url.html [ Failure ]
 

Modified: trunk/LayoutTests/platform/mac/TestExpectations (275761 => 275762)


--- trunk/LayoutTests/platform/mac/TestExpectations	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1405,8 +1405,8 @@
 http/tests/cookies/only-accept-first-party-cookies.html [ Skip ]
 
 # 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 ]
+http/tests/cookies/same-site/set-first-party-cross-site-cookies.py [ Skip ]
+http/tests/cookies/same-site/set-first-party-same-site-cookies.py [ Skip ]
 
 # <rdar://problem/40498290> REGRESSION (Mojave): HTMLMeterElement LayoutTests failing
 fast/dom/HTMLMeterElement/meter-boundary-values.html [ Failure ]

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (275761 => 275762)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2021-04-09 13:48:31 UTC (rev 275761)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2021-04-09 15:02:25 UTC (rev 275762)
@@ -1356,7 +1356,7 @@
 
 webkit.org/b/190626 imported/w3c/web-platform-tests/html/semantics/forms/the-datalist-element/datalistoptions.html [ Failure ]
 
-webkit.org/b/194933 http/tests/cookies/same-site/user-load-cross-site-redirect.php [ Failure ]
+webkit.org/b/194933 http/tests/cookies/same-site/user-load-cross-site-redirect.py [ Failure ]
 
 # WEBGL2 is disabled
 webkit.org/b/208188 fast/canvas/webgl/webgl2 [ Skip ]
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to