author | ziransun <zsun@igalia.com> |
Mon, 22 Jun 2020 10:40:01 +0000 | |
changeset 536813 | d4ada8e0d394333369769f9534b1f6906768ad4f |
parent 536812 | 5269ab455916b53139a605e3007e57fd828de817 |
child 536814 | c3ddafc46ffdc6f61da034a59ec6d44a3e09bff7 |
push id | 119680 |
push user | wptsync@mozilla.com |
push date | Tue, 23 Jun 2020 11:08:22 +0000 |
treeherder | autoland@7ca3d4bada73 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | testonly |
bugs | 1644679, 24079 |
milestone | 79.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/testing/web-platform/tests/beacon/resources/beacon.py +++ b/testing/web-platform/tests/beacon/resources/beacon.py @@ -1,10 +1,11 @@ import json +from wptserve.utils import isomorphic_decode def main(request, response): """Helper handler for Beacon tests. It handles two forms of requests: STORE: A URL with a query string of the form 'cmd=store&id=<token>'. @@ -28,78 +29,78 @@ def main(request, response): - [{error: "some validation details"}] - [] Common parameters: cmd - the command, 'store' or 'stat'. id - the unique identifier of the test. """ - id = request.GET.first("id") - command = request.GET.first("cmd").lower() + id = request.GET.first(b"id") + command = request.GET.first(b"cmd").lower() # Append CORS headers if needed. - if "origin" in request.GET: - response.headers.set("Access-Control-Allow-Origin", - request.GET.first("origin")) - if "credentials" in request.GET: - response.headers.set("Access-Control-Allow-Credentials", - request.GET.first("credentials")) + if b"origin" in request.GET: + response.headers.set(b"Access-Control-Allow-Origin", + request.GET.first(b"origin")) + if b"credentials" in request.GET: + response.headers.set(b"Access-Control-Allow-Credentials", + request.GET.first(b"credentials")) # Handle the 'store' and 'stat' commands. - if command == "store": + if command == b"store": error = None # Only store the actual POST requests, not any preflight/OPTIONS # requests we may get. - if request.method == "POST": - payload = "" - if "Content-Type" in request.headers and \ - "form-data" in request.headers["Content-Type"]: - if "payload" in request.POST: + if request.method == u"POST": + payload = b"" + if b"Content-Type" in request.headers and \ + b"form-data" in request.headers[b"Content-Type"]: + if b"payload" in request.POST: # The payload was sent as a FormData. - payload = request.POST.first("payload") + payload = request.POST.first(b"payload") else: # A FormData was sent with an empty payload. pass else: # The payload was sent as either a string, Blob, or BufferSource. payload = request.body - payload_parts = filter(None, payload.split(":")) + payload_parts = list(filter(None, payload.split(b":"))) if len(payload_parts) > 0: payload_size = int(payload_parts[0]) # Confirm the payload size sent matches with the number of # characters sent. if payload_size != len(payload_parts[1]): - error = "expected %d characters but got %d" % ( + error = u"expected %d characters but got %d" % ( payload_size, len(payload_parts[1])) else: # Confirm the payload contains the correct characters. for i in range(0, payload_size): - if payload_parts[1][i] != "*": - error = "expected '*' at index %d but got '%s''" % ( - i, payload_parts[1][i]) + if payload_parts[1][i:i+1] != b"*": + error = u"expected '*' at index %d but got '%s''" % ( + i, isomorphic_decode(payload_parts[1][i:i+1])) break # Store the result in the stash so that it can be retrieved # later with a 'stat' command. - request.server.stash.put(id, {"error": error}) - elif request.method == "OPTIONS": + request.server.stash.put(id, {u"error": error}) + elif request.method == u"OPTIONS": # If we expect a preflight, then add the cors headers we expect, # otherwise log an error as we shouldn't send a preflight for all # requests. - if "preflightExpected" in request.GET: - response.headers.set("Access-Control-Allow-Headers", - "content-type") - response.headers.set("Access-Control-Allow-Methods", "POST") + if b"preflightExpected" in request.GET: + response.headers.set(b"Access-Control-Allow-Headers", + b"content-type") + response.headers.set(b"Access-Control-Allow-Methods", b"POST") else: - error = "Preflight not expected." - request.server.stash.put(id, {"error": error}) - elif command == "stat": + error = u"Preflight not expected." + request.server.stash.put(id, {u"error": error}) + elif command == b"stat": test_data = request.server.stash.take(id) results = [test_data] if test_data else [] - response.headers.set("Content-Type", "text/plain") + response.headers.set(b"Content-Type", b"text/plain") response.content = json.dumps(results) else: response.status = 400 # BadRequest
--- a/testing/web-platform/tests/beacon/resources/content-type.py +++ b/testing/web-platform/tests/beacon/resources/content-type.py @@ -1,14 +1,14 @@ def main(request, response): - command = request.GET.first("cmd").lower(); - test_id = request.GET.first("id") - if command == "put": - request.server.stash.put(test_id, request.headers.get("Content-Type", "")) - return [("Content-Type", "text/plain")], "" + command = request.GET.first(b"cmd").lower() + test_id = request.GET.first(b"id") + if command == b"put": + request.server.stash.put(test_id, request.headers.get(b"Content-Type", b"")) + return [(b"Content-Type", b"text/plain")], u"" - if command == "get": - stashed_header = request.server.stash.take(test_id) - if stashed_header is not None: - return [("Content-Type", "text/plain")], stashed_header + if command == b"get": + stashed_header = request.server.stash.take(test_id) + if stashed_header is not None: + return [(b"Content-Type", b"text/plain")], stashed_header - response.set_error(400, "Bad Command") - return "ERROR: Bad Command!" + response.set_error(400, u"Bad Command") + return u"ERROR: Bad Command!"
--- a/testing/web-platform/tests/beacon/resources/inspect-header.py +++ b/testing/web-platform/tests/beacon/resources/inspect-header.py @@ -1,18 +1,18 @@ def main(request, response): - headers = [("Content-Type", "text/plain")] - command = request.GET.first("cmd").lower(); - test_id = request.GET.first("id") - header = request.GET.first("header") - if command == "put": - request.server.stash.put(test_id, request.headers.get(header, "")) + headers = [(b"Content-Type", b"text/plain")] + command = request.GET.first(b"cmd").lower() + test_id = request.GET.first(b"id") + header = request.GET.first(b"header") + if command == b"put": + request.server.stash.put(test_id, request.headers.get(header, b"")) - elif command == "get": + elif command == b"get": stashed_header = request.server.stash.take(test_id) if stashed_header is not None: - headers.append(("x-request-" + header, stashed_header )) + headers.append((b"x-request-" + header, stashed_header)) else: - response.set_error(400, "Bad Command") - return "ERROR: Bad Command!" + response.set_error(400, u"Bad Command") + return u"ERROR: Bad Command!" - return headers, "" + return headers, u""
--- a/testing/web-platform/tests/fetch/api/resources/trickle.py +++ b/testing/web-platform/tests/fetch/api/resources/trickle.py @@ -1,16 +1,16 @@ import time from six.moves import xrange def main(request, response): - delay = float(request.GET.first("ms", 500)) / 1E3 - count = int(request.GET.first("count", 50)) + delay = float(request.GET.first(b"ms", 500)) / 1E3 + count = int(request.GET.first(b"count", 50)) # Read request body request.body time.sleep(delay) - response.headers.set("Content-type", "text/plain") + response.headers.set(b"Content-type", b"text/plain") response.write_status_headers() time.sleep(delay) for i in xrange(count): - response.writer.write_content("TEST_TRICKLE\n") + response.writer.write_content(u"TEST_TRICKLE\n") time.sleep(delay)