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

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

Issue 2272553002: MD WebUI: Use arrow keys for navigation in cr-shared-menu, close on tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 c35bb2bbe2ae9d4ee6a7d4ec99dfa40ceaafc6be..39755ecd11e2195899c3860098a1a9d00e0c463a 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
@@ -16,7 +16,9 @@ suite('cr-shared-menu', function() {
function afterOpen(callback) {
menu.addEventListener('iron-overlay-opened', function f() {
menu.removeEventListener('iron-overlay-opened', f);
- callback();
+ // paper-listbox applies focus after opening with microtask timing.
+ // Delay until that has happened:
+ setTimeout(callback, 0);
});
}
@@ -146,20 +148,28 @@ suite('cr-shared-menu', function() {
});
});
- test('focus is trapped inside the menu', function(done) {
+ test('tab closes menu', function(done) {
button.focus();
MockInteractions.tap(button);
afterOpen(function() {
- // Simulate shift-tab on first element.
- assertEquals(item1, menu.shadowRoot.activeElement);
- MockInteractions.pressAndReleaseKeyOn(item1, 9, ['shift']);
- assertEquals(item3, menu.shadowRoot.activeElement);
+ MockInteractions.pressAndReleaseKeyOn(item1, 9);
+ afterClose(function() {
+ done();
+ });
+ });
+ });
- // Simulate tab on last element.
- MockInteractions.pressAndReleaseKeyOn(item3, 9);
- assertEquals(item1, menu.shadowRoot.activeElement);
+ test('up and down change focus', function(done) {
+ button.focus();
+ MockInteractions.tap(button);
+
+ afterOpen(function() {
+ assertEquals(item1, document.activeElement);
+ MockInteractions.pressAndReleaseKeyOn(item1, 40);
+ assertEquals(item2, document.activeElement);
+ MockInteractions.pressAndReleaseKeyOn(item2, 38);
done();
});
});

Powered by Google App Engine
This is Rietveld 408576698