tor-browser

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

granted-selector.html (1411B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md#locking-the-pepc-style">
      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-actions.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <body>
     10 
     11 <permission id="permission_element" type="camera"></permission>
     12 
     13 <script>
     14  promise_test(async() => {
     15 
     16    // Set the initial camera state to denied.
     17    await test_driver.set_permission({name: "camera"}, "denied");
     18    await navigator.permissions.query({name: "camera"});
     19 
     20    assert_false(permission_element.matches(":granted"));
     21 
     22    // Set the camera state to allowed.
     23    await test_driver.set_permission({name: "camera"}, "granted");
     24    await navigator.permissions.query({name: "camera"});
     25 
     26    // The granted selector should now be applied.
     27    assert_true(permission_element.matches(":granted"));
     28 
     29    // Set the camera state to denied.
     30    await test_driver.set_permission({name: "camera"}, "denied");
     31    await navigator.permissions.query({name: "camera"});
     32 
     33    // The granted selector should now be removed.
     34    assert_false(permission_element.matches(":granted"));
     35 
     36  }, "Permission element should not have the granted selector when the \
     37      permission is not granted.")
     38 </script>