on-popover-invalid-behavior.html (1562B)
1 <!doctype html> 2 <meta charset="utf-8" /> 3 <meta name="author" title="Keith Cirkel" href="mailto:wpt@keithcirkel.co.uk" /> 4 <meta name="timeout" content="long" /> 5 <link rel="help" href="https://open-ui.org/components/invokers.explainer/" /> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="resources/invoker-utils.js"></script> 9 10 <div id="invokee" popover> 11 <button id="containedinvoker" commandfor="invokee"></button> 12 </div> 13 <button id="invokerbutton" commandfor="invokee"></button> 14 15 <script> 16 function resetState() { 17 invokerbutton.removeAttribute("command"); 18 containedinvoker.removeAttribute("command"); 19 try { 20 invokee.hidePopover(); 21 } catch {} 22 invokee.setAttribute("popover", ""); 23 } 24 25 // invalid actions on show-popover 26 [null, "", "foo-bar", "showpopover", "show-modal", "show-picker", "open", "close"].forEach((command) => { 27 test(function (t) { 28 t.add_cleanup(resetState); 29 invokerbutton.command = command; 30 assert_false(invokee.matches(":popover-open")); 31 invokerbutton.click(); 32 assert_false(invokee.matches(":popover-open")); 33 }, `invoking (as ${command}) on popover does nothing`); 34 35 test(function (t) { 36 t.add_cleanup(resetState); 37 invokerbutton.command = command; 38 invokee.showPopover(); 39 assert_true(invokee.matches(":popover-open")); 40 invokerbutton.click(); 41 assert_true(invokee.matches(":popover-open")); 42 }, `invoking (as ${command}) on open popover does nothing`); 43 }); 44 </script>