summaryrefslogtreecommitdiffstats
path: root/uriloader/exthandler/tests/mochitest/redirect_helper.sjs
diff options
context:
space:
mode:
Diffstat (limited to 'uriloader/exthandler/tests/mochitest/redirect_helper.sjs')
-rw-r--r--uriloader/exthandler/tests/mochitest/redirect_helper.sjs30
1 files changed, 30 insertions, 0 deletions
diff --git a/uriloader/exthandler/tests/mochitest/redirect_helper.sjs b/uriloader/exthandler/tests/mochitest/redirect_helper.sjs
new file mode 100644
index 0000000000..5c1068bebb
--- /dev/null
+++ b/uriloader/exthandler/tests/mochitest/redirect_helper.sjs
@@ -0,0 +1,30 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+Cu.importGlobalProperties(["URLSearchParams"]);
+
+function handleRequest(request, response) {
+ let params = new URLSearchParams(request.queryString);
+ let uri = params.get("uri");
+ let redirectType = params.get("redirectType") || "location";
+ switch (redirectType) {
+ case "refresh":
+ response.setStatusLine(request.httpVersion, 200, "OK");
+ response.setHeader("Refresh", "0; url=" + uri);
+ break;
+
+ case "meta-refresh":
+ response.setStatusLine(request.httpVersion, 200, "OK");
+ response.setHeader("Content-Type", "text/html");
+ response.write(`<meta http-equiv="refresh" content="0; url=${uri}">`);
+ break;
+
+ case "location":
+ // fall through
+ default:
+ response.setStatusLine(request.httpVersion, 302, "Moved Temporarily");
+ response.setHeader("Location", uri);
+ }
+}