precise-attribute-changed.html (2134B)
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 element.invalidReason == "intersection_changed") { 22 is_element_valid = false; 23 } 24 }); 25 document.body.appendChild(element); 26 27 await t.step_wait(() => is_element_valid === true, "Wait for the element to be ready."); 28 29 // setting the preciselocation attribute should temporarily disable the element. 30 element.setAttribute("preciselocation", ""); 31 await t.step_wait( 32 () => is_element_valid === false, 33 "Element should become invalid after preciselocation is set.", 34 ); 35 await t.step_wait( 36 () => is_element_valid === true, 37 "Element should automatically become valid again after 500ms after the attribute is set.", 38 ); 39 40 // uusetting the preciselocation attribute should temporarily disable the element. 41 element.removeAttribute("preciselocation"); 42 await t.step_wait( 43 () => is_element_valid === false, 44 "Element should become invalid after preciselocation is unset.", 45 ); 46 await t.step_wait( 47 () => is_element_valid === true, 48 "Element should automatically become valid again after 500ms after the attribute is unset.", 49 ); 50 }, "Permission element is invalid temporarily if the precise attribute is changed."); 51 </script> 52 </body> 53 </html>