tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

watchposition-timeout.https.window.js (761B)


      1 // META: script=/resources/testdriver.js
      2 // META: script=/resources/testdriver-vendor.js
      3 
      4 promise_setup(async () => {
      5  await test_driver.set_permission({ name: "geolocation" }, "granted");
      6 });
      7 
      8 promise_test(async (t) => {
      9  let timeoutCount = 0;
     10 
     11  // This may still succeed without timeout in case there's a cache.
     12  const watchId = navigator.geolocation.watchPosition(() => {}, (error) => {
     13    if (error.code === GeolocationPositionError.TIMEOUT) {
     14      ++timeoutCount;
     15    }
     16  }, { timeout: 1 });
     17  t.add_cleanup(() => navigator.geolocation.clearWatch(watchId));
     18 
     19  await new Promise(r => setTimeout(r, 100));
     20 
     21  assert_true(timeoutCount < 2, "At most one timeout should have been seen");
     22 }, "Passing timeout=1 should not cause multiple timeout errors");