From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- testing/web-platform/tests/cors/OWNERS | 5 + testing/web-platform/tests/cors/allow-headers.htm | 89 ++++++++++ testing/web-platform/tests/cors/basic.htm | 63 +++++++ .../web-platform/tests/cors/credentials-flag.htm | 129 ++++++++++++++ .../web-platform/tests/cors/late-upload-events.htm | 46 +++++ testing/web-platform/tests/cors/origin.htm | 119 +++++++++++++ .../web-platform/tests/cors/preflight-cache.htm | 140 +++++++++++++++ .../web-platform/tests/cors/redirect-origin.htm | 195 +++++++++++++++++++++ .../tests/cors/redirect-preflight-2.htm | 55 ++++++ .../web-platform/tests/cors/redirect-preflight.htm | 65 +++++++ .../web-platform/tests/cors/redirect-userinfo.htm | 110 ++++++++++++ testing/web-platform/tests/cors/remote-origin.htm | 121 +++++++++++++ .../web-platform/tests/cors/request-headers.htm | 80 +++++++++ .../web-platform/tests/cors/resources/.gitignore | 1 + .../tests/cors/resources/checkandremove.py | 6 + .../tests/cors/resources/cors-cookie.py | 21 +++ .../tests/cors/resources/cors-headers.asis | 24 +++ .../tests/cors/resources/cors-makeheader.py | 67 +++++++ .../web-platform/tests/cors/resources/preflight.py | 35 ++++ .../tests/cors/resources/remote-xhrer.html | 28 +++ .../web-platform/tests/cors/resources/status.py | 37 ++++ .../web-platform/tests/cors/response-headers.htm | 103 +++++++++++ .../web-platform/tests/cors/simple-requests.htm | 91 ++++++++++ testing/web-platform/tests/cors/status-async.htm | 114 ++++++++++++ .../web-platform/tests/cors/status-preflight.htm | 64 +++++++ testing/web-platform/tests/cors/status.htm | 80 +++++++++ testing/web-platform/tests/cors/support.js | 30 ++++ 27 files changed, 1918 insertions(+) create mode 100644 testing/web-platform/tests/cors/OWNERS create mode 100644 testing/web-platform/tests/cors/allow-headers.htm create mode 100644 testing/web-platform/tests/cors/basic.htm create mode 100644 testing/web-platform/tests/cors/credentials-flag.htm create mode 100644 testing/web-platform/tests/cors/late-upload-events.htm create mode 100644 testing/web-platform/tests/cors/origin.htm create mode 100644 testing/web-platform/tests/cors/preflight-cache.htm create mode 100644 testing/web-platform/tests/cors/redirect-origin.htm create mode 100644 testing/web-platform/tests/cors/redirect-preflight-2.htm create mode 100644 testing/web-platform/tests/cors/redirect-preflight.htm create mode 100644 testing/web-platform/tests/cors/redirect-userinfo.htm create mode 100644 testing/web-platform/tests/cors/remote-origin.htm create mode 100644 testing/web-platform/tests/cors/request-headers.htm create mode 100644 testing/web-platform/tests/cors/resources/.gitignore create mode 100644 testing/web-platform/tests/cors/resources/checkandremove.py create mode 100644 testing/web-platform/tests/cors/resources/cors-cookie.py create mode 100644 testing/web-platform/tests/cors/resources/cors-headers.asis create mode 100644 testing/web-platform/tests/cors/resources/cors-makeheader.py create mode 100644 testing/web-platform/tests/cors/resources/preflight.py create mode 100644 testing/web-platform/tests/cors/resources/remote-xhrer.html create mode 100644 testing/web-platform/tests/cors/resources/status.py create mode 100644 testing/web-platform/tests/cors/response-headers.htm create mode 100644 testing/web-platform/tests/cors/simple-requests.htm create mode 100644 testing/web-platform/tests/cors/status-async.htm create mode 100644 testing/web-platform/tests/cors/status-preflight.htm create mode 100644 testing/web-platform/tests/cors/status.htm create mode 100644 testing/web-platform/tests/cors/support.js (limited to 'testing/web-platform/tests/cors') diff --git a/testing/web-platform/tests/cors/OWNERS b/testing/web-platform/tests/cors/OWNERS new file mode 100644 index 000000000..c89797924 --- /dev/null +++ b/testing/web-platform/tests/cors/OWNERS @@ -0,0 +1,5 @@ +@sideshowbarker +@zqzhang +@Velmont +@hillbrad +@jdm diff --git a/testing/web-platform/tests/cors/allow-headers.htm b/testing/web-platform/tests/cors/allow-headers.htm new file mode 100644 index 000000000..08e00a527 --- /dev/null +++ b/testing/web-platform/tests/cors/allow-headers.htm @@ -0,0 +1,89 @@ + + +Access-Control-Allow-Headers handling + + + + +

Access-Control-Allow-Headers handling

+ +
+ + diff --git a/testing/web-platform/tests/cors/basic.htm b/testing/web-platform/tests/cors/basic.htm new file mode 100644 index 000000000..c46e9a0a1 --- /dev/null +++ b/testing/web-platform/tests/cors/basic.htm @@ -0,0 +1,63 @@ + + +Basic CORS + + + + + + +
+ + diff --git a/testing/web-platform/tests/cors/credentials-flag.htm b/testing/web-platform/tests/cors/credentials-flag.htm new file mode 100644 index 000000000..bacd43c4e --- /dev/null +++ b/testing/web-platform/tests/cors/credentials-flag.htm @@ -0,0 +1,129 @@ + +CORS - Access-Control-Allow-Credentials + + + + + + +

CORS - Access-Control-Allow-Credentials

+
+ diff --git a/testing/web-platform/tests/cors/late-upload-events.htm b/testing/web-platform/tests/cors/late-upload-events.htm new file mode 100644 index 000000000..367955aa4 --- /dev/null +++ b/testing/web-platform/tests/cors/late-upload-events.htm @@ -0,0 +1,46 @@ + + +Adding upload event listeners after send() + + + + +

Adding upload event listeners after send()

+ +
+ + diff --git a/testing/web-platform/tests/cors/origin.htm b/testing/web-platform/tests/cors/origin.htm new file mode 100644 index 000000000..a090b3340 --- /dev/null +++ b/testing/web-platform/tests/cors/origin.htm @@ -0,0 +1,119 @@ + + +Access-Control-Allow-Origin handling + + + + + + + +

Access-Control-Allow-Origin handling

+ +
+ + diff --git a/testing/web-platform/tests/cors/preflight-cache.htm b/testing/web-platform/tests/cors/preflight-cache.htm new file mode 100644 index 000000000..f84c15ab3 --- /dev/null +++ b/testing/web-platform/tests/cors/preflight-cache.htm @@ -0,0 +1,140 @@ + + +CORS - preflight cache + + + + + + + +

Preflight cache

+ +
+ diff --git a/testing/web-platform/tests/cors/redirect-origin.htm b/testing/web-platform/tests/cors/redirect-origin.htm new file mode 100644 index 000000000..5463292fa --- /dev/null +++ b/testing/web-platform/tests/cors/redirect-origin.htm @@ -0,0 +1,195 @@ + + +CORS - redirect + + + + + + +

CORS redirect handling

+ +
+ + diff --git a/testing/web-platform/tests/cors/redirect-preflight-2.htm b/testing/web-platform/tests/cors/redirect-preflight-2.htm new file mode 100644 index 000000000..fe58d90a2 --- /dev/null +++ b/testing/web-platform/tests/cors/redirect-preflight-2.htm @@ -0,0 +1,55 @@ + + +CORS - preflight after a redirect + + + + + + + +

Preflight after redirect

+ +
+ diff --git a/testing/web-platform/tests/cors/redirect-preflight.htm b/testing/web-platform/tests/cors/redirect-preflight.htm new file mode 100644 index 000000000..bb47f2cae --- /dev/null +++ b/testing/web-platform/tests/cors/redirect-preflight.htm @@ -0,0 +1,65 @@ + + +CORS - redirect with preflight + + + + + + +

Redirect with preflight

+ +
+ diff --git a/testing/web-platform/tests/cors/redirect-userinfo.htm b/testing/web-platform/tests/cors/redirect-userinfo.htm new file mode 100644 index 000000000..1775d30df --- /dev/null +++ b/testing/web-platform/tests/cors/redirect-userinfo.htm @@ -0,0 +1,110 @@ + + +CORS - redirect with userinfo + + + + + + +

CORS userinfo redirect handling

+ +
+ + diff --git a/testing/web-platform/tests/cors/remote-origin.htm b/testing/web-platform/tests/cors/remote-origin.htm new file mode 100644 index 000000000..072677516 --- /dev/null +++ b/testing/web-platform/tests/cors/remote-origin.htm @@ -0,0 +1,121 @@ + + +Access-Control-Allow-Origin handling + + + + +

Access-Control-Allow-Origin handling

+ +
+ + diff --git a/testing/web-platform/tests/cors/request-headers.htm b/testing/web-platform/tests/cors/request-headers.htm new file mode 100644 index 000000000..8adaeb4f8 --- /dev/null +++ b/testing/web-platform/tests/cors/request-headers.htm @@ -0,0 +1,80 @@ + + +CORS - request headers - Access-Control-Allow-Headers + + + + + + +

Request headers

+
+ diff --git a/testing/web-platform/tests/cors/resources/.gitignore b/testing/web-platform/tests/cors/resources/.gitignore new file mode 100644 index 000000000..7b987d036 --- /dev/null +++ b/testing/web-platform/tests/cors/resources/.gitignore @@ -0,0 +1 @@ +logs.txt diff --git a/testing/web-platform/tests/cors/resources/checkandremove.py b/testing/web-platform/tests/cors/resources/checkandremove.py new file mode 100644 index 000000000..f713d990a --- /dev/null +++ b/testing/web-platform/tests/cors/resources/checkandremove.py @@ -0,0 +1,6 @@ +def main(request, response): + token = request.GET.first("token") + if request.server.stash.remove(token) is not None: + return "1" + else: + return "0" diff --git a/testing/web-platform/tests/cors/resources/cors-cookie.py b/testing/web-platform/tests/cors/resources/cors-cookie.py new file mode 100644 index 000000000..76fa6c165 --- /dev/null +++ b/testing/web-platform/tests/cors/resources/cors-cookie.py @@ -0,0 +1,21 @@ + +def main(request, response): + origin = request.GET.first("origin", request.headers["origin"]) + credentials = request.GET.first("credentials", "true") + + headers = [("Content-Type", "text/plain")] + if origin != 'none': + headers.append(("Access-Control-Allow-Origin", origin)) + if credentials != 'none': + headers.append(("Access-Control-Allow-Credentials", credentials)) + + ident = request.GET.first('ident', 'test') + + if ident in request.cookies: + body = request.cookies[ident].value + response.delete_cookie(ident) + else: + response.set_cookie(ident, "COOKIE"); + body = "NO_COOKIE" + + return headers, body diff --git a/testing/web-platform/tests/cors/resources/cors-headers.asis b/testing/web-platform/tests/cors/resources/cors-headers.asis new file mode 100644 index 000000000..ce21245f1 --- /dev/null +++ b/testing/web-platform/tests/cors/resources/cors-headers.asis @@ -0,0 +1,24 @@ +HTTP/1.1 200 OK +Access-Control-Allow-Origin: * +Access-Control-Expose-Headers: X-Custom-Header, X-Custom-Header-Empty, X-Custom-Header-Comma, X-Custom-Header-Bytes +Access-Control-Expose-Headers: X-Second-Expose +Access-Control-Expose-Headers: Date +Content-Type: text/plain +X-Custom-Header: test +X-Custom-Header: test +Set-Cookie: test1=t1;max-age=2 +Set-Cookie2: test2=t2;Max-Age=2 +X-Custom-Header-Empty: +X-Custom-Header-Comma: 1 +X-Custom-Header-Comma: 2 +X-Custom-Header-Bytes: … +X-Nonexposed: unicorn +X-Second-Expose: flyingpig +Cache-Control: no-cache +Content-Language: nn +Expires: Thu, 01 Dec 1994 16:00:00 GMT +Last-Modified: Thu, 01 Dec 1994 10:00:00 GMT +Pragma: no-cache +Date: Wed, 22 Oct 2013 10:00:00 GMT + +TEST diff --git a/testing/web-platform/tests/cors/resources/cors-makeheader.py b/testing/web-platform/tests/cors/resources/cors-makeheader.py new file mode 100644 index 000000000..eab35eedf --- /dev/null +++ b/testing/web-platform/tests/cors/resources/cors-makeheader.py @@ -0,0 +1,67 @@ +import json + +def main(request, response): + origin = request.GET.first("origin", request.headers.get('origin')) + + if "check" in request.GET: + token = request.GET.first("token") + value = request.server.stash.take(token) + if value is not None: + if request.GET.first("check", None) == "keep": + request.server.stash.put(token, value) + body = "1" + else: + body = "0" + return [("Content-Type", "text/plain")], body + + + if origin != 'none': + response.headers.set("Access-Control-Allow-Origin", origin) + if 'origin2' in request.GET: + response.headers.append("Access-Control-Allow-Origin", request.GET.first('origin2')) + + #Preflight + if 'headers' in request.GET: + response.headers.set("Access-Control-Allow-Headers", request.GET.first('headers')) + if 'credentials' in request.GET: + response.headers.set("Access-Control-Allow-Credentials", request.GET.first('credentials')) + if 'methods' in request.GET: + response.headers.set("Access-Control-Allow-Methods", request.GET.first('methods')) + + code_raw = request.GET.first('code', None) + if code_raw: + code = int(code_raw) + else: + code = None + if request.method == 'OPTIONS': + #Override the response code if we're in a preflight and it's asked + if 'preflight' in request.GET: + code = int(request.GET.first('preflight')) + + #Log that the preflight actually happened if we have an ident + if 'token' in request.GET: + request.server.stash.put(request.GET['token'], True) + + if 'location' in request.GET: + if code is None: + code = 302 + + if code >= 300 and code < 400: + response.headers.set("Location", request.GET.first('location')) + + headers = {} + for name, values in request.headers.iteritems(): + if len(values) == 1: + headers[name] = values[0] + else: + #I have no idea, really + headers[name] = values + + headers['get_value'] = request.GET.first('get_value', '') + + body = json.dumps(headers) + + if code: + return (code, "StatusText"), [], body + else: + return body diff --git a/testing/web-platform/tests/cors/resources/preflight.py b/testing/web-platform/tests/cors/resources/preflight.py new file mode 100644 index 000000000..978e97c5d --- /dev/null +++ b/testing/web-platform/tests/cors/resources/preflight.py @@ -0,0 +1,35 @@ +def main(request, response): + headers = [("Content-Type", "text/plain")] + + if "check" in request.GET: + token = request.GET.first("token") + value = request.server.stash.take(token) + if value == None: + body = "0" + else: + if request.GET.first("check", None) == "keep": + request.server.stash.put(token, value) + body = "1" + + return headers, body + + 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!" + + headers.append(("Access-Control-Allow-Methods", + request.headers['Access-Control-Request-Method'])) + + if "max_age" in request.GET: + headers.append(("Access-Control-Max-Age", request.GET['max_age'])) + + if "token" in request.GET: + request.server.stash.put(request.GET.first("token"), 1) + + headers.append(("Access-Control-Allow-Origin", "*")) + headers.append(("Access-Control-Allow-Headers", "x-print")) + + body = request.headers.get("x-print", "NO") + + return headers, body diff --git a/testing/web-platform/tests/cors/resources/remote-xhrer.html b/testing/web-platform/tests/cors/resources/remote-xhrer.html new file mode 100644 index 000000000..73a7cb444 --- /dev/null +++ b/testing/web-platform/tests/cors/resources/remote-xhrer.html @@ -0,0 +1,28 @@ + +Child helper + + + +The remote window diff --git a/testing/web-platform/tests/cors/resources/status.py b/testing/web-platform/tests/cors/resources/status.py new file mode 100644 index 000000000..8d441f06e --- /dev/null +++ b/testing/web-platform/tests/cors/resources/status.py @@ -0,0 +1,37 @@ +def main(request, response): + response.headers.set("Access-Control-Allow-Origin", request.headers.get("origin") ) + response.headers.set("Access-Control-Expose-Headers", "X-Request-Method") + + if request.method == 'OPTIONS': + response.headers.set("Access-Control-Allow-Methods", "GET, CHICKEN, HEAD, POST, PUT") + + if 'headers' in request.GET: + response.headers.set("Access-Control-Allow-Headers", request.GET.first('headers')) + + response.headers.set("X-Request-Method", request.method) + + response.headers.set("X-A-C-Request-Method", request.headers.get("Access-Control-Request-Method", "")); + + + #This should reasonably work for most response codes. + try: + code = int(request.GET.first("code", 200)) + except ValueError: + code = 200 + + text = request.GET.first("text", "OMG") + + if request.method == "OPTIONS" and "preflight" in request.GET: + try: + code = int(request.GET.first('preflight')) + except KeyError, ValueError: + pass + + status = code, text + + if "type" in request.GET: + response.headers.set("Content-Type", request.GET.first('type')) + + body = request.GET.first('content', "") + + return status, [], body diff --git a/testing/web-platform/tests/cors/response-headers.htm b/testing/web-platform/tests/cors/response-headers.htm new file mode 100644 index 000000000..d4d7cf231 --- /dev/null +++ b/testing/web-platform/tests/cors/response-headers.htm @@ -0,0 +1,103 @@ + + +CORS - Response headers + + + + + + +

Response headers

+
+ diff --git a/testing/web-platform/tests/cors/simple-requests.htm b/testing/web-platform/tests/cors/simple-requests.htm new file mode 100644 index 000000000..441a8c1ac --- /dev/null +++ b/testing/web-platform/tests/cors/simple-requests.htm @@ -0,0 +1,91 @@ + + +CORS - simple requests + + + + + + + +

Simple requests

+

Simple requests shouldn't trigger preflight

+ +
+ diff --git a/testing/web-platform/tests/cors/status-async.htm b/testing/web-platform/tests/cors/status-async.htm new file mode 100644 index 000000000..3573ee88f --- /dev/null +++ b/testing/web-platform/tests/cors/status-async.htm @@ -0,0 +1,114 @@ + + +CORS - status + + + + + + + +

Status returned

+ +
+ diff --git a/testing/web-platform/tests/cors/status-preflight.htm b/testing/web-platform/tests/cors/status-preflight.htm new file mode 100644 index 000000000..54b9e8e84 --- /dev/null +++ b/testing/web-platform/tests/cors/status-preflight.htm @@ -0,0 +1,64 @@ + + +CORS - status after preflight + + + + + + +

Status after preflight

+ +
+ diff --git a/testing/web-platform/tests/cors/status.htm b/testing/web-platform/tests/cors/status.htm new file mode 100644 index 000000000..4997ddab0 --- /dev/null +++ b/testing/web-platform/tests/cors/status.htm @@ -0,0 +1,80 @@ + + +CORS status + + + + + + + +

The returned status code in different scenarios

+ + + +
+   allowed  preflight  response  | status |
+   -------  ---------  --------  | ------ |
+ 1      no          x       400  |      0 |
+ 2      no        200         x  |      0 |
+ 3     yes          x       400  |    400 |
+ 4     yes        200       400  |    400 |
+ 5     yes        400         x  |      0 |
+
+ +
+ diff --git a/testing/web-platform/tests/cors/support.js b/testing/web-platform/tests/cors/support.js new file mode 100644 index 000000000..551eb70d0 --- /dev/null +++ b/testing/web-platform/tests/cors/support.js @@ -0,0 +1,30 @@ +// For ignoring exception names (just for testing) +/* +_real_assert_throws = assert_throws; +function assert_throws(d, func, desc) { + try { + func(); + } catch(e) { + return true; + } + assert_unreached("Didn't throw!"); +} +*/ + +function dirname(path) { + return path.replace(/\/[^\/]*$/, '/') +} + +/* This subdomain should point to this same location */ +var SUBDOMAIN = 'www1' +var SUBDOMAIN2 = 'www2' +var PORT = {{ports[http][1]}} +//XXX HTTPS +var PORTS = {{ports[https][0]}} + +/* Changes http://example.com/abc/def/cool.htm to http://www1.example.com/abc/def/ */ +var CROSSDOMAIN = dirname(location.href) + .replace('://', '://' + SUBDOMAIN + '.') +var REMOTE_HOST = SUBDOMAIN + '.' + location.host +var REMOTE_PROTOCOL = location.protocol +var REMOTE_ORIGIN = REMOTE_PROTOCOL + '//' + REMOTE_HOST -- cgit v1.2.3