diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /netwerk/test/mochitests/test_accept_header.sjs | |
parent | Initial commit. (diff) | |
download | thunderbird-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 'netwerk/test/mochitests/test_accept_header.sjs')
-rw-r--r-- | netwerk/test/mochitests/test_accept_header.sjs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/netwerk/test/mochitests/test_accept_header.sjs b/netwerk/test/mochitests/test_accept_header.sjs new file mode 100644 index 0000000000..6e73acd293 --- /dev/null +++ b/netwerk/test/mochitests/test_accept_header.sjs @@ -0,0 +1,62 @@ +function handleRequest(request, response) { + response.setStatusLine(request.httpVersion, "200", "OK"); + dump(`test_accept_header ${request.path}?${request.queryString}\n`); + + if (request.queryString == "worker") { + response.setHeader("Content-Type", "text/javascript", false); + response.write("postMessage(42)"); + + setState( + "data", + JSON.stringify({ type: "worker", accept: request.getHeader("Accept") }) + ); + return; + } + + if (request.queryString == "image") { + // A 1x1 PNG image. + // Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain) + const IMAGE = atob( + "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" + + "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=" + ); + + response.setHeader("Content-Type", "image/png", false); + response.write(IMAGE); + + setState( + "data", + JSON.stringify({ type: "image", accept: request.getHeader("Accept") }) + ); + return; + } + + if (request.queryString == "style") { + response.setHeader("Content-Type", "text/css", false); + response.write(""); + + setState( + "data", + JSON.stringify({ type: "style", accept: request.getHeader("Accept") }) + ); + return; + } + + if (request.queryString == "iframe") { + response.setHeader("Content-Type", "text/html", false); + response.write("<h1>Hello world!</h1>"); + + setState( + "data", + JSON.stringify({ type: "iframe", accept: request.getHeader("Accept") }) + ); + return; + } + + if (request.queryString == "get") { + response.setHeader("Content-Type", "application/json", false); + response.write(getState("data")); + + setState("data", ""); + } +} |