Geolocation API - implementation report 2016-2022

This is an implementation report for the Geolocation API, covering the testable normative changes that were made since maintenance resumed on the specification in 2016 until 2022.

Tested assertions

As the Geolocation API requires explicit permission grant to be used (via a browser UI), the following assertions were tested manually to assure interoperability across user agents.

As some of the tests rely on the [[Permissions]] specifications automation API, which is only partially supported in Chrome, some the test were modified locally to get them to pass across user agents. However, the working group expects that eventually all user agents will support the [[Permissions]]'s automation API and wpt.fyi will reflect accurate results for [[Geolocation]].

Change Test Chrome Firefox Safari TP
Switch `DOMTimeStamp` to `EpochTimeStamp` idlharness.https.window.js PASS PASS PASS
Return 0 when `watchPosition()` errors non-fully-active.https.html PASS PASS PASS
Callback with error if doc is not fully active non-fully-active.https.html PASS PASS PASS
Gracefully handle documents that are not fully active non-fully-active.https.html PASS PASS PASS
Now relies on the Permissions specification to handle permission grants, and user interface requirements. permission.https.html PASS PASS PASS
The `errorCallback` is now nullable. getCurrentPosition_permission_allow.https.html PASS PASS PASS
The API can be controlled by Permissions Policy, which restricts how/where the API is exposed to web pages. enabled-by-feature-policy.https.sub.html PASS PASS PASS
The callbacks are no longer treated as "EventHandler" objects (i.e., objects that have a .handleEvent() method), but are now exclusively treated as IDL callback functions. getCurrentPosition_TypeError.https.html, watchPosition_TypeError.https.html PASS PASS PASS
The API is now only exposed in Secure Contexts (i.e., only available in HTTPS). non-secure-contexts.http.html PASS PASS PASS
The interfaces no longer use [WebIDL]'s legacy [NoInterfaceObject], so Geolocation and other interface of this spec are now in the global scope. Also, the interfaces were renamed from NavigatorGeolocation* to just Geolocation*. idlharness.https.window.js PASS PASS PASS

Assertions that are not testable

Change Why not tested
Suggest permission lifetime Not testable because this is a UI requirement on user agents.
Handle OS-level permission change It's not possible to change OS-level permissions via WTP infrastructure (only browser permissions).
Add "geolocation task queue" This change is not observable/testable. At the same time, the async nature of the API is tested in almost every other test.
fix "Queue a task" / "in parallel" usage Although normative, this change was mostly editorial and not observable/testable.
Request a position only proceeds when a document is visible, or the document becomes visible. This can be tested because of limitations of WTP: It would require opening multiple browser tabs, which WPT can't do. However, this is implemented in all browsers and was manually verified.
Clarified how caching works as part of acquiring a position: only last position is cached, and can be evicted at any time. Caching behavior is designed not to be observable and is thus not possible to test.