on-dialog-disconnect.html (1212B)
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 <dialog id="invokee"></dialog> 11 <button id="invokerbutton" commandfor="invokee" command="show-modal"></button> 12 13 <script> 14 const invokee = document.getElementById('invokee'); 15 test( 16 function (t) { 17 assert_false(invokee.open, "invokee.open"); 18 assert_false(invokee.matches(":modal"), "invokee :modal"); 19 let fired = false; 20 invokee.addEventListener('command', () => { 21 fired = true; 22 invokee.remove(); 23 }); 24 invokerbutton.click(); 25 assert_true(fired, "command event fired"); 26 assert_false(invokee.isConnected, "dialog no longer connected"); 27 assert_false(invokee.open, "invokee.open"); 28 assert_false(invokee.matches(":modal"), "invokee :modal"); 29 }, 30 `invoking a dialog and removing during command event does not raise an error`, 31 ); 32 </script>