commit c18ed00a411c897caadf83dd91c56f3613cfacbd
parent f9db19acead185f146ca6ad67b8d3d9904bcf6b5
Author: Beth Rennie <beth@brennie.ca>
Date: Fri, 7 Nov 2025 19:25:17 +0000
Bug 1993057 - Emit notifications before and after changing prefs via about:config r=mkennedy
Differential Revision: https://phabricator.services.mozilla.com/D271730
Diffstat:
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/toolkit/components/aboutconfig/content/aboutconfig.js b/toolkit/components/aboutconfig/content/aboutconfig.js
@@ -373,7 +373,9 @@ class PrefRow {
}
toggle() {
+ this.#notifyWillChange();
Services.prefs.setBoolPref(this.name, !this.value);
+ this.#notifyChanged();
}
editOrToggle() {
@@ -385,14 +387,20 @@ class PrefRow {
}
save() {
+ if (this.type == "Number" && !this.inputField.reportValidity()) {
+ return;
+ }
+
+ this.#notifyWillChange();
+
if (this.type == "Number") {
- if (!this.inputField.reportValidity()) {
- return;
- }
Services.prefs.setIntPref(this.name, parseInt(this.inputField.value));
} else {
Services.prefs.setStringPref(this.name, this.inputField.value);
}
+
+ this.#notifyChanged();
+
this.refreshValue();
this.endEdit();
this.editButton.focus();
@@ -403,6 +411,18 @@ class PrefRow {
this.refreshElement();
gPrefInEdit = null;
}
+
+ #notifyWillChange() {
+ Services.obs.notifyObservers(
+ null,
+ "about-config-will-change-pref",
+ this.name
+ );
+ }
+
+ #notifyChanged() {
+ Services.obs.notifyObservers(null, "about-config-changed-pref", this.name);
+ }
}
let gPrefObserverRegistered = false;