Title: [276109] trunk/LayoutTests
Revision
276109
Author
cgambr...@apple.com
Date
2021-04-15 19:46:59 -0700 (Thu, 15 Apr 2021)

Log Message

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

Reviewed by Jonathan Bedard.

* http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html:
* http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.php: Removed.
* http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.py: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276108 => 276109)


--- trunk/LayoutTests/ChangeLog	2021-04-16 02:33:52 UTC (rev 276108)
+++ trunk/LayoutTests/ChangeLog	2021-04-16 02:46:59 UTC (rev 276109)
@@ -1,3 +1,15 @@
+2021-04-15  Chris Gambrell  <cgambr...@apple.com>
+
+        [LayoutTests] Convert http/tests/resourceLoadStatistics convert PHP to Python
+        https://bugs.webkit.org/show_bug.cgi?id=223541
+        <rdar://problem/75639142>
+
+        Reviewed by Jonathan Bedard.
+
+        * http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html:
+        * http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.php: Removed.
+        * http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.py: Added.
+
 2021-04-15  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Unreviewed test gardening after r276084

Modified: trunk/LayoutTests/http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html (276108 => 276109)


--- trunk/LayoutTests/http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html	2021-04-16 02:33:52 UTC (rev 276108)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html	2021-04-16 02:46:59 UTC (rev 276109)
@@ -13,7 +13,7 @@
     var loadedUrl;
     function firstFetch() {
         // This should create a capped cache entry.
-        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.php",
+        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.py",
             {
                 cache: "reload",
                 headers: {
@@ -32,7 +32,7 @@
 
     function secondFetch() {
         // This should not trigger a successful cache hit and instead create another capped cache entry.
-        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.php",
+        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.py",
             {
                 cache: "force-cache",
                 headers: {
@@ -51,7 +51,7 @@
 
     function thirdFetch() {
         // This should not trigger a successful cache hit and instead create another capped cache entry.
-        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.php",
+        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.py",
             {
                 cache: "force-cache",
             }
@@ -67,7 +67,7 @@
 
     function fourthFetch() {
         // This should not trigger a successful cache hit but clear capping.
-        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.php",
+        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.py",
             {
                 cache: "force-cache",
             }
@@ -83,7 +83,7 @@
 
     function fifthFetch() {
         // This should trigger a regular, successful cache hit.
-        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.php",
+        fetch("http://localhost:8000/resourceLoadStatistics/resources/cached-permanent-redirect.py",
             {
                 headers: {
                     "X-WebKit": "1234",

Deleted: trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.php (276108 => 276109)


--- trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.php	2021-04-16 02:33:52 UTC (rev 276108)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.php	2021-04-16 02:46:59 UTC (rev 276109)
@@ -1,16 +0,0 @@
-<?php
-if (isset($_SERVER["HTTP_IF_NONE_MATCH"]) || isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
-    header($_SERVER["SERVER_PROTOCOL"] . " 500 Internal Server Error", true, 500);
-    exit;
-}
-header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
-header("Access-Control-Allow-Headers: X-WebKit");
-if ($_SERVER["REQUEST_METHOD"] == "OPTIONS" && isset($_SERVER["HTTP_ACCESS_CONTROL_REQUEST_METHOD"]) && $_SERVER["HTTP_ACCESS_CONTROL_REQUEST_METHOD"] == "GET") {
-    exit;
-}
-$headerStringValue = $_SERVER["HTTP_X_WEBKIT"];
-header($_SERVER["SERVER_PROTOCOL"] . " 301 Moved Permanently", true, 301);
-header("Cache-Control: private, max-age=31536000", true);
-header('ETag: "WebKitTest"', true);
-header("Location: http://localhost:8000/resourceLoadStatistics/resources/echo-query.py?value=" . $headerStringValue);
-?>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.py (0 => 276109)


--- trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.py	2021-04-16 02:46:59 UTC (rev 276109)
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+if_none_match = os.environ.get('HTTP_IF_NONE_MATCH', None)
+if_modified_since = os.environ.get('HTTP_IF_MODIFIED_SINCE', None)
+
+sys.stdout.write('Content-Type: text/html\r\n')
+
+if if_none_match is not None or if_modified_since is not None:
+    sys.stdout.write('status: 500\r\n\r\n')
+    sys.exit(0)
+
+request_method = os.environ.get('REQUEST_METHOD', '')
+ac_request_method = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_METHOD', '')
+
+
+sys.stdout.write(
+    'Access-Control-Allow-Origin: http://127.0.0.1:8000\r\n'
+    'Access-Control-Allow-Headers: X-WebKit\r\n'
+)
+
+if request_method == 'OPTIONS' and ac_request_method == 'GET':
+    sys.stdout.write('\r\n')
+    sys.exit(0)
+
+header_string_value = os.environ.get('HTTP_X_WEBKIT', '')
+sys.stdout.write(
+    'status: 301\r\n'
+    'Cache-Control: private, max-age=31536000\r\n'
+    'ETag: "WebKitTest"\r\n'
+    'Location: http://localhost:8000/resourceLoadStatistics/resources/echo-query.py?value={}\r\n\r\n'.format(header_string_value)
+)
Property changes on: trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/cached-permanent-redirect.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to