From ae40b572f534c3438e9d28ee9cf837531476ff17 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Fri, 2 Oct 2009 21:17:45 +0000 Subject: 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 --- chrome/browser/browser_focus_uitest.cc | 38 ++++++++++++++++++++++++++++++ chrome/browser/views/frame/browser_view.cc | 2 -- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'chrome') 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 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { } } +// 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(); diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index a6b874a..a626250 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1226,8 +1226,6 @@ void BrowserView::TabSelectedAt(TabContents* old_contents, // We only restore focus if our window is visible, to avoid invoking blur // handlers when we are eventually shown. new_contents->view()->RestoreFocus(); - if (new_contents->find_ui_active()) - browser_->find_bar()->find_bar()->SetFocusAndSelection(); } // Update all the UI bits. -- cgit v1.1