summaryrefslogtreecommitdiffstats
path: root/netwerk/test/mochitests/web_packaged_app.sjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /netwerk/test/mochitests/web_packaged_app.sjs
parentInitial commit. (diff)
downloadfirefox-upstream/124.0.1.tar.xz
firefox-upstream/124.0.1.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/mochitests/web_packaged_app.sjs')
-rw-r--r--netwerk/test/mochitests/web_packaged_app.sjs47
1 files changed, 47 insertions, 0 deletions
diff --git a/netwerk/test/mochitests/web_packaged_app.sjs b/netwerk/test/mochitests/web_packaged_app.sjs
new file mode 100644
index 0000000000..772b8a0835
--- /dev/null
+++ b/netwerk/test/mochitests/web_packaged_app.sjs
@@ -0,0 +1,47 @@
+function handleRequest(request, response) {
+ response.setHeader("Content-Type", "application/package", false);
+ response.write(octetStreamData.getData());
+}
+
+// The package content
+// getData formats it as described at http://www.w3.org/TR/web-packaging/#streamable-package-format
+var octetStreamData = {
+ content: [
+ {
+ headers: ["Content-Location: /index.html", "Content-Type: text/html"],
+ data: "<html>\r\n <head>\r\n <script> alert('OK: hello'); alert('DONE'); </script>\r\n</head>\r\n Web Packaged App Index\r\n</html>\r\n",
+ type: "text/html",
+ },
+ {
+ headers: [
+ "Content-Location: /scripts/app.js",
+ "Content-Type: text/javascript",
+ ],
+ data: "module Math from '/scripts/helpers/math.js';\r\n...\r\n",
+ type: "text/javascript",
+ },
+ {
+ headers: [
+ "Content-Location: /scripts/helpers/math.js",
+ "Content-Type: text/javascript",
+ ],
+ data: "export function sum(nums) { ... }\r\n...\r\n",
+ type: "text/javascript",
+ },
+ ],
+ token: "gc0pJq0M:08jU534c0p",
+ getData() {
+ var str = "";
+ for (var i in this.content) {
+ str += "--" + this.token + "\r\n";
+ for (var j in this.content[i].headers) {
+ str += this.content[i].headers[j] + "\r\n";
+ }
+ str += "\r\n";
+ str += this.content[i].data + "\r\n";
+ }
+
+ str += "--" + this.token + "--";
+ return str;
+ },
+};