activation-trigger-mouse-right.html (2469B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#activation-triggering-input-event"> 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 <script src="resources/utils.js"></script> 11 </head> 12 <body onload="runTests()"> 13 <h1>Test for right-click activation trigger</h1> 14 <p>Tests user activation from a mouse right-click.</p> 15 <ol id="instructions"> 16 <li>Right-click anywhere in the document. 17 </ol> 18 <script> 19 function runTests() { 20 promise_test(async () => { 21 var actions = new test_driver.Actions(); 22 actions.pointerMove(0, 0, {origin: document.body}) 23 .pointerDown({button: actions.ButtonType.RIGHT}) 24 .pointerUp({button: actions.ButtonType.RIGHT}) 25 .send(); 26 27 // In most non-Windows platforms the right-click context-menu appears on mousedown, so 28 // mouseup and auxclick events are not received by the page if the menu is modal. We 29 // are suppressing the context-menu to guarantee receiving those later events. 30 document.body.addEventListener("contextmenu", e => e.preventDefault()); 31 32 let mousedown_event = getEvent('mousedown'); 33 let mouseup_event = getEvent('mouseup'); 34 let auxclick_event = getEvent('auxclick'); 35 let contextmenu_event = getEvent('contextmenu'); 36 37 await mousedown_event; 38 let consumed = await consumeTransientActivation(); 39 assert_true(consumed, 40 "mousedown event should result in activation"); 41 42 await mouseup_event; 43 consumed = await consumeTransientActivation(); 44 assert_false(consumed, 45 "mouseup should have no activation after mousedown consumption"); 46 47 await auxclick_event; 48 consumed = await consumeTransientActivation(); 49 assert_false(consumed, 50 "auxclick should have no activation after mousedown consumption"); 51 52 await contextmenu_event; 53 consumed = await consumeTransientActivation(); 54 assert_false(consumed, 55 "contextmenu should have no activation after mousedown consumption"); 56 }, "Activation through right-click mouse event"); 57 } 58 </script> 59 </body> 60 </html>