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

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

Issue 2202133002: MD WebUI: Do not restore focus from <cr-shared-menu> when closing with tap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: chrome/test/data/webui/cr_elements/cr_shared_menu_tests.js
diff --git a/chrome/test/data/webui/cr_elements/cr_shared_menu_tests.js b/chrome/test/data/webui/cr_elements/cr_shared_menu_tests.js
index 59747fa8033c0def3adb8cd1b4141347c3cfc98f..25ecbe784f29595cd149ac7542e0a8c2d37ee462 100644
--- a/chrome/test/data/webui/cr_elements/cr_shared_menu_tests.js
+++ b/chrome/test/data/webui/cr_elements/cr_shared_menu_tests.js
@@ -7,6 +7,7 @@ suite('cr-shared-menu', function() {
var menu;
var button;
+ var button2;
var item1;
var item2;
@@ -42,8 +43,14 @@ suite('cr-shared-menu', function() {
menu.toggleMenu(button, {});
});
+ button2 = document.createElement('button');
+ button2.addEventListener('tap', function() {
+ menu.toggleMenu(button2, {});
+ });
+
document.body.appendChild(menu);
document.body.appendChild(button);
+ document.body.appendChild(button2);
});
test('opening and closing menu', function(done) {
@@ -57,12 +64,17 @@ suite('cr-shared-menu', function() {
MockInteractions.tap(document.body);
assertFalse(menu.menuOpen);
- MockInteractions.tap(button);
- assertTrue(menu.menuOpen);
+ done();
+ });
+ });
+ test('open and close menu with escape', function(done) {
+ MockInteractions.tap(button);
+ assertTrue(menu.menuOpen);
+ afterOpen(function() {
// Pressing escape should close the menu.
MockInteractions.pressAndReleaseKeyOn(menu, 27);
- assertTrue(menu.menuOpen);
+ assertFalse(menu.menuOpen);
done();
});
});
@@ -86,6 +98,23 @@ suite('cr-shared-menu', function() {
});
});
+ test('refocus latest button on close', function(done) {
+ // Regression test for crbug.com/628080.
+ button.focus();
+ MockInteractions.tap(button);
+
+ afterOpen(function() {
+ button2.focus();
+ MockInteractions.tap(button2);
+
+ afterOpen(function() {
+ menu.closeMenu();
+ assertEquals(button2, document.activeElement);
+ done();
+ });
+ });
+ });
+
test('closeMenu does not refocus button when focus moves', function(done) {
var input = document.createElement('input');
document.body.appendChild(input);
« no previous file with comments | « chrome/browser/resources/md_history/list_container.js ('k') | ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698