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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Tests for cr-action-menu element. Runs as an interactive UI 6 * @fileoverview Tests for cr-action-menu element. Runs as an interactive UI
7 * test, since many of these tests check focus behavior. 7 * test, since many of these tests check focus behavior.
8 */ 8 */
9 suite('CrActionMenu', function() { 9 suite('CrActionMenu', function() {
10 /** @type {?CrActionMenuElement} */ 10 /** @type {?CrActionMenuElement} */
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 dots.addEventListener('focus', resolve); 120 dots.addEventListener('focus', resolve);
121 MockInteractions.keyDownOn(menu, key, [], key); 121 MockInteractions.keyDownOn(menu, key, [], key);
122 assertFalse(menu.open); 122 assertFalse(menu.open);
123 }); 123 });
124 } 124 }
125 125
126 test('close on Tab', function() { return testFocusAfterClosing('Tab'); }); 126 test('close on Tab', function() { return testFocusAfterClosing('Tab'); });
127 test('close on Escape', function() { 127 test('close on Escape', function() {
128 return testFocusAfterClosing('Escape'); 128 return testFocusAfterClosing('Escape');
129 }); 129 });
130
131 test('mouse movement focus options', function() {
132 // MockInterations doesn't have any mouseover triggers, so copying
133 // makeMouseEvent code over to make new mouseover events.
134 var HAS_NEW_MOUSE = (function() {
135 var has = false;
136 try {
137 has = Boolean(new MouseEvent('x'));
138 } catch (_) {
139 }
140 return has;
141 })();
142
143 function makeMouseoverEvent(node) {
144 if (HAS_NEW_MOUSE) {
145 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.
146 } else {
147 e = document.createEvent('MouseEvent');
148 e.initMouseEvent(
149 'mouseover', true, /* bubbles */
150 true, /* cancelable */
151 null, /* view */
152 null, /* detail */
153 0, /* screenX */
154 0, /* screenY */
155 0, /* clientX */
156 0, /* clientY */
157 false, /*ctrlKey */
158 false, /*altKey */
159 false, /*shiftKey */
160 false, /*metaKey */
161 0, /*button */
162 null /*relatedTarget*/);
163 }
164
165 node.dispatchEvent(e);
166 }
167
168 menu.showAt(document.querySelector('#dots'));
169
170 // Moving mouse on option 1 should focus it
171 assertNotEquals(items[0], menu.root.activeElement);
172 makeMouseoverEvent(items[0]);
173 assertEquals(items[0], menu.root.activeElement);
174
175 // Moving mouse on the menu (not on option) should focus the menu
176 makeMouseoverEvent(menu);
177 assertNotEquals(items[0], menu.root.activeElement);
178 assertEquals(menu, document.activeElement);
179
180 // Mouse movements should override keyboard focus
181 down();
182 down();
183 assertEquals(items[1], menu.root.activeElement);
184 makeMouseoverEvent(items[0]);
185 assertEquals(items[0], menu.root.activeElement);
186 });
130 }); 187 });
OLDNEW
« 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