summaryrefslogtreecommitdiffstats
path: root/toolkit/components/aboutconfig/test/browser/browser_locked.js
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 /toolkit/components/aboutconfig/test/browser/browser_locked.js
parentInitial commit. (diff)
downloadfirefox-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 'toolkit/components/aboutconfig/test/browser/browser_locked.js')
-rw-r--r--toolkit/components/aboutconfig/test/browser/browser_locked.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/toolkit/components/aboutconfig/test/browser/browser_locked.js b/toolkit/components/aboutconfig/test/browser/browser_locked.js
new file mode 100644
index 0000000000..6b06f22218
--- /dev/null
+++ b/toolkit/components/aboutconfig/test/browser/browser_locked.js
@@ -0,0 +1,54 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const PREF_STRING_NO_DEFAULT = "test.aboutconfig.a";
+
+add_setup(async function () {
+ await SpecialPowers.pushPrefEnv({
+ set: [[PREF_STRING_NO_DEFAULT, "some value"]],
+ });
+});
+
+add_task(async function test_locked() {
+ registerCleanupFunction(() => {
+ Services.prefs.unlockPref(PREF_STRING_DEFAULT_NOTEMPTY);
+ Services.prefs.unlockPref(PREF_BOOLEAN_DEFAULT_TRUE);
+ Services.prefs.unlockPref(PREF_STRING_NO_DEFAULT);
+ });
+
+ Services.prefs.lockPref(PREF_STRING_DEFAULT_NOTEMPTY);
+ Services.prefs.lockPref(PREF_BOOLEAN_DEFAULT_TRUE);
+ Services.prefs.lockPref(PREF_STRING_NO_DEFAULT);
+
+ await AboutConfigTest.withNewTab(async function () {
+ // Test locked default string pref.
+ let lockedPref = this.getRow(PREF_STRING_DEFAULT_NOTEMPTY);
+ Assert.ok(lockedPref.hasClass("locked"));
+ Assert.equal(lockedPref.value, PREF_STRING_DEFAULT_NOTEMPTY_VALUE);
+ Assert.ok(lockedPref.editColumnButton.classList.contains("button-edit"));
+ Assert.ok(lockedPref.editColumnButton.disabled);
+
+ // Test locked default boolean pref.
+ lockedPref = this.getRow(PREF_BOOLEAN_DEFAULT_TRUE);
+ Assert.ok(lockedPref.hasClass("locked"));
+ Assert.equal(lockedPref.value, "true");
+ Assert.ok(lockedPref.editColumnButton.classList.contains("button-toggle"));
+ Assert.ok(lockedPref.editColumnButton.disabled);
+
+ // Test locked user added pref.
+ lockedPref = this.getRow(PREF_STRING_NO_DEFAULT);
+ Assert.ok(lockedPref.hasClass("locked"));
+ Assert.equal(lockedPref.value, "");
+ Assert.ok(lockedPref.editColumnButton.classList.contains("button-edit"));
+ Assert.ok(lockedPref.editColumnButton.disabled);
+
+ // Test pref not locked.
+ let unlockedPref = this.getRow(PREF_BOOLEAN_USERVALUE_TRUE);
+ Assert.ok(!unlockedPref.hasClass("locked"));
+ Assert.equal(unlockedPref.value, "true");
+ Assert.ok(
+ unlockedPref.editColumnButton.classList.contains("button-toggle")
+ );
+ Assert.ok(!unlockedPref.editColumnButton.disabled);
+ });
+});