select-required-attribute.tentative.html (1626B)
1 <!DOCTYPE html> 2 <html lang="en"> 3 <title>HTMLselectElement Test: required attribute</title> 4 <link rel="author" title="Ionel Popescu" href="mailto:iopopesc@microsoft.com"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <style> 9 select:required { 10 border: 3px dashed rgb(255, 0, 0); 11 } 12 13 select:optional { 14 border: 1px solid rgb(128, 128, 128); 15 } 16 17 select, ::picker(select) { 18 appearance: base-select; 19 } 20 </style> 21 22 <select id="select0" required> 23 <option>one</option> 24 <option>two</option> 25 <option>three</option> 26 </select> 27 28 <select id="select1"> 29 <option>one</option> 30 <option>two</option> 31 <option>three</option> 32 </select> 33 34 <select id="select2"> 35 <option>one</option> 36 <option>two</option> 37 <option>three</option> 38 </select> 39 40 <script> 41 function checkRequired(style) { 42 assert_equals(style.borderWidth, '3px'); 43 assert_equals(style.borderStyle, 'dashed'); 44 assert_equals(style.borderColor, 'rgb(255, 0, 0)'); 45 } 46 47 function checkOptional(style) { 48 assert_equals(style.borderWidth, '1px'); 49 assert_equals(style.borderStyle, 'solid'); 50 assert_equals(style.borderColor, 'rgb(128, 128, 128)'); 51 } 52 53 test(() => { 54 const select0 = document.getElementById("select0"); 55 const select1 = document.getElementById("select1"); 56 const select2 = document.getElementById("select2"); 57 58 checkRequired(window.getComputedStyle(select0)); 59 checkOptional(window.getComputedStyle(select1)); 60 checkOptional(window.getComputedStyle(select2)); 61 select2.required = true; 62 checkRequired(window.getComputedStyle(select2)); 63 }, "Test required attribute"); 64 65 </script>