1
0
Fork 0
firefox/testing/web-platform/tests/geolocation/getCurrentPosition-success.https.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

43 lines
1.4 KiB
HTML

<!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 = 51.478;
const longitude = -0.166;
const accuracy = 100;
await test_driver.bidi.emulation.set_geolocation_override({
coordinates: {latitude, longitude, accuracy}
});
const position = await new Promise(
(resolve, reject) =>
window.navigator.geolocation.getCurrentPosition(
position => resolve(position.coords.toJSON()),
error => reject(error),
{timeout: 200}
));
assert_equals(position.latitude, latitude);
assert_equals(position.longitude, longitude);
assert_equals(position.accuracy, accuracy);
}, "Tests Geolocation success callback");
</script>