dialog-open-movebefore-setup.html (1842B)
1 <!doctype html> 2 <title>moveBefore should not re-run dialog setup steps</title> 3 <link rel="author" title="Keith Cirkel" href="mailto:wpt@keithcirkel.co.uk" /> 4 <link rel="help" href="https://github.com/whatwg/html/pull/11326#discussion_r2104180451" /> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-actions.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 11 <div id="new_parent"></div> 12 <dialog id="dialog" closedby="closerequest"></dialog> 13 <dialog id="second_dialog" closedby="closerequest"></dialog> 14 15 <script> 16 promise_test(async t => { 17 // Show both dialogs in a specific order so that `second_dialog` is at the 18 // end of the "open dialog list". 19 20 dialog.show(); 21 // Ensure a user activation happens between each dialog show so that they 22 // are in discrete closewatcher groups. 23 await test_driver.bless(); 24 assert_true(navigator.userActivation.isActive, "document now active"); 25 second_dialog.show(); 26 27 assert_true(dialog.open, "the first dialog is open"); 28 assert_true(dialog.open, "the second dialog is open"); 29 30 new_parent.moveBefore(dialog, null); 31 32 assert_true(dialog.open, "the first dialog is still open"); 33 assert_true(dialog.open, "the second dialog is still open"); 34 35 // Press escape to close only the top-most open dialog: 36 const ESC = '\uE00C'; 37 await test_driver.send_keys(document.documentElement, ESC); 38 39 // The dialog that closed should have been second_dialog, because 40 assert_true(dialog.open, "the first open dialog remains open"); 41 assert_false(second_dialog.open, "the second open dialog is now closed"); 42 }, "reparenting a dialog should not cause it to move in the open dialogs list"); 43 </script>