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

Unified Diff: chrome/test/data/webui/media_router/media_router_container_filter_tests.js

Issue 2096733002: Fix the bug where focus jumps around on the media router sink list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add selectIndex to externs.js Created 4 years, 6 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
« no previous file with comments | « chrome/browser/resources/media_router/externs.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/media_router/media_router_container_filter_tests.js
diff --git a/chrome/test/data/webui/media_router/media_router_container_filter_tests.js b/chrome/test/data/webui/media_router/media_router_container_filter_tests.js
index 5f54c7a5d07ade109d164c6b72251ca2bbbde37d..c01a719281a8e75b4cb75107dc2baa82f188d32b 100644
--- a/chrome/test/data/webui/media_router/media_router_container_filter_tests.js
+++ b/chrome/test/data/webui/media_router/media_router_container_filter_tests.js
@@ -191,27 +191,41 @@ cr.define('media_router_container_filter', function() {
// Tests that pressing the Escape key in the FILTER view when a sink has
// keyboard focus returns |container| to the SINK_LIST view and focuses
- // the correct sink in the list.
+ // the correct sink in the list. We need to check that the same sink
+ // remains both focused and selected, where focused refers to the
+ // "focused" HTML attribute, and selected refers to the Polymer "selected"
+ // attribute of the paper-menu for the sink list.
test('filter view escape key on menu item', function(done) {
+ var focusIndex = 2;
container.allSinks = fakeSinkList;
MockInteractions.tap(container.$$('#sink-search-icon'));
setTimeout(function() {
- var item = container.$$('#search-results')
- .querySelectorAll('paper-item')[1];
- item.focus();
- var focusedSuccess = item.focused;
- pressEscapeOnElement(item);
- checkCurrentView(media_router.MediaRouterView.SINK_LIST);
- setTimeout(function() {
- item = container.$$('#sink-list-view')
- .querySelectorAll('paper-item')[1];
- // TODO(crbug.com/608551): This condition handles flakiness around
- // the search item getting focus earlier. If it doesn't get focus,
- // the logic that changes focus from a search item to a sink list
- // item obviously won't do anything.
- assertEquals(focusedSuccess, item.focused);
+ var searchResults = container.$$('#search-results');
+ // Use the Polymer method for selecting (and focusing on) a sink
+ searchResults.selectIndex(focusIndex);
+ var itemInSearch =
+ searchResults.querySelectorAll('paper-item')[focusIndex];
+ // TODO(crbug.com/608551): This condition handles flakiness around
+ // the search item getting focus earlier. If it doesn't get focus,
+ // the logic that changes focus from a search item to a sink list
+ // item obviously won't do anything.
+ if (itemInSearch.focused) {
+ var selectedIndexInSearch = searchResults.selected;
+ pressEscapeOnElement(itemInSearch);
+ checkCurrentView(media_router.MediaRouterView.SINK_LIST);
+ chainOnAnimationPromise(function() {
+ var sinkList = container.$$('#sink-list');
+ var item = sinkList.querySelectorAll('paper-item')[focusIndex];
+
+ // Check that the "focused" HTML attribute persists.
+ assertTrue(item.focused);
+ // Check that the "selected" Polymer attribute persists.
+ assertEquals(sinkList.selected, selectedIndexInSearch);
+ done();
+ });
+ } else {
done();
- });
+ }
});
});
« no previous file with comments | « chrome/browser/resources/media_router/externs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698