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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/NeverFixTests ('k') | third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/events/context-menu-key-shift-f10-prevent-default.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/context-menu-key-shift-f10-prevent-default.html b/third_party/WebKit/LayoutTests/fast/events/context-menu-key-shift-f10-prevent-default.html
new file mode 100644
index 0000000000000000000000000000000000000000..7c0fd5e044cf2e4f86f5d1596bdcdd31827f6deb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/context-menu-key-shift-f10-prevent-default.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<title>Test Context Menu Key, Shift+F10 behavior when preventing default</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 preventKeydown = false;
+ var preventKeyup = false;
+ var anchor = document.getElementById('anchor');
+ anchor.addEventListener('contextmenu', () => contextMenuFired = true);
+ anchor.addEventListener('keydown', event => preventKeydown ? event.preventDefault() : true);
+ anchor.addEventListener('keyup', event => preventKeyup ? event.preventDefault() : true);
+
+ function testContextMenuEvent(key, modifiers, shouldFire, shouldPreventKeydown, shouldPreventKeyup) {
+ contextMenuFired = false;
+ preventKeydown = shouldPreventKeydown;
+ preventKeyup = shouldPreventKeyup;
+ 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} PreventKeydown:${shouldPreventKeydown} PreventKeyup:${shouldPreventKeyup}.`);
+ }
+
+ // Shift+F10 should always bind to keydown.
+ testContextMenuEvent('F10', ['shiftKey'], true, false, false);
+ testContextMenuEvent('F10', ['shiftKey'], false, true, false);
+ testContextMenuEvent('F10', ['shiftKey'], true, false, true);
+
+ // ContextMenu key should bind to keyup on Windows and keydown on other platforms.
+ testContextMenuEvent('ContextMenu', [], true, false, false);
+ const isWin = navigator.platform.indexOf('Win') == 0;
+ if (isWin) {
+ testContextMenuEvent('ContextMenu', [], true, true, false);
+ testContextMenuEvent('ContextMenu', [], false, false, true);
+ } else {
+ testContextMenuEvent('ContextMenu', [], false, true, false);
+ testContextMenuEvent('ContextMenu', [], true, false, true);
+ }
+}, 'Shift+F10 should bind to keydown, ContextMenu key should bind to keyup only on Windows.');
+</script>
« 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