diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index b2100c9591a3..0ed1cb5b65c0 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -5486,10 +5486,18 @@ int32_t EventStateManager::Prefs::sContentAccessModifierMask = 0; void EventStateManager::Prefs::Init() { - DebugOnly rv = - Preferences::AddBoolVarCache(&sKeyCausesActivation, - "accessibility.accesskeycausesactivation", - sKeyCausesActivation); + DebugOnly rv = Preferences::RegisterCallback(OnChange, "dom.popup_allowed_events"); + MOZ_ASSERT(NS_SUCCEEDED(rv), + "Failed to observe \"dom.popup_allowed_events\""); + + static bool sPrefsAlreadyCached = false; + if (sPrefsAlreadyCached) { + return; + } + + rv = Preferences::AddBoolVarCache(&sKeyCausesActivation, + "accessibility.accesskeycausesactivation", + sKeyCausesActivation); MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"accessibility.accesskeycausesactivation\""); rv = Preferences::AddBoolVarCache(&sClickHoldContextMenu, @@ -5512,10 +5520,7 @@ EventStateManager::Prefs::Init() sContentAccessModifierMask); MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"ui.key.contentAccess\""); - - rv = Preferences::RegisterCallback(OnChange, "dom.popup_allowed_events"); - MOZ_ASSERT(NS_SUCCEEDED(rv), - "Failed to observe \"dom.popup_allowed_events\""); + sPrefsAlreadyCached = true; } // static