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