Bug 1900225: Part 4 - Add geo.prompt.open_system_prefs to block opening system preferences r=gstoll a=RyanVM

Also adds this as the default for mochitests, in anticipation of the day that
the implementation is supported by the computers in automation.

Differential Revision: https://phabricator.services.mozilla.com/D216475
This commit is contained in:
David P 2024-08-27 22:47:32 +00:00
parent 02741f5f68
commit b5f3201f9f
3 changed files with 20 additions and 1 deletions

View file

@ -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) {

View file

@ -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."
#---------------------------------------------------------------------------

View file

@ -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);