commit 8a5a3fa780956ad7297718e10d027b4140593bf6
parent 3dff790ffeb6c883f3e8b2c3b6a9d59dd46f2d6b
Author: Ravjit Uppal <ravjit@chromium.org>
Date: Thu, 9 Oct 2025 16:28:32 +0000
Bug 1991184 [wpt PR 55115] - [PEPC] Implement getCurrentPosition for HTMLGeolocationElement, a=testonly
Automatic update from web-platform-tests
[PEPC] Implement getCurrentPosition for HTMLGeolocationElement
This change refactors `GeoNotifier` into a base class. Two new
subclasses, `GeoNotifierV8` and `GeoNotifierBlink`, are introduced.
`GeoNotifierV8` handles callbacks originating from V8 bindings, while
`GeoNotifierBlink` is designed for Blink-internal usage with
`base::RepeatingCallback`. A new overload for
`Geolocation::getCurrentPosition` is added to accept a
`base::RepeatingCallback`, which is used by `HTMLGeolocationElement`.
Change-Id: I0ee8291a0e492d9b6d4dd61cb11756d7115ff7ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6865601
Commit-Queue: Ravjit Uppal <ravjit@chromium.org>
Reviewed-by: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1521456}
--
wpt-commits: 9ab5c7aa2fc8e4bbb010bb0e9fa4f681ce8fa884
wpt-pr: 55115
Diffstat:
2 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/html/semantics/permission-element/geolocation-element/get-current-position-error.html b/testing/web-platform/tests/html/semantics/permission-element/geolocation-element/get-current-position-error.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<meta charset="utf-8" />
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js?feature=bidi"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+
+<script>
+ promise_setup(async () => {
+ // Ensure permission is denied before proceeding.
+ await test_driver.bidi.permissions.set_permission({
+ descriptor: { name: 'geolocation' },
+ state: 'denied',
+ });
+ });
+
+ promise_test(async (t) => {
+ document.innerHTML +=
+ '<geolocation id="geolocation-element" autolocate onlocation="onLocation()"></geolocation>';
+ }, 'Tests Geolocation element\'s error callback');
+
+ function onLocation() {
+ const el = document.getElementById('geolocation-element');
+ assert_equals(el.position, null);
+ assert_equals(el.error.code, 1);
+ assert_equals(el.error.message, 'User denied Geolocation');
+ }
+</script>
diff --git a/testing/web-platform/tests/html/semantics/permission-element/geolocation-element/get-current-position-success.html b/testing/web-platform/tests/html/semantics/permission-element/geolocation-element/get-current-position-success.html
@@ -0,0 +1,40 @@
+<!doctype html>
+<meta charset="utf-8" />
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js?feature=bidi"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+
+<script>
+ promise_setup(async () => {
+ // Ensure permission is granted before proceeding.
+ await test_driver.bidi.permissions.set_permission({
+ descriptor: { name: 'geolocation' },
+ state: 'granted',
+ });
+ });
+
+ promise_test(async (t) => {
+ t.add_cleanup(async () => {
+ await test_driver.bidi.emulation.set_geolocation_override({ coordinates: null });
+ });
+
+ const latitude = 50;
+ const longitude = 0;
+ const accuracy = 100;
+
+ await test_driver.bidi.emulation.set_geolocation_override({
+ coordinates: { latitude, longitude, accuracy },
+ });
+ document.innerHTML +=
+ '<geolocation id="geolocation-element" autolocate onlocation="onLocation()"></geolocation>';
+ }, 'Tests Geolocation element\'s success callback');
+
+ function onLocation() {
+ let el = document.getElementById('geolocation-element');
+ assert_equals(el.position.coords.latitude, 50);
+ assert_equals(el.position.coords.longitude, 0);
+ assert_equals(el.position.coords.accuracy, 100);
+ assert_equals(el.error, null);
+ }
+</script>