n-activate-preventDefault.html (1150B)
1 <!doctype html> 2 <meta name=variant content="?dialog"> 3 <meta name=variant content="?CloseWatcher"> 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 <body> 13 <script> 14 const type = location.search.substring(1); 15 16 promise_test(async t => { 17 const events = []; 18 const watcher = createRecordingCloseWatcher(t, events, undefined, type); 19 watcher.addEventListener("cancel", e => e.preventDefault()); 20 21 await maybeTopLayerBless(watcher); 22 await sendCloseRequest(); 23 await waitForPotentialCloseEvent(); 24 25 assert_array_equals(events, ["cancel[cancelable=true]"]); 26 27 await sendCloseRequest(); 28 await waitForPotentialCloseEvent(); 29 assert_array_equals(events, ["cancel[cancelable=true]", "cancel[cancelable=false]", "close"]); 30 }, "Create a close watcher without user activation that preventDefault()s cancel; send user activation"); 31 </script>