Diff
Modified: trunk/LayoutTests/ChangeLog (273697 => 273698)
--- trunk/LayoutTests/ChangeLog 2021-03-01 23:15:25 UTC (rev 273697)
+++ trunk/LayoutTests/ChangeLog 2021-03-01 23:28:08 UTC (rev 273698)
@@ -1,3 +1,21 @@
+2021-03-01 Chris Gambrell <cgambr...@apple.com>
+
+ [LayoutTests] Convert http/tests/websocket convert PHP to Python
+ https://bugs.webkit.org/show_bug.cgi?id=221912
+ <rdar://problem/74358196>
+
+ Reviewed by Jonathan Bedard.
+
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php: Removed.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.py: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies.php: Removed.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies.py: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js:
+ (clearCookies):
+ * http/tests/websocket/tests/hybi/error-event-ready-state-non-existent-url-with-server-responding-404.html:
+ * http/tests/websocket/tests/hybi/resources/status-404-without-body.php: Removed.
+ * http/tests/websocket/tests/hybi/resources/status-404-without-body.py: Added.
+
2021-03-01 Peng Liu <peng.l...@apple.com>
[GPUP] Clean up LayoutTests/gpu-process/TestExpectations related to media tests
Deleted: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php (273697 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php 2021-03-01 23:15:25 UTC (rev 273697)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php 2021-03-01 23:28:08 UTC (rev 273698)
@@ -1,43 +0,0 @@
-<?php
-if ( isset($_GET['clear'])) {
- header("Content-Type: text/plain");
- setcookie("WK-websocket-test", "0", time()-1);
- setcookie("WK-websocket-test-httponly", "0", time()-1, "", "", false, true);
- echo("Cookies are cleared.");
- return;
-} else {
- header("Content-Type: text/html");
- setcookie("WK-websocket-test", "1");
- setcookie("WK-websocket-test-httponly", "1", time()+3600, "", "", false, true);
- header("Set-Cookie: WK-websocket-test=1");
- header("Set-Cookie: WK-websocket-test-httponly=1; HttpOnly");
-}
-?>
-<html>
-<head>
-<script src=""
-</head>
-<body>
-<p>Tests that WebSocket sends no cookies when they are blocked.</p>
-<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
-<div id="console"></div>
-<script>
-window.jsTestIsAsync = true;
-
-function startsWith(str, prefix) {
- return str.indexOf(prefix) == 0;
-}
-
-var worker = new Worker("resources/block-cookies-worker.js");
-worker._onmessage_ = function (event)
-{
- var message = event.data;
- debug(message);
- if (startsWith(message, "PASS") || startsWith(message, "FAIL"))
- finishJSTest();
-};
-
-</script>
-<script src=""
-</body>
-</html>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.py (0 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.py 2021-03-01 23:28:08 UTC (rev 273698)
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+
+
+import os
+import sys
+from datetime import datetime, timedelta
+from urllib.parse import parse_qs
+
+clear = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True).get('clear', [None])[0]
+clear_exp_time = datetime.utcnow() - timedelta(seconds=1)
+exp_time = datetime.utcnow() + timedelta(hours=1)
+
+if clear:
+ sys.stdout.write(
+ 'Content-Type: text/plain\r\n'
+ 'Set-Cookie: "WK-websocket-test"=0; expires={} GMT; Max-Age=0\r\n'
+ 'Set-Cookie: "WK-websocket-test-httponly"=0; expires={} GMT; Max-Age=0; HttpOnly\r\n\r\n'
+ 'Cookies are cleared.'.format(clear_exp_time.strftime('%a, %d-%b-%Y %H:%M:%S'))
+ )
+
+ sys.exit(0)
+
+sys.stdout.write(
+ 'Content-Type: text/html\r\n'
+ 'Set-Cookie: "WK-websocket-test"=1\r\n'
+ 'Set-Cookie: "WK-websocket-test-httponly"=1; expires={} GMT; Max-Age=3600; HttpOnly\r\n'
+ 'Set-Cookie: "WK-websocket-test"=1\r\n'
+ 'Set-Cookie: "WK-websocket-test-httponly"=1; HttpOnly\r\n\r\n'.format(exp_time.strftime('%a, %d-%b-%Y %H:%M:%S'))
+)
+
+print('''<html>
+<head>
+<script src=""
+</head>
+<body>
+<p>Tests that WebSocket sends no cookies when they are blocked.</p>
+<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
+<div id="console"></div>
+<script>
+window.jsTestIsAsync = true;
+
+function startsWith(str, prefix) {
+ return str.indexOf(prefix) == 0;
+}
+
+var worker = new Worker("resources/block-cookies-worker.js");
+worker._onmessage_ = function (event)
+{
+ var message = event.data;
+ debug(message);
+ if (startsWith(message, "PASS") || startsWith(message, "FAIL"))
+ finishJSTest();
+};
+
+</script>
+<script src=""
+</body>
+</html>''')
\ No newline at end of file
Property changes on: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.py
___________________________________________________________________
Added: svn:executable
+*
\ No newline at end of property
Deleted: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php (273697 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php 2021-03-01 23:15:25 UTC (rev 273697)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php 2021-03-01 23:28:08 UTC (rev 273698)
@@ -1,47 +0,0 @@
-<?php
-if ( isset($_GET['clear'])) {
- header("Content-Type: text/plain");
- setcookie("WK-websocket-test", "0", time()-1);
- setcookie("WK-websocket-test-httponly", "0", time()-1, "", "", false, true);
- echo("Cookies are cleared.");
- return;
-} else {
- header("Content-Type: text/html");
- setcookie("WK-websocket-test", "1");
- setcookie("WK-websocket-test-httponly", "1", time()+3600, "", "", false, true);
- header("Set-Cookie: WK-websocket-test=1");
- header("Set-Cookie: WK-websocket-test-httponly=1; HttpOnly");
-}
-?>
-<html>
-<head>
-<script src=""
-</head>
-<body>
-<p>Tests that WebSocket sends no cookies when they are blocked.</p>
-<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
-<div id="console"></div>
-<script>
-window.jsTestIsAsync = true;
-
-function clearCookies()
-{
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "block-cookies.php?clear=1", false);
- xhr.send(null);
-}
-
-var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/contentextensions/resources/echo-cookie");
-ws._onopen_ = function() {
- debug("WebSocket open");
-};
-ws._onmessage_ = function(evt) {
- debug("WebSocket message (" + evt.data + ")");
- clearCookies();
- finishJSTest();
-};
-
-</script>
-<script src=""
-</body>
-</html>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.py (0 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.py 2021-03-01 23:28:08 UTC (rev 273698)
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+from datetime import datetime, timedelta
+from urllib.parse import parse_qs
+
+clear = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True).get('clear', [None])[0]
+clear_exp_time = datetime.utcnow() - timedelta(seconds=1)
+clear_exp_time_httponly = datetime.utcnow() - timedelta(seconds=1000)
+exp_time = datetime.utcnow() + timedelta(hours=1)
+
+if clear:
+ sys.stdout.write(
+ 'Content-Type: text/plain\r\n'
+ 'Set-Cookie: "WK-websocket-test"=0; expires={} GMT; Max-Age=0\r\n'
+ 'Set-Cookie: "WK-websocket-test-httponly"=0; expires={} GMT; Max-Age=0; HttpOnly\r\n\r\n'
+ 'Cookies are cleared.'.format(clear_exp_time.strftime('%a, %d-%b-%Y %H:%M:%S'), clear_exp_time_httponly.strftime('%a, %d-%b-%Y %H:%M:%S'))
+ )
+
+ sys.exit(0)
+
+sys.stdout.write(
+ 'Content-Type: text/html\r\n'
+ 'Set-Cookie: "WK-websocket-test"=1\r\n'
+ 'Set-Cookie: "WK-websocket-test-httponly"=1; expires={} GMT; Max-Age=3600; HttpOnly\r\n'
+ 'Set-Cookie: "WK-websocket-test"=1\r\n'
+ 'Set-Cookie: "WK-websocket-test-httponly"=1; HttpOnly\r\n\r\n'.format(exp_time.strftime('%a, %d-%b-%Y %H:%M:%S'))
+)
+
+print('''<html>
+<head>
+<script src=""
+</head>
+<body>
+<p>Tests that WebSocket sends no cookies when they are blocked.</p>
+<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
+<div id="console"></div>
+<script>
+window.jsTestIsAsync = true;
+
+function clearCookies()
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "block-cookies.py?clear=1", false);
+ xhr.send(null);
+}
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/contentextensions/resources/echo-cookie");
+ws._onopen_ = function() {
+ debug("WebSocket open");
+};
+ws._onmessage_ = function(evt) {
+ debug("WebSocket message (" + evt.data + ")");
+ clearCookies();
+ finishJSTest();
+};
+
+</script>
+<script src=""
+</body>
+</html>''')
\ No newline at end of file
Property changes on: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.py
___________________________________________________________________
Added: svn:executable
+*
\ No newline at end of property
Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js (273697 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js 2021-03-01 23:15:25 UTC (rev 273697)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js 2021-03-01 23:28:08 UTC (rev 273698)
@@ -1,7 +1,7 @@
function clearCookies()
{
var xhr = new XMLHttpRequest();
- xhr.open("GET", "block-cookies-worker.php?clear=1", false);
+ xhr.open("GET", "block-cookies-worker.py?clear=1", false);
xhr.send(null);
}
Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/error-event-ready-state-non-existent-url-with-server-responding-404.html (273697 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/error-event-ready-state-non-existent-url-with-server-responding-404.html 2021-03-01 23:15:25 UTC (rev 273697)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/error-event-ready-state-non-existent-url-with-server-responding-404.html 2021-03-01 23:28:08 UTC (rev 273698)
@@ -11,7 +11,7 @@
window.jsTestIsAsync = true;
-var ws = new WebSocket("ws://localhost:8000/websocket/tests/hybi/resources/status-404-without-body.php");
+var ws = new WebSocket("ws://localhost:8000/websocket/tests/hybi/resources/status-404-without-body.py");
ws._onerror_ = function(event) {
debug("onerror() was called.");
Deleted: trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/status-404-without-body.php (273697 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/status-404-without-body.php 2021-03-01 23:15:25 UTC (rev 273697)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/status-404-without-body.php 2021-03-01 23:28:08 UTC (rev 273698)
@@ -1,4 +0,0 @@
-<?php
- header('http/1.1 404 Not Found');
- exit();
-?>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/status-404-without-body.py (0 => 273698)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/status-404-without-body.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/status-404-without-body.py 2021-03-01 23:28:08 UTC (rev 273698)
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+
+import sys
+
+sys.stdout.write(
+ 'status: 404\r\n'
+ 'Content-Type: text/html\r\n\r\n'
+)
\ No newline at end of file
Property changes on: trunk/LayoutTests/http/tests/websocket/tests/hybi/resources/status-404-without-body.py
___________________________________________________________________
Added: svn:executable
+*
\ No newline at end of property