summaryrefslogtreecommitdiffstats
path: root/dom/html/test/sw_formSubmission.js
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/html/test/sw_formSubmission.js
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/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..e7b4a7872c
--- /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());
+});