Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/context-menu-key-shift-f10-prevent-default.html

Issue 2160983003: [ContextMenu] Shift+F10 should trigger contextmenu on keydown to match system behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Test Context Menu Key, Shift+F10 behavior when preventing default</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <a href="#" id="anchor">Anchor</a>
6 <script>
7 test(function() {
8 assert_not_equals(window.eventSender, undefined, 'This test requires eventSe nder.');
9
10 var contextMenuFired = false;
11 var preventKeydown = false;
12 var preventKeyup = false;
13 var anchor = document.getElementById('anchor');
14 anchor.addEventListener('contextmenu', () => contextMenuFired = true);
15 anchor.addEventListener('keydown', event => preventKeydown ? event.preventDe fault() : true);
16 anchor.addEventListener('keyup', event => preventKeyup ? event.preventDefaul t() : true);
17
18 function testContextMenuEvent(key, modifiers, shouldFire, shouldPreventKeydo wn, shouldPreventKeyup) {
19 contextMenuFired = false;
20 preventKeydown = shouldPreventKeydown;
21 preventKeyup = shouldPreventKeyup;
22 anchor.focus();
23 eventSender.keyDown(key, modifiers);
24 // Esc key to hide context menu
25 eventSender.keyDown("Escape");
26 assert_equals(contextMenuFired, shouldFire, `${key}+${modifiers} opens C ontext Menu:${shouldFire} PreventKeydown:${shouldPreventKeydown} PreventKeyup:${ shouldPreventKeyup}.`);
27 }
28
29 // Shift+F10 should always bind to keydown.
30 testContextMenuEvent('F10', ['shiftKey'], true, false, false);
31 testContextMenuEvent('F10', ['shiftKey'], false, true, false);
32 testContextMenuEvent('F10', ['shiftKey'], true, false, true);
33
34 // ContextMenu key should bind to keyup on Windows and keydown on other plat forms.
35 testContextMenuEvent('ContextMenu', [], true, false, false);
36 const isWin = navigator.platform.indexOf('Win') == 0;
37 if (isWin) {
38 testContextMenuEvent('ContextMenu', [], true, true, false);
39 testContextMenuEvent('ContextMenu', [], false, false, true);
40 } else {
41 testContextMenuEvent('ContextMenu', [], false, true, false);
42 testContextMenuEvent('ContextMenu', [], true, false, true);
43 }
44 }, 'Shift+F10 should bind to keydown, ContextMenu key should bind to keyup only on Windows.');
45 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/NeverFixTests ('k') | third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698