diff options
author | Moonchild <moonchild@palemoon.org> | 2021-02-25 01:03:57 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-02-25 01:03:57 +0000 |
commit | ceadffab6b357723981a429e11222daf6cd6dcfb (patch) | |
tree | 5603053048d6a460f79b22bdf165fb74d32d39b0 /testing/web-platform/tests/fetch/api/resources | |
parent | 14fb2f966e9b54598c451e3cb35b4aa0480dafed (diff) | |
parent | ad5a13bd501e379517da1a944c104a11d951a3f5 (diff) | |
download | UXP-RC_20210225.tar UXP-RC_20210225.tar.gz UXP-RC_20210225.tar.lz UXP-RC_20210225.tar.xz UXP-RC_20210225.zip |
Merge branch 'master' into releaseRC_20210225
Diffstat (limited to 'testing/web-platform/tests/fetch/api/resources')
11 files changed, 0 insertions, 270 deletions
diff --git a/testing/web-platform/tests/fetch/api/resources/authentication.py b/testing/web-platform/tests/fetch/api/resources/authentication.py deleted file mode 100644 index a06d179e5..000000000 --- a/testing/web-platform/tests/fetch/api/resources/authentication.py +++ /dev/null @@ -1,15 +0,0 @@ -def main(request, response): - user = request.auth.username - password = request.auth.password - - if user == "user" and password == "password": - return "Authentication done" - - realm = "test" - if "realm" in request.GET: - realm = request.GET.first("realm") - - return ((401, "Unauthorized"), - [("WWW-Authenticate", 'Basic realm="' + realm + '"')], - "Please login with credentials 'user' and 'password'") - diff --git a/testing/web-platform/tests/fetch/api/resources/clean-stash.py b/testing/web-platform/tests/fetch/api/resources/clean-stash.py deleted file mode 100644 index 3ae731052..000000000 --- a/testing/web-platform/tests/fetch/api/resources/clean-stash.py +++ /dev/null @@ -1,6 +0,0 @@ -def main(request, response): - token = request.GET.first("token") - if request.server.stash.take(token) is not None: - return "1" - else: - return "0" diff --git a/testing/web-platform/tests/fetch/api/resources/data.json b/testing/web-platform/tests/fetch/api/resources/data.json deleted file mode 100644 index 76519fa8c..000000000 --- a/testing/web-platform/tests/fetch/api/resources/data.json +++ /dev/null @@ -1 +0,0 @@ -{"key": "value"} diff --git a/testing/web-platform/tests/fetch/api/resources/inspect-headers.py b/testing/web-platform/tests/fetch/api/resources/inspect-headers.py deleted file mode 100644 index c4ace18ab..000000000 --- a/testing/web-platform/tests/fetch/api/resources/inspect-headers.py +++ /dev/null @@ -1,22 +0,0 @@ -def main(request, response): - headers = [] - request_headers = [] - if "headers" in request.GET: - checked_headers = request.GET.first("headers").split("|") - for header in checked_headers: - if header in request.headers: - headers.append(("x-request-" + header, request.headers.get(header, "") )) - - if "cors" in request.GET: - if "Origin" in request.headers: - headers.append(("Access-Control-Allow-Origin", request.headers.get("Origin", ""))) - else: - headers.append(("Access-Control-Allow-Origin", "*")) - headers.append(("Access-Control-Allow-Credentials", "true")) - headers.append(("Access-Control-Allow-Methods", "GET, POST, HEAD")) - exposed_headers = ["x-request-" + header for header in checked_headers] - headers.append(("Access-Control-Expose-Headers", ", ".join(exposed_headers))) - headers.append(("Access-Control-Allow-Headers", ", ".join(request.headers))) - - headers.append(("content-type", "text/plain")) - return headers, "" diff --git a/testing/web-platform/tests/fetch/api/resources/method.py b/testing/web-platform/tests/fetch/api/resources/method.py deleted file mode 100644 index db234f9d1..000000000 --- a/testing/web-platform/tests/fetch/api/resources/method.py +++ /dev/null @@ -1,11 +0,0 @@ -def main(request, response): - headers = [] - if "cors" in request.GET: - headers.append(("Access-Control-Allow-Origin", "*")) - headers.append(("Access-Control-Allow-Credentials", "true")) - headers.append(("Access-Control-Allow-Methods", "GET, POST, PUT, FOO")) - headers.append(("Access-Control-Allow-Headers", "x-test, x-foo")) - headers.append(("Access-Control-Expose-Headers", "x-request-method")) - - headers.append(("x-request-method", request.method)) - return headers, request.body diff --git a/testing/web-platform/tests/fetch/api/resources/preflight.py b/testing/web-platform/tests/fetch/api/resources/preflight.py deleted file mode 100644 index 72dceba68..000000000 --- a/testing/web-platform/tests/fetch/api/resources/preflight.py +++ /dev/null @@ -1,56 +0,0 @@ -def main(request, response): - headers = [("Content-Type", "text/plain")] - stashed_data = {'control_request_headers': "", 'preflight': "0", 'preflight_referrer': ""} - - if "origin" in request.GET: - for origin in request.GET['origin'].split(", "): - headers.append(("Access-Control-Allow-Origin", origin)) - else: - headers.append(("Access-Control-Allow-Origin", "*")) - - if request.method == "OPTIONS": - if not "Access-Control-Request-Method" in request.headers: - response.set_error(400, "No Access-Control-Request-Method header") - return "ERROR: No access-control-request-method in preflight!" - - if "control_request_headers" in request.GET: - stashed_data['control_request_headers'] = request.headers.get("Access-Control-Request-Headers", "") - - if "max_age" in request.GET: - headers.append(("Access-Control-Max-Age", request.GET['max_age'])) - - if "allow_headers" in request.GET: - headers.append(("Access-Control-Allow-Headers", request.GET['allow_headers'])) - - if "allow_methods" in request.GET: - headers.append(("Access-Control-Allow-Methods", request.GET['allow_methods'])) - - preflight_status = 200 - if "preflight_status" in request.GET: - preflight_status = int(request.GET.first("preflight_status")) - - stashed_data['preflight'] = "1" - stashed_data['preflight_referrer'] = request.headers.get("Referer", "") - request.server.stash.put(request.GET.first("token"), stashed_data) - - return preflight_status, headers, "" - - token = None - if "token" in request.GET: - token = request.GET.first("token") - data = request.server.stash.take(token) - if data: - stashed_data = data - - #use x-* headers for returning value to bodyless responses - headers.append(("Access-Control-Expose-Headers", "x-did-preflight, x-control-request-headers, x-referrer, x-preflight-referrer, x-origin")) - headers.append(("x-did-preflight", stashed_data['preflight'])) - headers.append(("x-control-request-headers", stashed_data['control_request_headers'])) - headers.append(("x-preflight-referrer", stashed_data['preflight_referrer'])) - headers.append(("x-referrer", request.headers.get("Referer", "") )) - headers.append(("x-origin", request.headers.get("Origin", "") )) - - if token: - request.server.stash.put(token, stashed_data) - - return headers, "" diff --git a/testing/web-platform/tests/fetch/api/resources/redirect.py b/testing/web-platform/tests/fetch/api/resources/redirect.py deleted file mode 100644 index 46beade1f..000000000 --- a/testing/web-platform/tests/fetch/api/resources/redirect.py +++ /dev/null @@ -1,54 +0,0 @@ -from urllib import urlencode -from urlparse import urlparse - -def main(request, response): - stashed_data = {'count': 0, 'preflight': "0"} - status = 302 - headers = [("Content-Type", "text/plain"), - ("Cache-Control", "no-cache"), - ("Pragma", "no-cache"), - ("Access-Control-Allow-Origin", "*")] - token = None - - if "token" in request.GET: - token = request.GET.first("token") - data = request.server.stash.take(token) - if data: - stashed_data = data - - if request.method == "OPTIONS": - if "allow_headers" in request.GET: - headers.append(("Access-Control-Allow-Headers", request.GET['allow_headers'])) - stashed_data['preflight'] = "1" - #Preflight is not redirected: return 200 - if not "redirect_preflight" in request.GET: - if token: - request.server.stash.put(request.GET.first("token"), stashed_data) - return 200, headers, "" - - if "redirect_status" in request.GET: - status = int(request.GET['redirect_status']) - - stashed_data['count'] += 1 - - if "location" in request.GET: - url = request.GET['location'] - scheme = urlparse(url).scheme - if scheme == "" or scheme == "http" or scheme == "https": - url += "&" if '?' in url else "?" - #keep url parameters in location - url += urlencode({key: request.GET.first(key) for key in request.GET.keys()}) - #make sure location changes during redirection loop - url += "&count=" + str(stashed_data['count']) - headers.append(("Location", url)) - - if token: - request.server.stash.put(request.GET.first("token"), stashed_data) - if "max_count" in request.GET: - max_count = int(request.GET['max_count']) - #stop redirecting and return count - if stashed_data['count'] > max_count: - # -1 because the last is not a redirection - return str(stashed_data['count'] - 1) - - return status, headers, "" diff --git a/testing/web-platform/tests/fetch/api/resources/status.py b/testing/web-platform/tests/fetch/api/resources/status.py deleted file mode 100644 index 5d72e10b2..000000000 --- a/testing/web-platform/tests/fetch/api/resources/status.py +++ /dev/null @@ -1,9 +0,0 @@ -def main(request, response): - code = int(request.GET.first("code", 200)) - text = request.GET.first("text", "OMG") - content = request.GET.first("content", "") - type = request.GET.first("type", "") - status = (code, text) - headers = [("Content-Type", type), - ("X-Request-Method", request.method)] - return status, headers, content diff --git a/testing/web-platform/tests/fetch/api/resources/top.txt b/testing/web-platform/tests/fetch/api/resources/top.txt deleted file mode 100644 index 83a3157d1..000000000 --- a/testing/web-platform/tests/fetch/api/resources/top.txt +++ /dev/null @@ -1 +0,0 @@ -top
\ No newline at end of file diff --git a/testing/web-platform/tests/fetch/api/resources/trickle.py b/testing/web-platform/tests/fetch/api/resources/trickle.py deleted file mode 100644 index 0e709445c..000000000 --- a/testing/web-platform/tests/fetch/api/resources/trickle.py +++ /dev/null @@ -1,12 +0,0 @@ -import time - -def main(request, response): - delay = float(request.GET.first("ms", 500)) / 1E3 - count = int(request.GET.first("count", 50)) - time.sleep(delay) - response.headers.set("Content-type", "text/plain") - response.write_status_headers() - time.sleep(delay); - for i in xrange(count): - response.writer.write_content("TEST_TRICKLE\n") - time.sleep(delay) diff --git a/testing/web-platform/tests/fetch/api/resources/utils.js b/testing/web-platform/tests/fetch/api/resources/utils.js deleted file mode 100644 index 86542c7bc..000000000 --- a/testing/web-platform/tests/fetch/api/resources/utils.js +++ /dev/null @@ -1,83 +0,0 @@ -var inWorker = false; -var RESOURCES_DIR = "../resources/"; - -try { - inWorker = !(self instanceof Window); -} catch (e) { - inWorker = true; -} - -function dirname(path) { - return path.replace(/\/[^\/]*$/, '/') -} - -function checkRequest(request, ExpectedValuesDict) { - for (var attribute in ExpectedValuesDict) { - switch(attribute) { - case "headers": - for (var key in ExpectedValuesDict["headers"].keys()) { - assert_equals(request["headers"].get(key), ExpectedValuesDict["headers"].get(key), - "Check headers attribute has " + key + ":" + ExpectedValuesDict["headers"].get(key)); - } - break; - - case "body": - //for checking body's content, a dedicated asyncronous/promise test should be used - assert_true(request["headers"].has("Content-Type") , "Check request has body using Content-Type header") - break; - - case "method": - case "referrer": - case "referrerPolicy": - case "credentials": - case "cache": - case "redirect": - case "integrity": - case "url": - case "destination": - assert_equals(request[attribute], ExpectedValuesDict[attribute], "Check " + attribute + " attribute") - break; - - default: - break; - } - } -} - -function stringToArray(str) { - var array = new Uint8Array(str.length); - for (var i=0, strLen = str.length; i < strLen; i++) - array[i] = str.charCodeAt(i); - return array; -} - -function validateBufferFromString(buffer, expectedValue, message) -{ - return assert_array_equals(new Uint8Array(buffer !== undefined ? buffer : []), stringToArray(expectedValue), message); -} - -function validateStreamFromString(reader, expectedValue, retrievedArrayBuffer) { - return reader.read().then(function(data) { - if (!data.done) { - assert_true(data.value instanceof Uint8Array, "Fetch ReadableStream chunks should be Uint8Array"); - var newBuffer; - if (retrievedArrayBuffer) { - newBuffer = new ArrayBuffer(data.value.length + retrievedArrayBuffer.length); - newBuffer.set(retrievedArrayBuffer, 0); - newBuffer.set(data.value, retrievedArrayBuffer.length); - } else { - newBuffer = data.value; - } - return validateStreamFromString(reader, expectedValue, newBuffer); - } - validateBufferFromString(retrievedArrayBuffer, expectedValue, "Retrieve and verify stream"); - }); -} - -// From streams tests -function delay(milliseconds) -{ - return new Promise(function(resolve) { - step_timeout(resolve, milliseconds); - }); -} |