button-invoke-menulist.html (1284B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 5 <button id=btn commandfor="m">Actions</button> 6 7 <menulist id=m> 8 <menuitem>Action 1</menuitem> 9 <menuitem>Action 2</menuitem> 10 </menulist> 11 12 <script> 13 const btn = document.getElementById("btn"); 14 const menulist = document.querySelector("menulist"); 15 16 test(() => { 17 btn.setAttribute("command", "toggle-popover"); 18 btn.disabled = true; 19 btn.click(); 20 assert_false(menulist.matches(':popover-open'), 21 'The menulist should not open because the button is disabled.'); 22 23 btn.disabled = false; 24 btn.click(); 25 assert_true(menulist.matches(':popover-open'), 26 'The menulist should be able to open successfully.'); 27 menulist.hidePopover(); 28 }, "Button with command=toggle-popover can invoke menulist popover."); 29 30 test(() => { 31 btn.setAttribute("command", "toggle-menu"); 32 btn.disabled = true; 33 btn.click(); 34 assert_false(menulist.matches(':popover-open'), 35 'The menulist should not open because the button is disabled.'); 36 37 btn.disabled = false; 38 btn.click(); 39 assert_true(menulist.matches(':popover-open'), 40 'The menulist should be able to open successfully.'); 41 menulist.hidePopover(); 42 }, "Button with command=toggle-menu can invoke menulist popover."); 43 </script>