| OLD | NEW |
| 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 Loading... |
| 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 function makeMouseoverEvent(node) { |
| 133 var e = new MouseEvent('mouseover', {bubbles: true}); |
| 134 node.dispatchEvent(e); |
| 135 } |
| 136 |
| 137 menu.showAt(document.querySelector('#dots')); |
| 138 |
| 139 // Moving mouse on option 1 should focus it. |
| 140 assertNotEquals(items[0], menu.root.activeElement); |
| 141 makeMouseoverEvent(items[0]); |
| 142 assertEquals(items[0], menu.root.activeElement); |
| 143 |
| 144 // Moving mouse on the menu (not on option) should focus the menu. |
| 145 makeMouseoverEvent(menu); |
| 146 assertNotEquals(items[0], menu.root.activeElement); |
| 147 assertEquals(menu, document.activeElement); |
| 148 |
| 149 // Mouse movements should override keyboard focus. |
| 150 down(); |
| 151 down(); |
| 152 assertEquals(items[1], menu.root.activeElement); |
| 153 makeMouseoverEvent(items[0]); |
| 154 assertEquals(items[0], menu.root.activeElement); |
| 155 }); |
| 130 }); | 156 }); |
| OLD | NEW |