yyy-activate-CloseWatcher-dialog-popover.html (2490B)
1 <!DOCTYPE html> 2 <link rel=author href="mailto:jarhar@chromium.org"> 3 <link rel=help href="https://github.com/whatwg/html/pull/9462"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 <script src="/resources/testdriver-actions.js"></script> 9 <script src="/common/top-layer.js"></script> 10 <script src="../resources/helpers.js"></script> 11 12 <button id=b0>button</button> 13 14 <dialog id=dialog> 15 <button id=b1>button</button> 16 <div id=popover popover=auto>popover</div> 17 </dialog> 18 19 <script> 20 promise_test(async t => { 21 const events = []; 22 const closeWatcher = await createBlessedRecordingCloseWatcher(t, events, 'CloseWatcher', 'CloseWatcher'); 23 const dialog = await createBlessedRecordingCloseWatcher(t, events, 'dialog', 'dialog'); 24 const popover = await createBlessedRecordingCloseWatcher(t, events, 'popover', 'popover', dialog); 25 assert_true(dialog.hasAttribute('open'), 'The dialog should be open.'); 26 assert_true(popover.matches(':popover-open'), 'The popover should be open.'); 27 28 await blessTopLayer(popover); 29 await sendCloseRequest(); 30 await waitForPotentialCloseEvent(); 31 assert_false(popover.matches(':popover-open'), 'First close request: The popover should be closed.'); 32 assert_true(dialog.hasAttribute('open'), 'First close request: The dialog should be open.'); 33 assert_array_equals(events, []); 34 35 await blessTopLayer(dialog); 36 await sendCloseRequest(); 37 await waitForPotentialCloseEvent(); 38 assert_false(popover.matches(':popover-open'), 'Second close request: The popover should be closed.'); 39 assert_false(dialog.hasAttribute('open'), 'Second close request: The dialog should be closed.'); 40 assert_array_equals(events, ['dialog cancel[cancelable=true]', 'dialog close']); 41 42 await test_driver.bless(); 43 await sendCloseRequest(); 44 await waitForPotentialCloseEvent(); 45 assert_false(popover.matches(':popover-open'), 'Third close request: The popover should be closed.'); 46 assert_false(dialog.hasAttribute('open'), 'Third close request: The dialog should be closed.'); 47 assert_array_equals(events, ['dialog cancel[cancelable=true]', 'dialog close', 'CloseWatcher cancel[cancelable=true]', 'CloseWatcher close']); 48 }, 'Create a CloseWatcher with user activation; create a dialog with user activation; create a popover with user activation; sending user activation before each close request'); 49 </script>