Files
sousa-gecko/testing/web-platform/tests/geolocation/getCurrentPosition-error.https.html
T
Maksim Sadym 818d2c0874 Bug 1965842 [wpt PR 52243] - Extend geolocation tests,
Automatic update from web-platform-tests
Extend geolocation tests (#52243)

Copy Chromium's wpt-internal test to public WPT using testdriver geolocation API.
* wpt_internal/geolocation-api/success.https.html
--

wpt-commits: c647833f5eeb730eb9a6bcdb52c8b3158b205dc9
wpt-pr: 52243

Differential Revision: https://phabricator.services.mozilla.com/D249368
2025-05-14 16:00:40 +00:00

49 lines
1.7 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});
});
await test_driver.bidi.emulation.set_geolocation_override({
error: {type: "positionUnavailable"}
});
const error = await new Promise(
(resolve, reject) =>
window.navigator.geolocation.getCurrentPosition(
() => reject("Unexpected success callback"),
error => resolve({
code: error.code,
message: error.message,
PERMISSION_DENIED: error.PERMISSION_DENIED,
POSITION_UNAVAILABLE: error.POSITION_UNAVAILABLE,
TIMEOUT: error.TIMEOUT
}),
{timeout: 1000}
));
assert_equals(error.code, 2);
// The message value is not specified.
assert_not_equals(error.message, undefined);
assert_equals(error.PERMISSION_DENIED, 1);
assert_equals(error.POSITION_UNAVAILABLE, 2);
assert_equals(error.TIMEOUT, 3);
}, "Tests Geolocation error callback");
</script>