diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper/resources/executor-window.py')
-rw-r--r-- | testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper/resources/executor-window.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper/resources/executor-window.py b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper/resources/executor-window.py new file mode 100644 index 0000000000..1a660100b9 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper/resources/executor-window.py @@ -0,0 +1,40 @@ +import html +import json +from urllib import parse + +def main(request, response): + initRequestHeaders = "" + for header_name in request.headers.keys(): + for header_value in request.headers.get_list(header_name): + js_name = json.dumps(header_name.lower().decode("utf-8")) + js_value = json.dumps(header_value.decode("utf-8")) + initRequestHeaders += f"window.__requestHeaders.append({js_name}, {js_value});\n" + if (b"status" in request.GET): + status = int(request.GET.first(b"status")) + else: + status = 200 + query = parse.parse_qs(request.url_parts.query) + scripts = [] + for script in query.get("script", []): + scripts.append(f"<script src='{html.escape(script)}'></script>") + scripts_s = "\n".join(scripts) + + uuid = query.get("uuid")[0] + + start_on = query.get("startOn") + start_on_s = f"'{start_on[0]}'" if start_on else "null" + + return (status, [("Content-Type", "text/html")], f""" +<!DOCTYPE HTML> +<script src="/common/dispatcher/dispatcher.js"></script> +<script src="./executor-common.js"></script> +<script src="./executor-window.js"></script> + +{scripts_s} +<body> +<script> +window.__requestHeaders = new Headers(); +{initRequestHeaders} +requestExecutor("{uuid}", {start_on_s}); +</script> +""") |