display-values.tentative.html (2577B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>Geolocation Element: display style validation</title> 6 <link 7 rel="help" 8 href="https://github.com/WICG/PEPC/blob/main/explainer.md#locking-the-pepc-style" 9 /> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 </head> 13 <body> 14 <script> 15 function createGeolocationElementWithStyle(displayValue) { 16 const element = document.createElement("geolocation"); 17 18 element.style.display = displayValue; 19 // Clear the body and append the element. This is necessary because 20 // there can be a max of 3 geolocation elements on the page at a time. 21 document.body.appendChild(element); 22 return element; 23 } 24 25 const testCases = [ 26 ["block", ""], 27 ["inline-block", ""], 28 ["flex", ""], 29 ["inline-flex", ""], 30 ["inline", "style_invalid"], 31 ["contents", "style_invalid"], 32 ["inline-table", "style_invalid"], 33 ["list-item", "style_invalid"], 34 ["ruby", "style_invalid"], 35 ["ruby-text", "style_invalid"], 36 ["table", "style_invalid"], 37 ["table-caption", "style_invalid"], 38 ["table-cell", "style_invalid"], 39 ["table-column", "style_invalid"], 40 ["table-column-group", "style_invalid"], 41 ["table-footer-group", "style_invalid"], 42 ["table-header-group", "style_invalid"], 43 ["table-row", "style_invalid"], 44 ["table-row-group", "style_invalid"], 45 ]; 46 47 async_test((t) => { 48 let completedTests = 0; 49 50 testCases.forEach(([displayValue, expectedInvalidReason]) => { 51 const element = createGeolocationElementWithStyle(displayValue); 52 element.onvalidationstatuschange = t.step_func(() => { 53 // These two invalid reasons are expected when the geolocation element was just created. 54 if ( 55 element.invalidReason == "unsuccessful_registration" || 56 element.invalidReason == "intersection_changed" 57 ) { 58 return; 59 } 60 assert_equals( 61 element.invalidReason, 62 expectedInvalidReason, 63 `display: ${displayValue} should be ${expectedInvalidReason === "" ? "valid" : "invalid"}`, 64 ); 65 element.remove(); 66 if (++completedTests === testCases.length) t.done(); 67 }); 68 }); 69 }, "Geolocation element display style validation"); 70 </script> 71 </body> 72 </html>