1
0
Fork 0
firefox/testing/web-platform/tests/geolocation/watchposition-timeout.https.window.js
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

22 lines
761 B
JavaScript

// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
promise_setup(async () => {
await test_driver.set_permission({ name: "geolocation" }, "granted");
});
promise_test(async (t) => {
let timeoutCount = 0;
// This may still succeed without timeout in case there's a cache.
const watchId = navigator.geolocation.watchPosition(() => {}, (error) => {
if (error.code === GeolocationPositionError.TIMEOUT) {
++timeoutCount;
}
}, { timeout: 1 });
t.add_cleanup(() => navigator.geolocation.clearWatch(watchId));
await new Promise(r => setTimeout(r, 100));
assert_true(timeoutCount < 2, "At most one timeout should have been seen");
}, "Passing timeout=1 should not cause multiple timeout errors");