Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/events/contextmenu-follows-focus.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/events/contextmenu-follows-focus.html b/third_party/WebKit/LayoutTests/fast/events/contextmenu-follows-focus.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c5943c2c9c9194d4132f4ad5725d7d036451d6e5 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/events/contextmenu-follows-focus.html |
| @@ -0,0 +1,37 @@ |
| +<!DOCTYPE html> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script> |
| +var context_for_menu; |
| +function catchContextMenu(event) { |
| + context_for_menu = event.currentTarget.tagName; |
| +} |
| +</script> |
| + |
| +<body> |
|
bokan
2017/05/11 22:19:14
Nit: As per layout test style (https://chromium.go
|
| +<input oncontextmenu="catchContextMenu(event);"> |
| +<a href="www" oncontextmenu="catchContextMenu(event);">A link</a> |
| +</body> |
| + |
| +<script> |
| +test(function() { |
| + if (!window.eventSender) { |
|
yosin_UTC9
2017/05/12 04:25:06
nit: We found shorter one: |assert_exists(window,
|
| + document.write('This test requires eventSender.'); |
| + return false; |
| + } |
| + |
| + document.querySelector('INPUT').focus(); |
| + eventSender.keyDown('ContextMenu'); |
| + assert_equals(context_for_menu, 'INPUT', |
| + 'ContextMenu should use the focused input field as context.'); |
| + |
| + // Hide INPUT's context menu before we display A's context menu. |
| + eventSender.keyDown('Escape'); |
| + |
| + document.querySelector('A').focus(); |
| + eventSender.keyDown('ContextMenu'); |
| + assert_equals(context_for_menu, 'A', |
| + 'ContextMenu should use the focused link as context.'); |
| + |
| +}, 'ContextMenu should always follow focused element.'); |
| +</script> |