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

Unified Diff: chrome/test/data/webui/cr_elements/cr_action_menu_test.js

Issue 2801453002: MD Settings: mouse movements should focus cr-action-menu items (Closed)
Patch Set: move off-by-one fix to another CL Created 3 years, 8 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 | « no previous file | ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/cr_elements/cr_action_menu_test.js
diff --git a/chrome/test/data/webui/cr_elements/cr_action_menu_test.js b/chrome/test/data/webui/cr_elements/cr_action_menu_test.js
index 635bd09c53790da842d12813214dc175c48d99f5..1dff3a2e7293509df2aa2ebccd70aa2ed8c05450 100644
--- a/chrome/test/data/webui/cr_elements/cr_action_menu_test.js
+++ b/chrome/test/data/webui/cr_elements/cr_action_menu_test.js
@@ -127,4 +127,61 @@ suite('CrActionMenu', function() {
test('close on Escape', function() {
return testFocusAfterClosing('Escape');
});
+
+ test('mouse movement focus options', function() {
+ // MockInterations doesn't have any mouseover triggers, so copying
+ // makeMouseEvent code over to make new mouseover events.
+ var HAS_NEW_MOUSE = (function() {
+ var has = false;
+ try {
+ has = Boolean(new MouseEvent('x'));
+ } catch (_) {
+ }
+ return has;
+ })();
+
+ function makeMouseoverEvent(node) {
+ if (HAS_NEW_MOUSE) {
+ var e = new MouseEvent('mouseover', {bubbles: true});
Dan Beam 2017/04/05 20:59:48 this is the only code you need
scottchen 2017/04/05 21:17:01 Done.
+ } else {
+ e = document.createEvent('MouseEvent');
+ e.initMouseEvent(
+ 'mouseover', true, /* bubbles */
+ true, /* cancelable */
+ null, /* view */
+ null, /* detail */
+ 0, /* screenX */
+ 0, /* screenY */
+ 0, /* clientX */
+ 0, /* clientY */
+ false, /*ctrlKey */
+ false, /*altKey */
+ false, /*shiftKey */
+ false, /*metaKey */
+ 0, /*button */
+ null /*relatedTarget*/);
+ }
+
+ node.dispatchEvent(e);
+ }
+
+ menu.showAt(document.querySelector('#dots'));
+
+ // Moving mouse on option 1 should focus it
+ assertNotEquals(items[0], menu.root.activeElement);
+ makeMouseoverEvent(items[0]);
+ assertEquals(items[0], menu.root.activeElement);
+
+ // Moving mouse on the menu (not on option) should focus the menu
+ makeMouseoverEvent(menu);
+ assertNotEquals(items[0], menu.root.activeElement);
+ assertEquals(menu, document.activeElement);
+
+ // Mouse movements should override keyboard focus
+ down();
+ down();
+ assertEquals(items[1], menu.root.activeElement);
+ makeMouseoverEvent(items[0]);
+ assertEquals(items[0], menu.root.activeElement);
+ });
});
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698