|
| 1 | +<!doctype html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>Permission Element: invalid if precise attribute is changed</title> |
| 6 | + <link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md" /> |
| 7 | + <script src="/resources/testharness.js"></script> |
| 8 | + <script src="/resources/testharnessreport.js"></script> |
| 9 | + </head> |
| 10 | + <body> |
| 11 | + <script> |
| 12 | + promise_test(async (t) => { |
| 13 | + let is_element_valid = false; |
| 14 | + const element = document.createElement("permission"); |
| 15 | + element.setAttribute("type", "geolocation"); |
| 16 | + element.onvalidationstatuschange = t.step_func(() => { |
| 17 | + if (element.invalidReason == "") { |
| 18 | + is_element_valid = true; |
| 19 | + } |
| 20 | + if (element.invalidReason == "attribute_changed") { |
| 21 | + is_element_valid = false; |
| 22 | + } |
| 23 | + }); |
| 24 | + document.body.appendChild(element); |
| 25 | + |
| 26 | + await t.step_wait(() => is_element_valid === true, "Wait for the element to be ready."); |
| 27 | + |
| 28 | + // setting the preciselocation attribute should temporarily disable the element. |
| 29 | + element.setAttribute("preciselocation", ""); |
| 30 | + await t.step_wait( |
| 31 | + () => is_element_valid === false, |
| 32 | + "Element should become invalid after preciselocation is set.", |
| 33 | + ); |
| 34 | + await t.step_wait( |
| 35 | + () => is_element_valid === true, |
| 36 | + "Element should automatically become valid again after 500ms after the attribute is set.", |
| 37 | + ); |
| 38 | + |
| 39 | + // uusetting the preciselocation attribute should temporarily disable the element. |
| 40 | + element.removeAttribute("preciselocation"); |
| 41 | + await t.step_wait( |
| 42 | + () => is_element_valid === false, |
| 43 | + "Element should become invalid after preciselocation is unset.", |
| 44 | + ); |
| 45 | + await t.step_wait( |
| 46 | + () => is_element_valid === true, |
| 47 | + "Element should automatically become valid again after 500ms after the attribute is unset.", |
| 48 | + ); |
| 49 | + }, "Permission element is invalid temporarily if the precise attribute is changed."); |
| 50 | + </script> |
| 51 | + </body> |
| 52 | +</html> |
0 commit comments