tor-browser

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

getCurrentPosition_permission_deny.https.html (1219B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <title>Geolocation Test: getCurrentPosition location access denied</title>
      4 <link rel="help" href="http://www.w3.org/TR/geolocation-API/#privacy_for_uas" />
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/resources/testdriver.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <script>
     10  promise_test(async (t) => {
     11    t.add_cleanup(() => {
     12      return test_driver.set_permission({ name: "geolocation" }, "prompt");
     13    });
     14    await test_driver.set_permission({ name: "geolocation" }, "denied");
     15    const error = await new Promise((resolve, reject) => {
     16      let calledAsync = false;
     17      navigator.geolocation.getCurrentPosition(reject, t.step_func((error) => {
     18        assert_true(calledAsync, "Expected callback to be called asynchronously");
     19        resolve(error);
     20      }));
     21      calledAsync = true;
     22    });
     23    assert_true(
     24      error instanceof GeolocationPositionError,
     25      "should be a GeolocationPositionError"
     26    );
     27    assert_equals(error.code, error.PERMISSION_DENIED);
     28  }, "User denies access, check that error callback is called with correct code");
     29 </script>