ny-activate-preventDefault.html (1582B)
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 19 const watcher1 = createRecordingCloseWatcher(t, events, "watcher1", type); 20 const watcher2 = await createBlessedRecordingCloseWatcher(t, events, "watcher2", type, watcher1); 21 watcher2.addEventListener("cancel", e => e.preventDefault()); 22 23 await maybeTopLayerBless(watcher2); 24 25 await sendCloseRequest(); 26 await waitForPotentialCloseEvent(); 27 assert_array_equals(events, ["watcher2 cancel[cancelable=true]"]); 28 29 await sendCloseRequest(); 30 await waitForPotentialCloseEvent(); 31 assert_array_equals(events, ["watcher2 cancel[cancelable=true]", "watcher2 cancel[cancelable=false]", "watcher2 close"]); 32 33 await sendCloseRequest(); 34 await waitForPotentialCloseEvent(); 35 assert_array_equals(events, ["watcher2 cancel[cancelable=true]", "watcher2 cancel[cancelable=false]", "watcher2 close", "watcher1 cancel[cancelable=false]", "watcher1 close"]); 36 }, "Create a close watcher without user activation; create a close watcher with user activation that preventDefault()s cancel; send user activation"); 37 </script>