tor-browser

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

getCurrentPosition-success.https.html (1472B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8"/>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/resources/testdriver.js?feature=bidi"></script>
      6 <script src="/resources/testdriver-vendor.js"></script>
      7 
      8 <script>
      9    promise_setup(async () => {
     10        // Ensure permission is granted before proceeding.
     11        await test_driver.bidi.permissions.set_permission({
     12            descriptor: {name: "geolocation"},
     13            state: "granted",
     14        });
     15    });
     16 
     17    promise_test(async (t) => {
     18        t.add_cleanup(async () => {
     19            await test_driver.bidi.emulation.set_geolocation_override(
     20                {coordinates: null});
     21        });
     22 
     23        const latitude = 51.478;
     24        const longitude = -0.166;
     25        const accuracy = 100;
     26 
     27        await test_driver.bidi.emulation.set_geolocation_override({
     28            coordinates: {latitude, longitude, accuracy}
     29        });
     30 
     31        const position = await new Promise(
     32            (resolve, reject) =>
     33                window.navigator.geolocation.getCurrentPosition(
     34                    position => resolve(position.coords.toJSON()),
     35                    error => reject(error),
     36                    {timeout: 200}
     37                ));
     38 
     39        assert_equals(position.latitude, latitude);
     40        assert_equals(position.longitude, longitude);
     41        assert_equals(position.accuracy, accuracy);
     42    }, "Tests Geolocation success callback");
     43 </script>