Title: [272656] trunk/LayoutTests
Revision
272656
Author
[email protected]
Date
2021-02-10 08:53:11 -0800 (Wed, 10 Feb 2021)

Log Message

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

Patch by Chris Gambrell <[email protected]> on 2021-02-10
Reviewed by Jonathan Bedard.

* http/tests/css/font-face-src-loading.html:
* http/tests/css/link-css-disabled-value-with-slow-loading-sheet-in-error.html:
* http/tests/css/resources/500.php: Removed.
* http/tests/css/resources/500.py: Added.
* http/tests/css/resources/webfont-request.php: Removed.
* http/tests/css/resources/webfont-request.py: Added.
(getRequestCount):
(setRequestCount):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272655 => 272656)


--- trunk/LayoutTests/ChangeLog	2021-02-10 16:18:39 UTC (rev 272655)
+++ trunk/LayoutTests/ChangeLog	2021-02-10 16:53:11 UTC (rev 272656)
@@ -1,3 +1,20 @@
+2021-02-10  Chris Gambrell  <[email protected]>
+
+        [LayoutTests] Convert http/tests/css convert PHP to Python
+        https://bugs.webkit.org/show_bug.cgi?id=221511
+        <rdar://problem/74049585>
+
+        Reviewed by Jonathan Bedard.
+
+        * http/tests/css/font-face-src-loading.html:
+        * http/tests/css/link-css-disabled-value-with-slow-loading-sheet-in-error.html:
+        * http/tests/css/resources/500.php: Removed.
+        * http/tests/css/resources/500.py: Added.
+        * http/tests/css/resources/webfont-request.php: Removed.
+        * http/tests/css/resources/webfont-request.py: Added.
+        (getRequestCount):
+        (setRequestCount):
+
 2021-02-10  Myles C. Maxfield  <[email protected]>
 
         REGRESSION(r263255): Text styles without an explicit language tag do not honor the system language

Modified: trunk/LayoutTests/http/tests/css/font-face-src-loading.html (272655 => 272656)


--- trunk/LayoutTests/http/tests/css/font-face-src-loading.html	2021-02-10 16:18:39 UTC (rev 272655)
+++ trunk/LayoutTests/http/tests/css/font-face-src-loading.html	2021-02-10 16:53:11 UTC (rev 272656)
@@ -2,7 +2,7 @@
 <style>
 @font-face {
     font-family: 'webfont';
-    src: url(http://localhost:8000/css/resources/webfont-request.php?mode=getFont&filename=webfontRequestCount.txt) format('truetype');
+    src: url(http://localhost:8000/css/resources/webfont-request.py?mode=getFont&filename=webfontRequestCount.txt) format('truetype');
 }
 </style>
 <script>
@@ -41,7 +41,7 @@
         if (xhr.readyState == xhr.DONE)
             checkRequestCount();
     };
-    xhr.open('GET', 'http://localhost:8000/css/resources/webfont-request.php?mode=getRequestCount&' + filename, true);
+    xhr.open('GET', 'http://localhost:8000/css/resources/webfont-request.py?mode=getRequestCount&' + filename, true);
     xhr.send();
 }
 

Modified: trunk/LayoutTests/http/tests/css/link-css-disabled-value-with-slow-loading-sheet-in-error.html (272655 => 272656)


--- trunk/LayoutTests/http/tests/css/link-css-disabled-value-with-slow-loading-sheet-in-error.html	2021-02-10 16:18:39 UTC (rev 272655)
+++ trunk/LayoutTests/http/tests/css/link-css-disabled-value-with-slow-loading-sheet-in-error.html	2021-02-10 16:53:11 UTC (rev 272656)
@@ -2,7 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="" media="all" title="Default Style Sheet" type="text/css">
-<link rel="alternate stylesheet" href="" media="all" title="green" type="text/css">
+<link rel="alternate stylesheet" href="" media="all" title="green" type="text/css">
 <script src=""
 </head>
 <body>

Deleted: trunk/LayoutTests/http/tests/css/resources/500.php (272655 => 272656)


--- trunk/LayoutTests/http/tests/css/resources/500.php	2021-02-10 16:18:39 UTC (rev 272655)
+++ trunk/LayoutTests/http/tests/css/resources/500.php	2021-02-10 16:53:11 UTC (rev 272656)
@@ -1,13 +0,0 @@
-<?php
-// We sleep here so that we are have enough time to test the different attributes before the stylesheet is fully loaded.
-usleep(100);
-
-header("HTTP/1.0 500 Internal Error");
-header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
-header("Cache-Control: no-cache, no-store, must-revalidate");
-header("Pragma: no-cache");
-header("Content-Type: text/css");
-
-ob_flush();
-flush();
-?>

Added: trunk/LayoutTests/http/tests/css/resources/500.py (0 => 272656)


--- trunk/LayoutTests/http/tests/css/resources/500.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/css/resources/500.py	2021-02-10 16:53:11 UTC (rev 272656)
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+import sys
+import time
+
+time.sleep(0.0001)
+
+sys.stdout.write(
+    'status: 500\r\n'
+    'Expires: Thu, 01 Dec 2003 16:00:00 GMT\r\n'
+    'Cache-Control: no-cache, no-store, must-revalidate\r\n'
+    'Pragma: no-cache\r\n'
+    'Content-Type: text/css\r\n\r\n'
+)
+
+sys.stdout.flush()
\ No newline at end of file
Property changes on: trunk/LayoutTests/http/tests/css/resources/500.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Deleted: trunk/LayoutTests/http/tests/css/resources/webfont-request.php (272655 => 272656)


--- trunk/LayoutTests/http/tests/css/resources/webfont-request.php	2021-02-10 16:18:39 UTC (rev 272655)
+++ trunk/LayoutTests/http/tests/css/resources/webfont-request.php	2021-02-10 16:53:11 UTC (rev 272656)
@@ -1,36 +0,0 @@
-<?php
-require_once "../../resources/portabilityLayer.php";
-
-function getRequestCount($file)
-{
-    if (!file_exists($file)) {
-        return 0;
-    }
-    return (int)file_get_contents($file);
-}
-
-function setRequestCount($file, $count)
-{
-    file_put_contents($file, $count);
-}
-
-$tmpFile = sys_get_temp_dir() . "/" . $_GET["filename"];
-
-$currentCount = getRequestCount($tmpFile);
-$mode = $_GET["mode"];
-
-if ($mode == "getFont") {
-    setRequestCount($tmpFile, $currentCount + 1);
-    header("Access-control-max-age: 0");
-    header("Access-control-allow-origin: *");
-    header("Access-control-allow-methods: *");
-    header("Cache-Control: max-age=0");
-    header("Content-Type: application/octet-stream");
-    echo "";
-} else if ($mode == "getRequestCount") {
-    header("Access-control-max-age: 0");
-    header("Access-control-allow-origin: *");
-    header("Access-control-allow-methods: *");
-    echo $currentCount;
-}
-?>

Added: trunk/LayoutTests/http/tests/css/resources/webfont-request.py (0 => 272656)


--- trunk/LayoutTests/http/tests/css/resources/webfont-request.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/css/resources/webfont-request.py	2021-02-10 16:53:11 UTC (rev 272656)
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import tempfile
+from urllib.parse import parse_qs
+
+def getRequestCount(file):
+    if not os.path.isfile(file):
+        return 0
+
+    with open(file, 'r') as file:
+        return int(file.read())
+
+def setRequestCount(file, count):
+    with open(file, 'r') as file:
+        file.write(count)
+
+query = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True)
+filename = query.get('filename', [''])[0]
+mode = query.get('mode', [''])[0]
+
+tmpFile = os.path.join(tempfile.gettempdir(), filename)
+currentCount = getRequestCount(tmpFile)
+
+if mode == 'getFont':
+    setRequestCount(tmpFile, currentCount + 1)
+    sys.stdout.write(
+        'Access-control-max-age: 0\r\n'
+        'Access-control-allow-origin: *\r\n'
+        'Access-control-allow-methods: *\r\n'
+        'Cache-Control: max-age=0\r\n'
+        'Content-Type: application/octet-stream\r\n\r\n'
+    )
+else:
+    sys.stdout.write(
+        'Access-control-max-age: 0\r\n'
+        'Access-control-allow-origin: *\r\n'
+        'Access-control-allow-methods: *\r\n\r\n'
+        '{}'.format(currentCount)
+    )
\ No newline at end of file
Property changes on: trunk/LayoutTests/http/tests/css/resources/webfont-request.py
___________________________________________________________________

Added: svn:executable

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

Reply via email to