Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/permission-element/granted-selector.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body>
<geolocation id="geolocation_element"></geolocation>
<script>
const PEPC_CLICK_DELAY = 600;
promise_test(async(t) => {
// Wait for initialization
await new Promise((r) => t.step_timeout(r, PEPC_CLICK_DELAY));
// Set the initial state to denied.
await test_driver.set_permission({name: "geolocation"}, "denied");
await navigator.permissions.query({name: "geolocation"});
// Wait for renderer to receive update
await new Promise((r) => t.step_timeout(r, 100));
assert_false(geolocation_element.matches(":granted"));
// Set the state to allowed.
await test_driver.set_permission({name: "geolocation"}, "granted");
await navigator.permissions.query({name: "geolocation"});
await new Promise((r) => t.step_timeout(r, 100));
// The granted selector should now be applied.
assert_true(geolocation_element.matches(":granted"));
// Set the state to denied.
await test_driver.set_permission({name: "geolocation"}, "denied");
await navigator.permissions.query({name: "geolocation"});
await new Promise((r) => t.step_timeout(r, 100));
// The granted selector should now be removed.
assert_false(geolocation_element.matches(":granted"));
}, "Geolocation element should not have the granted selector when the \
permission is not granted.")
</script>