summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/test_nofetch_handler.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/serviceworkers/test/test_nofetch_handler.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/serviceworkers/test/test_nofetch_handler.html')
-rw-r--r--dom/serviceworkers/test/test_nofetch_handler.html57
1 files changed, 57 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/test_nofetch_handler.html b/dom/serviceworkers/test/test_nofetch_handler.html
new file mode 100644
index 0000000000..0725a68561
--- /dev/null
+++ b/dom/serviceworkers/test/test_nofetch_handler.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for Bugs 1181127 and 1325101</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="error_reporting_helpers.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
+</head>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1181127">Mozilla Bug 1181127</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1181127">Mozilla Bug 1325101</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+
+<script src="utils.js"></script>
+<script class="testbody" type="text/javascript">
+
+add_task(function setupPrefs() {
+ return SpecialPowers.pushPrefEnv({"set": [
+ ["dom.serviceWorkers.enabled", true],
+ ["dom.serviceWorkers.testing.enabled", true],
+ // Make sure the event handler during the install event persists. This ensures
+ // the reason for which the interception doesn't occur is because of the
+ // handlesFetch=false flag from ServiceWorkerInfo.
+ ["dom.serviceWorkers.idle_timeout", 299999],
+ ]});
+});
+
+var iframeg;
+function create_iframe(url) {
+ return new Promise(function(res) {
+ iframe = document.createElement('iframe');
+ iframe.src = url;
+ iframe.onload = function() { res(iframe) }
+ document.body.appendChild(iframe);
+ iframeg = iframe;
+ })
+}
+
+add_task(async function test_nofetch_worker() {
+ let registration = await navigator.serviceWorker.register(
+ "nofetch_handler_worker.js", { scope: "./nofetch_handler_worker/"} )
+ .then(swr => waitForState(swr.installing, 'activated', swr));
+
+ let iframe = await create_iframe("./nofetch_handler_worker/doesnt_exist.html");
+ ok(!iframe.contentDocument.body.innerHTML.includes("intercepted"), "Request was not intercepted.");
+
+ await SpecialPowers.popPrefEnv();
+ await registration.unregister();
+});
+</script>
+</body>
+</html>