Skip to content
Permalink
Browse files
[LayoutTests] Convert http/tests/cache convert PHP to Python
https://bugs.webkit.org/show_bug.cgi?id=222935
<rdar://problem/75183314>

Reviewed by Jonathan Bedard.

* http/tests/cache/cache-redirections.html:
* http/tests/cache/resources/cache-control-redirect.php: Removed.
* http/tests/cache/resources/cache-control-redirect.py: Added.
* http/tests/cache/resources/permanent-redirect.php: Removed.
* http/tests/cache/resources/x-frame-options.php: Removed.
* http/tests/cache/resources/x-frame-options.py: Added.
* http/tests/cache/x-frame-options-304.html:
* http/tests/navigation/window-open-redirect-and-remove-opener.html:
* http/tests/xmlhttprequest/cacheable-cross-origin-redirect-crash.html:


Canonical link: https://commits.webkit.org/236063@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ChrisGambrell committed Apr 2, 2021
1 parent 4839b65 commit dde66ab17ec5cf96bd0a5e474a0cea427f528c0a
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 64 deletions.
@@ -1,3 +1,21 @@
2021-04-01 Chris Gambrell <cgambrell@apple.com>

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

Reviewed by Jonathan Bedard.

* http/tests/cache/cache-redirections.html:
* http/tests/cache/resources/cache-control-redirect.php: Removed.
* http/tests/cache/resources/cache-control-redirect.py: Added.
* http/tests/cache/resources/permanent-redirect.php: Removed.
* http/tests/cache/resources/x-frame-options.php: Removed.
* http/tests/cache/resources/x-frame-options.py: Added.
* http/tests/cache/x-frame-options-304.html:
* http/tests/navigation/window-open-redirect-and-remove-opener.html:
* http/tests/xmlhttprequest/cacheable-cross-origin-redirect-crash.html:

2021-04-01 Chris Gambrell <cgambrell@apple.com>

[LayoutTests] Convert http/tests/history convert PHP to Python
@@ -255,6 +273,24 @@
* js/dom/transform-stream-expected.txt: Added.
* js/dom/transform-stream.html: Added.

2021-03-31 Chris Gambrell <cgambrell@apple.com>

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

Reviewed by Jonathan Bedard.

* http/tests/cache/cache-redirections.html:
* http/tests/cache/resources/cache-control-redirect.php: Removed.
* http/tests/cache/resources/cache-control-redirect.py: Added.
* http/tests/cache/resources/permanent-redirect.php: Removed.
* http/tests/cache/resources/x-frame-options.php: Removed.
* http/tests/cache/resources/x-frame-options.py: Added.
* http/tests/cache/x-frame-options-304.html:
* http/tests/navigation/window-open-redirect-and-remove-opener.html:
* http/tests/xmlhttprequest/cacheable-cross-origin-redirect-crash.html:

2021-03-31 Chris Gambrell <cgambrell@apple.com>

[LayoutTests] Convert http/tests/appcache convert PHP to Python
@@ -15,7 +15,7 @@

var counter = 0;
var resource = "No";
var baseURL = "resources/cache-control-redirect.php?code=302&url=cacheable-random-text.py&random_id=1";
var baseURL = "resources/cache-control-redirect.py?code=302&url=cacheable-random-text.py&random_id=1";
var testCases = [
{name : "Should reuse resource (cacheable redirection)", expected : true, url : baseURL + "&cache_control=public, max-age=1000", reloadDelay : 0},
{name : "Should reload resource (no-store redirection)", expected : false, url: baseURL + "&cache_control=no-store&max_age=1000", reloadDelay : 0},

This file was deleted.

@@ -0,0 +1,33 @@
#!/usr/bin/env python3

import os
import sys
from random import randint
from urllib.parse import parse_qs

query = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True)
cache_control = query.get('cache_control', [''])[0]
code = query.get('code', [302])[-1]
expiration = query.get('expiration', [None])[0]
random_id = query.get('random_id', [None])[0]
url = query.get('url', [''])[0]

sys.stdout.write('status: {}\r\n'.format(int(code)))

if random_id is not None:
ident = ''
charset = 'ABCDEFGHIKLMNOPQRSTUVWXYZ0123456789'
for _ in range(0, 16):
ident += charset[randint(0, len(charset) - 1)]
sys.stdout.write('Location: {}?id={}\r\n'.format(url, ident))
else:
sys.stdout.write('Location: {}\r\n'.format(url))

if expiration is not None:
expires = '{} +0000'.format(expires.strftime('%a, %d %b %Y %H:%M:%S'))
sys.stdout.write('Expires: {}\r\n'.format(expires))

sys.stdout.write(
'Content-Type: text/html\r\n'
'Cache-Control: {}\r\n\r\n'.format(cache_control)
)

This file was deleted.

This file was deleted.

@@ -0,0 +1,29 @@
#!/usr/bin/env python3

import os
import sys
from datetime import datetime, timedelta

modified_since = os.environ.get('HTTP_IF_MODIFIED_SINCE', '')

sys.stdout.write('Content-Type: text/html\r\n')

if modified_since:
sys.stdout.write('status: 304\r\n\r\n')
sys.exit(0)

one_year = 365 * 24 * 60 * 60
last_modified = '{} +0000'.format((datetime.utcnow() - timedelta(seconds=one_year)).strftime('%a, %d %b %Y %H:%M:%S'))
expires = '{} +0000'.format((datetime.utcnow() + timedelta(seconds=one_year)).strftime('%a, %d %b %Y %H:%M:%S'))

sys.stdout.write(
'Cache-Control: no-cache, max-age={}\r\n'
'Expires: {}\r\n'
'Content-Type: text/html\r\n'
'Etag: 123456789\r\n'
'Last-Modified: {}\r\n'
'X-FRAME-OPTIONS: ALLOWALL\r\n\r\n'
'<body><script>\n'
'window.onload = function() {{ window.parent.test(); }}\n'
'</script></body>\n'.format(one_year, expires, last_modified)
)
@@ -17,9 +17,9 @@

document.body.removeChild(document.body.lastChild);
var iframe = document.createElement("iframe");
iframe.src = "resources/x-frame-options.php"
iframe.src = "resources/x-frame-options.py"
document.body.appendChild(iframe);
}
</script>
<iframe src="resources/x-frame-options.php"></iframe>
<iframe src="resources/x-frame-options.py"></iframe>
</body>
@@ -18,7 +18,7 @@
<p>Tests that we do not crash when removing the opener after using window.open() to load a resource that redirects.</p>
<iframe name="A" srcdoc='
<script>
window.open("http://127.0.0.1:8000/cache/resources/cache-control-redirect.php?url=http://127.0.0.1:8000/navigation/resources/window-open-redirect-and-remove-opener.html", "B");
window.open("http://127.0.0.1:8000/cache/resources/cache-control-redirect.py?url=http://127.0.0.1:8000/navigation/resources/window-open-redirect-and-remove-opener.html", "B");
parent.removeIframeA();
</script>
'></iframe>
@@ -6,7 +6,7 @@
description("Tests that we do not crash when XHR reuses a cached resource that contains a simple cross origin redirect.");
jsTestIsAsync = true;

const url = "/cache/resources/cache-control-redirect.php?code=302&cache_control=public,max-age=1000&url=http%3A%2F%2Flocalhost%3A8000%2Fsecurity%2Fresources%2Fallow-if-origin.py%3FallowCache%26allowCredentials%26origin%3Dhttp%253A%252F%252F127.0.0.1%253A8000";
const url = "/cache/resources/cache-control-redirect.py?code=302&cache_control=public,max-age=1000&url=http%3A%2F%2Flocalhost%3A8000%2Fsecurity%2Fresources%2Fallow-if-origin.py%3FallowCache%26allowCredentials%26origin%3Dhttp%253A%252F%252F127.0.0.1%253A8000";

xhr = new XMLHttpRequest();
xhr.withCredentials = true;

0 comments on commit dde66ab

Please sign in to comment.