commit 9605c52d304b53d294a45085ba5c6cc4a84bb261 parent bfad0646716e74e8a39b40cf9ed4f1fb890da400 Author: Jens Stutte <jstutte@mozilla.com> Date: Thu, 2 Oct 2025 13:40:18 +0000 Bug 1991846 - _RFPHelper._handleLetterboxingPrefChanged should avoid to register the observer twice. r=tjr There might be a way to solve this at test level by pushing only the prefs that really need to be changed, but it feels safer to solve it here. Differential Revision: https://phabricator.services.mozilla.com/D267224 Diffstat:
| M | toolkit/components/resistfingerprinting/RFPHelper.sys.mjs | | | 15 | +++++++++++++-- |
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/toolkit/components/resistfingerprinting/RFPHelper.sys.mjs b/toolkit/components/resistfingerprinting/RFPHelper.sys.mjs @@ -35,6 +35,11 @@ function log(...args) { class _RFPHelper { _resizeObservers = new WeakMap(); + // Track the observer status. It looks like pref changes can be notified + // also if the pref is actually unchanged. This might be a tests-only issue + // where we repeatedly push the prefs. See bug 1992137. + _letterboxingPrefObserversAdded = false; + // ============================================================================ // Shared Setup // ============================================================================ @@ -289,11 +294,17 @@ class _RFPHelper { _handleLetterboxingPrefChanged() { if (Services.prefs.getBoolPref(kPrefLetterboxing, false)) { - Services.ww.registerNotification(this); + if (!this._letterboxingPrefObserversAdded) { + Services.ww.registerNotification(this); + this._letterboxingPrefObserversAdded = true; + } this._attachAllWindows(); } else { this._detachAllWindows(); - Services.ww.unregisterNotification(this); + if (this._letterboxingPrefObserversAdded) { + Services.ww.unregisterNotification(this); + this._letterboxingPrefObserversAdded = false; + } } }