Skip to content

Truly independent web browser

Tests/LibWeb: Keep test-web off the OS location provider

sideshowbarkerf78201a3e9f6
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp
index 2c11fb111e8..9f0a86ade20 100644
--- a/Libraries/LibWebView/Application.cpp
+++ b/Libraries/LibWebView/Application.cpp
@@ -3260,6 +3260,8 @@ void Application::set_spell_checker(OwnPtr<SpellChecker> spell_checker)
ErrorOr<NonnullRawPtr<Core::GeolocationProvider>> Application::ensure_geolocation_provider()
{
if (!m_geolocation_provider) {
+ if (!should_use_os_geolocation())
+ return Error::from_string_literal("The OS location provider is disabled");
m_geolocation_provider = TRY(Core::GeolocationProvider::create());
m_geolocation_provider->on_authorization_change = [this] { update_os_location_authorization(); };
update_os_location_authorization();
diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.h
index 5a4f9fffbf1..2f2a6614971 100644
--- a/Libraries/LibWebView/Application.h
+++ b/Libraries/LibWebView/Application.h
@@ -442,6 +442,7 @@ protected:
virtual Core::EventLoop& create_platform_event_loop();
virtual bool should_coordinate_browser_process() const { return true; }
+ virtual bool should_use_os_geolocation() const { return true; }
virtual SiteIsolationMode default_site_isolation_mode() const { return SiteIsolationMode::IFrame; }
virtual Optional<ByteString> ask_user_for_download_path([[maybe_unused]] ByteString const& file) const { return {}; }
diff --git a/Tests/LibWeb/test-web/Application.h b/Tests/LibWeb/test-web/Application.h
index bedd6ce6c1b..8d8d25a1167 100644
--- a/Tests/LibWeb/test-web/Application.h
+++ b/Tests/LibWeb/test-web/Application.h
@@ -27,6 +27,9 @@ public:
virtual bool should_coordinate_browser_process() const override { return false; }
virtual bool should_capture_web_content_output() const override { return true; }
+ // A test's position is emulated, so the OS is never asked for one, nor for leave to get one: the machine's own
+ // Location Services setting would otherwise read as a denial for every site a test allowed.
+ virtual bool should_use_os_geolocation() const override { return false; }
// Tests cover elastic overscroll on every platform, whichever of them the browser enables it on.
virtual bool platform_scrolls_elastically() const override { return true; }