diff --git a/dom/geolocation/Geolocation.cpp b/dom/geolocation/Geolocation.cpp index fa756a3f0c8e..ff76e233b4c9 100644 --- a/dom/geolocation/Geolocation.cpp +++ b/dom/geolocation/Geolocation.cpp @@ -1446,7 +1446,14 @@ void Geolocation::NotifyAllowedRequest(nsGeolocationRequest* aRequest) { /* static */ geolocation::SystemGeolocationPermissionBehavior Geolocation::GetLocationOSPermission() { - return geolocation::GetGeolocationPermissionBehavior(); + auto permission = geolocation::GetGeolocationPermissionBehavior(); + + if (!StaticPrefs::geo_prompt_open_system_prefs() && + permission == geolocation::SystemGeolocationPermissionBehavior:: + GeckoWillPromptUser) { + return geolocation::SystemGeolocationPermissionBehavior::NoPrompt; + } + return permission; } void Geolocation::RequestIfPermitted(nsGeolocationRequest* request) { diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index c7487cb6b87c..031ed0344d44 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -5648,6 +5648,13 @@ mirror: always #endif +# If true, open system preferences for the user when geolocation is requested +# by the user but OS geolocation permission is not available. +- name: geo.prompt.open_system_prefs + type: bool + value: true + mirror: always + #--------------------------------------------------------------------------- # Prefs starting with "gfx." #--------------------------------------------------------------------------- diff --git a/testing/profiles/mochitest/user.js b/testing/profiles/mochitest/user.js index bbd8fc317020..f87958f8ea01 100644 --- a/testing/profiles/mochitest/user.js +++ b/testing/profiles/mochitest/user.js @@ -31,3 +31,8 @@ user_pref("app.update.disabledForTesting", true); // Therefore, in the mochitest, as the frequently in common browser tests can be // super higher than the real user, we disable this feature. user_pref("places.history.floodingPrevention.enabled", false); + +// If we are on a platform where we can detect that we don't have OS geolocation +// permission, and we can open it and wait for the user to give permission, then +// don't do that. +user_pref("geo.prompt.open_system_prefs", false);