summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/eventsource/resources
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/eventsource/resources
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/eventsource/resources')
-rw-r--r--testing/web-platform/tests/eventsource/resources/accept.event_stream2
-rw-r--r--testing/web-platform/tests/eventsource/resources/cache-control.event_stream2
-rw-r--r--testing/web-platform/tests/eventsource/resources/cors-cookie.py31
-rw-r--r--testing/web-platform/tests/eventsource/resources/cors.py34
-rw-r--r--testing/web-platform/tests/eventsource/resources/init.htm9
-rw-r--r--testing/web-platform/tests/eventsource/resources/last-event-id.py11
-rw-r--r--testing/web-platform/tests/eventsource/resources/message.py14
-rw-r--r--testing/web-platform/tests/eventsource/resources/message2.py35
-rw-r--r--testing/web-platform/tests/eventsource/resources/reconnect-fail.py24
-rw-r--r--testing/web-platform/tests/eventsource/resources/status-error.py4
-rw-r--r--testing/web-platform/tests/eventsource/resources/status-reconnect.py21
11 files changed, 187 insertions, 0 deletions
diff --git a/testing/web-platform/tests/eventsource/resources/accept.event_stream b/testing/web-platform/tests/eventsource/resources/accept.event_stream
new file mode 100644
index 000000000..24da54826
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/accept.event_stream
@@ -0,0 +1,2 @@
+data: {{headers[accept]}}
+
diff --git a/testing/web-platform/tests/eventsource/resources/cache-control.event_stream b/testing/web-platform/tests/eventsource/resources/cache-control.event_stream
new file mode 100644
index 000000000..aa9f2d6c0
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/cache-control.event_stream
@@ -0,0 +1,2 @@
+data: {{headers[cache-control]}}
+
diff --git a/testing/web-platform/tests/eventsource/resources/cors-cookie.py b/testing/web-platform/tests/eventsource/resources/cors-cookie.py
new file mode 100644
index 000000000..7deaff498
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/cors-cookie.py
@@ -0,0 +1,31 @@
+from datetime import datetime
+
+def main(request, response):
+ last_event_id = request.headers.get("Last-Event-Id", "")
+ ident = request.GET.first('ident', "test")
+ cookie = "COOKIE" if ident in request.cookies else "NO_COOKIE"
+ origin = request.GET.first('origin', request.headers["origin"])
+ credentials = request.GET.first('credentials', 'true')
+
+ headers = []
+
+ if origin != 'none':
+ headers.append(("Access-Control-Allow-Origin", origin));
+
+ if credentials != 'none':
+ headers.append(("Access-Control-Allow-Credentials", credentials));
+
+ if last_event_id == '':
+ headers.append(("Content-Type", "text/event-stream"))
+ response.set_cookie(ident, "COOKIE")
+ data = "id: 1\nretry: 200\ndata: first %s\n\n" % cookie
+ elif last_event_id == '1':
+ headers.append(("Content-Type", "text/event-stream"))
+ long_long_time_ago = datetime.now().replace(year=2001, month=7, day=27)
+ response.set_cookie(ident, "COOKIE", expires=long_long_time_ago)
+ data = "id: 2\ndata: second %s\n\n" % cookie
+ else:
+ headers.append(("Content-Type", "stop"))
+ data = "data: " + last_event_id + cookie + "\n\n";
+
+ return headers, data
diff --git a/testing/web-platform/tests/eventsource/resources/cors.py b/testing/web-platform/tests/eventsource/resources/cors.py
new file mode 100644
index 000000000..d01596c83
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/cors.py
@@ -0,0 +1,34 @@
+import os
+from wptserve import pipes
+
+def run_other(request, response, path):
+ #This is a terrible hack
+ environ = {"__file__": path}
+ execfile(path, environ, environ)
+ rv = environ["main"](request, response)
+ return rv
+
+def main(request, response):
+ origin = request.GET.first("origin", request.headers["origin"])
+ credentials = request.GET.first("credentials", "true")
+
+ response.headers.update([("Access-Control-Allow-Origin", origin),
+ ("Access-Control-Allow-Credentials", credentials)])
+
+ handler = request.GET.first('run')
+ if handler in ["status-reconnect",
+ "message",
+ "redirect",
+ "cache-control"]:
+ if handler == "cache-control":
+ response.headers.set("Content-Type", "text/event-stream")
+ rv = open(os.path.join(request.doc_root, "eventsource", "resources", "cache-control.event_stream"), "r").read()
+ response.content = rv
+ pipes.sub(request, response)
+ return
+ elif handler == "redirect":
+ return run_other(request, response, os.path.join(request.doc_root, "common", "redirect.py"))
+ else:
+ return run_other(request, response, os.path.join(os.path.split(__file__)[0], handler + ".py"))
+ else:
+ return
diff --git a/testing/web-platform/tests/eventsource/resources/init.htm b/testing/web-platform/tests/eventsource/resources/init.htm
new file mode 100644
index 000000000..7c56d8880
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/init.htm
@@ -0,0 +1,9 @@
+<!doctype html>
+<html>
+ <head>
+ <title>support init file</title>
+ </head>
+ <body>
+ <script> parent.init() </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/eventsource/resources/last-event-id.py b/testing/web-platform/tests/eventsource/resources/last-event-id.py
new file mode 100644
index 000000000..4306fbaa3
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/last-event-id.py
@@ -0,0 +1,11 @@
+ # -*- coding: utf-8 -*-
+
+def main(request, response):
+ response.headers.set("Content-Type", "text/event-stream")
+ last_event_id = request.headers.get('Last-Event-ID', None)
+
+ if(last_event_id):
+ return "data: " + last_event_id + "\n\n"
+ else:
+ return "id: …\nretry: 200\ndata: hello\n\n"
+
diff --git a/testing/web-platform/tests/eventsource/resources/message.py b/testing/web-platform/tests/eventsource/resources/message.py
new file mode 100644
index 000000000..6d04b1fbe
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/message.py
@@ -0,0 +1,14 @@
+import time
+
+def main(request, response):
+ mime = request.GET.first("mime", "text/event-stream")
+ message = request.GET.first("message", "data: data");
+ newline = "" if request.GET.first("newline", None) == "none" else "\n\n";
+ sleep = int(request.GET.first("sleep", "0"))
+
+ headers = [("Content-Type", mime)]
+ body = message + newline + "\n"
+ if sleep != 0:
+ time.sleep(sleep/1000)
+
+ return headers, body
diff --git a/testing/web-platform/tests/eventsource/resources/message2.py b/testing/web-platform/tests/eventsource/resources/message2.py
new file mode 100644
index 000000000..ce339d927
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/message2.py
@@ -0,0 +1,35 @@
+import time
+
+def main(request, response):
+ response.headers.set('Content-Type', 'text/event-stream')
+ response.headers.set('Cache-Control', 'no-cache')
+
+ response.explicit_flush = True
+ response.write_status_headers()
+
+ while True:
+ response.writer.write("data:msg")
+ response.writer.write("\n")
+ response.writer.write("data: msg")
+ response.writer.write("\n\n")
+
+ response.writer.write(":")
+ response.writer.write("\n")
+
+ response.writer.write("falsefield:msg")
+ response.writer.write("\n\n")
+
+ response.writer.write("falsefield:msg")
+ response.writer.write("\n")
+
+ response.writer.write("Data:data")
+ response.writer.write("\n\n")
+
+ response.writer.write("data")
+ response.writer.write("\n\n")
+
+ response.writer.write("data:end")
+ response.writer.write("\n\n")
+
+ response.writer.flush()
+ time.sleep(2)
diff --git a/testing/web-platform/tests/eventsource/resources/reconnect-fail.py b/testing/web-platform/tests/eventsource/resources/reconnect-fail.py
new file mode 100644
index 000000000..80a247d59
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/reconnect-fail.py
@@ -0,0 +1,24 @@
+def main(request, response):
+ name = "recon_fail_" + request.GET.first("id")
+
+ headers = [("Content-Type", "text/event-stream")]
+ cookie = request.cookies.first(name, None)
+ state = cookie.value if cookie is not None else None
+
+ if state == 'opened':
+ status = (200, "RECONNECT")
+ response.set_cookie(name, "reconnected");
+ body = "data: reconnected\n\n";
+
+ elif state == 'reconnected':
+ status = (204, "NO CONTENT (CLOSE)")
+ response.delete_cookie(name);
+ body = "data: closed\n\n" # Will never get through
+
+ else:
+ status = (200, "OPEN");
+ response.set_cookie(name, "opened");
+ body = "retry: 2\ndata: opened\n\n";
+
+ return status, headers, body
+
diff --git a/testing/web-platform/tests/eventsource/resources/status-error.py b/testing/web-platform/tests/eventsource/resources/status-error.py
new file mode 100644
index 000000000..8aa230c72
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/status-error.py
@@ -0,0 +1,4 @@
+def main(request, response):
+ status = (request.GET.first("status", "404"), "HAHAHAHA")
+ headers = [("Content-Type", "text/event-stream")]
+ return status, headers, "data: data\n\n"
diff --git a/testing/web-platform/tests/eventsource/resources/status-reconnect.py b/testing/web-platform/tests/eventsource/resources/status-reconnect.py
new file mode 100644
index 000000000..16c6502e3
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/resources/status-reconnect.py
@@ -0,0 +1,21 @@
+def main(request, response):
+ status_code = request.GET.first("status", "204")
+ name = request.GET.first("id", status_code)
+
+ headers = [("Content-Type", "text/event-stream")]
+
+ cookie_name = "request" + name
+
+ if request.cookies.first(cookie_name, "") == status_code:
+ status = 200
+ response.delete_cookie(cookie_name)
+ body = "data: data\n\n"
+ else:
+ response.set_cookie(cookie_name, status_code);
+ status = (int(status_code), "TEST")
+ body = "retry: 2\n"
+ if "ok_first" in request.GET:
+ body += "data: ok\n\n"
+
+ return status, headers, body
+