gecko-dev/testing/web-platform/tests/resource-timing/SyntheticResponse.py
Yoav Weiss 4331c72603 Bug 1517720 [wpt PR 14713] - Fix resource-timing.html document.domain test - take 2, a=testonly
Automatic update from web-platform-tests
Fix resource-timing.html document.domain test - take 2 (#14713)

* Fix resource-timing.html document.domain test

The document.domain test on resource-timing.html was not passing on any
browser. Looking into it, the test was broken.
This CL fixes it, removes it from TestExpectations, as well as rename it
as many more tests were added since this was *the* L1 test suite.

Change-Id: Ibaa26032ec36a652aba352c5bb08ba6975d8b3f6
Reviewed-on: https://chromium-review.googlesource.com/c/1387475
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618590}

* Moved the document domain test out of the other legacy tests, to verify that it is running from the right domain

--

wpt-commits: 2ecc3df3498165fd368a1c45ee7f87e4aacbf439
wpt-pr: 14713
2019-02-07 21:49:46 +00:00

48 lines
1.7 KiB
Python

import urllib
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), "../common/"))
import sleep
def main(request, response):
index = request.request_path.index("?")
args = request.request_path[index+1:].split("&")
headers = []
statusSent = False
headersSent = False
for arg in args:
if arg.startswith("ignored"):
continue
elif arg.endswith("ms"):
sleep.sleep_at_least(float(arg[0:-2]))
elif arg.startswith("redirect:"):
return (302, "WEBPERF MARKETING"), [("Location", urllib.unquote(arg[9:]))], "TEST"
elif arg.startswith("mime:"):
headers.append(("Content-Type", urllib.unquote(arg[5:])))
elif arg.startswith("send:"):
text = urllib.unquote(arg[5:])
if not statusSent:
# Default to a 200 status code.
response.writer.write_status(200)
statusSent = True
if not headersSent:
for key, value in headers:
response.writer.write_header(key, value)
response.writer.end_headers()
headersSent = True
response.writer.write_content(text)
elif arg.startswith("status:"):
code = int(urllib.unquote(arg[7:]))
response.writer.write_status(code)
if code // 100 == 1:
# Terminate informational 1XX responses with an empty line.
response.writer.end_headers()
else:
statusSent = True
elif arg == "flush":
response.writer.flush()
# else:
# error " INVALID ARGUMENT %s" % arg