| <!DOCTYPE html> |
| <title>Test Context Menu Key, Shift+F10 with Modifiers</title> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <a href="#" id="anchor">Anchor</a> |
| <script> |
| test(function() { |
| assert_not_equals(window.eventSender, undefined, 'This test requires eventSender.'); |
| |
| var contextMenuFired = false; |
| var anchor = document.getElementById('anchor'); |
| anchor.addEventListener('contextmenu', () => contextMenuFired = true); |
| |
| function testContextMenuEvent(key, modifiers, shouldFire) { |
| contextMenuFired = false; |
| anchor.focus(); |
| eventSender.keyDown(key, modifiers); |
| // Esc key to hide context menu |
| eventSender.keyDown("Escape"); |
| assert_equals(contextMenuFired, shouldFire, `${key}+${modifiers} opens Context Menu:${shouldFire}.`); |
| } |
| |
| testContextMenuEvent('ContextMenu', [], true); |
| testContextMenuEvent('ContextMenu', ['numLockOn'], true); |
| testContextMenuEvent('ContextMenu', ['capsLockOn'], true); |
| testContextMenuEvent('ContextMenu', ['altKey'], false); |
| testContextMenuEvent('ContextMenu', ['ctrlKey'], false); |
| testContextMenuEvent('ContextMenu', ['shiftKey'], false); |
| |
| testContextMenuEvent('F10', ['shiftKey'], true); |
| testContextMenuEvent('F10', ['shiftKey', 'numLockOn'], true); |
| testContextMenuEvent('F10', ['shiftKey', 'capsLockOn'], true); |
| testContextMenuEvent('F10', ['shiftKey', 'altKey'], false); |
| testContextMenuEvent('F10', ['shiftKey', 'ctrlKey'], false); |
| }, 'Context Menu keys should allow NumLock/CapsLock/etc but not other modifiers.'); |
| </script> |