summaryrefslogtreecommitdiffstats
path: root/dom/xhr/tests/worker_xhr_headers_server.sjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/xhr/tests/worker_xhr_headers_server.sjs
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/xhr/tests/worker_xhr_headers_server.sjs')
-rw-r--r--dom/xhr/tests/worker_xhr_headers_server.sjs69
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/xhr/tests/worker_xhr_headers_server.sjs b/dom/xhr/tests/worker_xhr_headers_server.sjs
new file mode 100644
index 0000000000..c2a944f6ef
--- /dev/null
+++ b/dom/xhr/tests/worker_xhr_headers_server.sjs
@@ -0,0 +1,69 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+"use strict";
+
+function handleRequest(request, response) {
+ switch (request.method) {
+ case "POST":
+ try {
+ var optionsHost = request.getHeader("options-host");
+ } catch (e) {}
+
+ var headerFound = false;
+ if (optionsHost) {
+ setState("postHost", request.host);
+ setState("optionsHost", optionsHost);
+ headerFound = true;
+ }
+
+ try {
+ var emptyHeader = "nada" + request.getHeader("empty");
+ } catch (e) {}
+
+ if (emptyHeader && emptyHeader == "nada") {
+ setState("emptyHeader", "nada");
+ headerFound = true;
+ }
+ if (headerFound) {
+ return;
+ }
+ break;
+
+ case "OPTIONS":
+ if (getState("optionsHost") == request.host) {
+ try {
+ var optionsHeader = request.getHeader(
+ "Access-Control-Request-Headers"
+ );
+ } catch (e) {}
+ setState("optionsHeader", "'" + optionsHeader + "'");
+ }
+ break;
+
+ case "GET":
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "text/plain", false);
+
+ if (
+ getState("postHost") == request.host &&
+ getState("emptyHeader") == "nada"
+ ) {
+ var result = getState("optionsHeader");
+ if (result) {
+ response.write(
+ "Success: expected OPTIONS request with " + result + " header"
+ );
+ } else if (getState("badGet") == 1) {
+ response.write("Error: unexpected GET request");
+ }
+ } else {
+ setState("badGet", "1");
+ response.write("Error: this response should never be seen");
+ }
+ return;
+ }
+
+ response.setStatusLine(request.httpVersion, 501, "Not Implemented");
+}