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

Side by Side Diff: chrome/test/data/webui/cr_elements/cr_action_menu_test.js

Issue 2464873003: WebUI: Return focus to anchor element when cr-action-menu is closed. (Closed)
Patch Set: Resolve conflicts. Created 4 years, 1 month 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 /** @fileoverview Tests for cr-action-menu element. */ 5 /** @fileoverview Tests for cr-action-menu element. */
6 suite('CrActionMenu', function() { 6 suite('CrActionMenu', function() {
7 /** @type {?CrActionMenuElement} */ 7 /** @type {?CrActionMenuElement} */
8 var menu = null; 8 var menu = null;
9 9
10 /** @type {?NodeList<HTMLElement>} */ 10 /** @type {?NodeList<HTMLElement>} */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }); 86 });
87 87
88 test('close on resize', function() { 88 test('close on resize', function() {
89 menu.showAt(document.querySelector('#dots')); 89 menu.showAt(document.querySelector('#dots'));
90 assertTrue(menu.open); 90 assertTrue(menu.open);
91 91
92 window.dispatchEvent(new CustomEvent('resize')); 92 window.dispatchEvent(new CustomEvent('resize'));
93 assertFalse(menu.open); 93 assertFalse(menu.open);
94 }); 94 });
95 95
96 test('close on Tab', function() { 96 /** @param {string} key The key to use for closing. */
97 menu.showAt(document.querySelector('#dots')); 97 function testFocusAfterClosing(key) {
98 assertTrue(menu.open); 98 return new Promise(function(resolve) {
99 var dots = document.querySelector('#dots');
100 menu.showAt(dots);
101 assertTrue(menu.open);
99 102
100 MockInteractions.keyDownOn(menu, 'Tab', [], 'Tab'); 103 // Check that focus returns to the anchor element.
101 assertFalse(menu.open); 104 dots.addEventListener('focus', resolve);
105 MockInteractions.keyDownOn(menu, key, [], key);
106 assertFalse(menu.open);
107 });
108 }
109
110 test('close on Tab', function() { return testFocusAfterClosing('Tab'); });
111 test('close on Escape', function() {
112 return testFocusAfterClosing('Escape');
102 }); 113 });
103 }); 114 });
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