mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Implement emulated Geolocation position retrieval
This implements enough of the Geolocation spec that it is now possible for websites to retrieve the current geo position or try to watch for updates (which currently never happen). As it stands now, it only returns a single emulated position that points to San Francisco.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
53c35c5d3b
commit
71f03cb785
Notes:
github-actions[bot]
2025-06-24 09:35:05 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/71f03cb7856 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5169 Reviewed-by: https://github.com/shannonbooth ✅
@@ -12,10 +12,9 @@ namespace Web::Geolocation {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(GeolocationPositionError);
|
||||
|
||||
GeolocationPositionError::GeolocationPositionError(JS::Realm& realm, ErrorCode code, String message)
|
||||
GeolocationPositionError::GeolocationPositionError(JS::Realm& realm, ErrorCode code)
|
||||
: PlatformObject(realm)
|
||||
, m_code(code)
|
||||
, m_message(move(message))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,4 +24,19 @@ void GeolocationPositionError::initialize(JS::Realm& realm)
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/geolocation/#message-attribute
|
||||
String GeolocationPositionError::message() const
|
||||
{
|
||||
// The message attribute is a developer-friendly textual description of the code attribute.
|
||||
switch (m_code) {
|
||||
case ErrorCode::PositionUnavailable:
|
||||
return "Position unavailable"_string;
|
||||
case ErrorCode::PermissionDenied:
|
||||
return "Permission denied"_string;
|
||||
case ErrorCode::Timeout:
|
||||
return "Timeout"_string;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user