tor-browser

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

disabled-by-permissions-policy.https.sub.html (2657B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <body>
      4  <script src="/resources/testharness.js"></script>
      5  <script src="/resources/testharnessreport.js"></script>
      6  <script src="/resources/testdriver.js"></script>
      7  <script src="/resources/testdriver-vendor.js"></script>
      8  <script src="/permissions-policy/resources/permissions-policy.js"></script>
      9  <script>
     10    "use strict";
     11 
     12    const same_origin_src =
     13      "/permissions-policy/resources/permissions-policy-geolocation.html";
     14    const cross_origin_src =
     15      "https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src;
     16 
     17    promise_setup(async () => {
     18      await test_driver.set_permission({ name: "geolocation" }, "granted");
     19    });
     20 
     21    promise_test(async (test) => {
     22      // These operations are slow, so let's do them in parallel.
     23      const getCurrentPositionPromise = new Promise((resolve, reject) => {
     24        navigator.geolocation.getCurrentPosition(reject, resolve);
     25      });
     26      const watchPositionPromise = new Promise((resolve, reject) => {
     27        navigator.geolocation.watchPosition(reject, resolve);
     28      });
     29      const posError = await getCurrentPositionPromise;
     30 
     31      assert_true(
     32        posError instanceof GeolocationPositionError,
     33        "Expected instance of GeolocationPositionError"
     34      );
     35 
     36      assert_equals(
     37        posError.code,
     38        GeolocationPositionError.prototype.PERMISSION_DENIED,
     39        "Expected PERMISSION_DENIED"
     40      );
     41 
     42      const watchError = await watchPositionPromise;
     43      assert_true(
     44        watchError instanceof GeolocationPositionError,
     45        "Expected instance of GeolocationPositionError"
     46      );
     47      assert_equals(
     48        watchError.code,
     49        GeolocationPositionError.prototype.PERMISSION_DENIED,
     50        "Expected PERMISSION_DENIED"
     51      );
     52    }, "Permissions-Policy header geolocation=() disallows the top-level document.");
     53 
     54    promise_test(async (test) => {
     55      await test_feature_availability({
     56        feature_description: "Geolocation API",
     57        test,
     58        src: same_origin_src,
     59        expect_feature_available: expect_feature_unavailable_default,
     60        is_promise_test: true,
     61      });
     62    }, "Permissions-Policy header geolocation=() disallows same-origin iframes.");
     63 
     64    promise_test(async (test) => {
     65      await test_feature_availability({
     66        feature_description: "Geolocation API",
     67        test,
     68        src: cross_origin_src,
     69        expect_feature_available: expect_feature_unavailable_default,
     70        feature_name: "geolocation",
     71        is_promise_test: true,
     72      });
     73    }, "Permissions-Policy header geolocation=() disallows cross-origin iframes.");
     74  </script>
     75 </body>