diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/html/test/sw_formSubmission.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
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.js | 36 |
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()); +}); |