diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/extensions/test/xpcshell/test_change_backgroundServiceWorker_enabled_pref_false.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | toolkit/components/extensions/test/xpcshell/test_change_backgroundServiceWorker_enabled_pref_false.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/toolkit/components/extensions/test/xpcshell/test_change_backgroundServiceWorker_enabled_pref_false.js b/toolkit/components/extensions/test/xpcshell/test_change_backgroundServiceWorker_enabled_pref_false.js new file mode 100644 index 0000000000..0be36788c1 --- /dev/null +++ b/toolkit/components/extensions/test/xpcshell/test_change_backgroundServiceWorker_enabled_pref_false.js @@ -0,0 +1,47 @@ +"use strict"; + +// extensions.backgroundServiceWorker.enabled=false is set in the test manifest +// because there is no guarantee that the pref value set at runtime takes effect +// due to the pref being declared "mirror: once". The value of this pref is +// frozen upon the first access to any "mirror:once" pref, and we can therefore +// not assume the pref value to be mutable at runtime. +const PREF_EXT_SW_ENABLED = "extensions.backgroundServiceWorker.enabled"; + +add_task(async function test_backgroundServiceWorkerEnabled() { + // Sanity check: + Assert.equal( + Services.prefs.getBoolPref(PREF_EXT_SW_ENABLED), + false, + "Pref value should be false" + ); + Assert.equal( + WebExtensionPolicy.backgroundServiceWorkerEnabled, + false, + "backgroundServiceWorkerEnabled should be false" + ); + + if (AppConstants.MOZ_WEBEXT_WEBIDL_ENABLED) { + Assert.ok( + !Services.prefs.prefIsLocked(PREF_EXT_SW_ENABLED), + "Pref should be not locked when MOZ_WEBEXT_WEBIDL_ENABLED is true" + ); + } else { + Assert.ok( + Services.prefs.prefIsLocked(PREF_EXT_SW_ENABLED), + "Pref should be locked when MOZ_WEBEXT_WEBIDL_ENABLED is false" + ); + Services.prefs.unlockPref(PREF_EXT_SW_ENABLED); + } + + // Flip pref and test result. + Services.prefs.setBoolPref(PREF_EXT_SW_ENABLED, true); + Assert.ok( + Services.prefs.getBoolPref(PREF_EXT_SW_ENABLED), + "pref can change after setting it" + ); + Assert.equal( + WebExtensionPolicy.backgroundServiceWorkerEnabled, + false, + "backgroundServiceWorkerEnabled is still false despite the pref flip" + ); +}); |