summaryrefslogtreecommitdiffstats
path: root/dom/html/test/sw_formSubmission.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/html/test/sw_formSubmission.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/test/sw_formSubmission.js')
-rw-r--r--dom/html/test/sw_formSubmission.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/dom/html/test/sw_formSubmission.js b/dom/html/test/sw_formSubmission.js
new file mode 100644
index 0000000000..ad997a4831
--- /dev/null
+++ b/dom/html/test/sw_formSubmission.js
@@ -0,0 +1,36 @@
+/**
+ * We are used by test_formSubmission.html to immediately activate and start
+ * controlling its page. We operate in 3 modes, conveyed via ?MODE appended to
+ * our URL.
+ *
+ * - "no-fetch": Don't register a fetch listener so that the optimized fetch
+ * event bypass happens.
+ * - "reset-fetch": Do register a fetch listener, reset every interception.
+ * - "proxy-fetch": Do register a fetch listener, resolve every interception
+ * with fetch(event.request).
+ */
+
+const mode = location.search.slice(1);
+
+// Fetch handling.
+if (mode !== "no-fetch") {
+ addEventListener("fetch", function(event) {
+ if (mode === "reset-fetch") {
+ // Don't invoke respondWith, resetting the interception.
+ return;
+ } else if (mode === "proxy-fetch") {
+ // Per the spec, there's an automatic waitUntil() on this too.
+ event.respondWith(fetch(event.request));
+ return;
+ }
+ });
+}
+
+// Go straight to activation, bypassing waiting.
+addEventListener("install", function(event) {
+ event.waitUntil(skipWaiting());
+});
+// Control the test document ASAP.
+addEventListener("activate", function(event) {
+ event.waitUntil(clients.claim());
+});