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/serviceworkers/test/test_enabled_pref.html | |
parent | Initial commit. (diff) | |
download | firefox-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_enabled_pref.html')
-rw-r--r-- | dom/serviceworkers/test/test_enabled_pref.html | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/test_enabled_pref.html b/dom/serviceworkers/test/test_enabled_pref.html new file mode 100644 index 0000000000..b821fdaf5a --- /dev/null +++ b/dom/serviceworkers/test/test_enabled_pref.html @@ -0,0 +1,55 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Bug 1645054 - test dom.serviceWorkers.enabled preference</title> +</head> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="utils.js"></script> +<script> + + 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); + }); + } + + async function do_fetch(pref) { + await SpecialPowers.pushPrefEnv({ set: [pref] }); + + let iframe = await create_iframe("./pref/fetch_nonexistent_file.html"); + let status = await iframe.contentWindow.fetch_status(); + + await SpecialPowers.popPrefEnv(); + return status; + } + + add_task(async () => { + await SpecialPowers.pushPrefEnv({ + set: [['dom.serviceWorkers.testing.enabled', true]] + }); + + let reg = await navigator.serviceWorker.register( + 'pref/intercept_nonexistent_file_sw.js'); + await waitForState(reg.installing, 'activated'); + + let status; + + status = await do_fetch(['dom.serviceWorkers.enabled', true]); + is(status, 200, 'SW enabled'); + + status = await do_fetch(['dom.serviceWorkers.enabled', false]); + is(status, 404, 'SW disabled'); + + status = await do_fetch(['dom.serviceWorkers.enabled', true]); + is(status, 200, 'SW enabled again'); + + await reg.unregister(); + }); + +</script> +<body> +</body> +</html> |