command-reflection.html (1849B)
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/testdriver.js"></script> 9 <script src="/resources/testdriver-actions.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src="resources/invoker-utils.js"></script> 12 13 <div id="invokee"></div> 14 <button id="invokerbutton" commandfor="invokee"></button> 15 16 <script> 17 ['', 'show-modal', 'toggle-popover', 'hide-popover', 'show-popover', 'close', '--custom'].forEach(command => { 18 test(function (t) { 19 invokerbutton.command = command 20 assert_equals(invokerbutton.command, command, `invoker should reflect ${command} properly`); 21 }, `invoker should reflect ${command} properly`); 22 }); 23 [ 24 ['sHoW-MoDaL', 'show-modal'], 25 ['tOgGlE-pOpOvEr', 'toggle-popover'], 26 ['hIdE-pOpOvEr', 'hide-popover'], 27 ['sHoW-pOpOvEr', 'show-popover'], 28 ['ClOsE', 'close'], 29 ['--cUsToM', '--cUsToM' 30 ]].forEach(([cased, command]) => { 31 test(function (t) { 32 invokerbutton.command = cased 33 assert_equals(invokerbutton.command, command, `invoker should reflect odd cased ${cased} properly - as ${command}`); 34 }, `invoker should reflect odd cased ${cased} properly - as ${command}`); 35 }); 36 ['invalid', 'show-invalid', 'foo-bar'].forEach(command => { 37 test(function (t) { 38 invokerbutton.command = command 39 assert_equals(invokerbutton.command, '', `invoker should reflect the invalid value "${command}" as the empty string`); 40 }, `invoker should reflect the invalid value "${command}" as the empty string`); 41 }); 42 </script>