Find-in-bar would steal focus when switching tab.
BUG=23296
TEST=See bug.
Review URL: http://codereview.chromium.org/243073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27901 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 5e3a111..ca3de5e 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -344,6 +344,44 @@
}
}
+// Tabs remember focus with find-in-page box.
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocusFindInPage) {
+ HTTPTestServer* server = StartHTTPServer();
+
+ // First we navigate to our test page.
+ GURL url = server->TestServerPageW(kSimplePage);
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ browser()->Find();
+ ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
+ ASCIIToUTF16("a"), true, false, NULL);
+ CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
+
+ // Focus the location bar.
+ browser()->FocusLocationBar();
+
+ // Create a 2nd tab.
+ browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, -1,
+ false, NULL);
+
+ // Focus should be on the recently opened tab page.
+ CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW);
+
+ // Select 1st tab, focus should still be on the location-bar.
+ // (bug http://crbug.com/23296)
+ browser()->SelectTabContentsAt(0, true);
+ CheckViewHasFocus(VIEW_ID_LOCATION_BAR);
+
+ // Now open the find box again, switch to another tab and come back, the focus
+ // should return to the find box.
+ browser()->Find();
+ CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
+ browser()->SelectTabContentsAt(1, true);
+ CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW);
+ browser()->SelectTabContentsAt(0, true);
+ CheckViewHasFocus(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
+}
+
// Background window does not steal focus.
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) {
HTTPTestServer* server = StartHTTPServer();