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

Unified Diff: chrome/browser/browser_focus_uitest.cc

Issue 160206: Fix focus bug when reloading crashed tab (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_focus_uitest.cc
===================================================================
--- chrome/browser/browser_focus_uitest.cc (revision 21658)
+++ chrome/browser/browser_focus_uitest.cc (working copy)
@@ -504,7 +504,7 @@
EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()->
HasFocus());
- // Let's show an interstitial.erstitial
+ // Let's show an interstitial.
TestInterstitialPage* interstitial_page =
new TestInterstitialPage(browser()->GetSelectedTabContents(),
true, GURL("http://interstitial.com"));
@@ -637,3 +637,52 @@
EXPECT_EQ(browser_view->GetLocationBarView(),
focus_manager->GetFocusedView());
}
+
+// Tests that focus goes where expected when using reload.
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
+ HTTPTestServer* server = StartHTTPServer();
+
+ HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(hwnd);
+ ASSERT_TRUE(browser_view);
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(hwnd);
+ ASSERT_TRUE(focus_manager);
+
+ // Open the new tab, reload.
+ browser()->NewTab();
+ ui_test_utils::ReloadCurrentTab(browser());
+ // Focus should stay on the location bar.
+ EXPECT_EQ(browser_view->GetLocationBarView(),
+ focus_manager->GetFocusedView());
+
+ // Open a regular page, focus the location bar, reload.
+ ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage));
+ browser_view->GetLocationBarView()->FocusLocation();
+ EXPECT_EQ(browser_view->GetLocationBarView(),
+ focus_manager->GetFocusedView());
+ ui_test_utils::ReloadCurrentTab(browser());
+ // Focus should now be on the tab contents.
+ EXPECT_EQ(browser_view->GetTabContentsContainerView(),
+ focus_manager->GetFocusedView());
+}
+
+// Tests that focus goes where expected when using reload on a crashed tab.
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) {
+ HTTPTestServer* server = StartHTTPServer();
+
+ HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(hwnd);
+ ASSERT_TRUE(browser_view);
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(hwnd);
+ ASSERT_TRUE(focus_manager);
+
+ // Open a regular page, crash, reload.
+ ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage));
+ ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
+ ui_test_utils::ReloadCurrentTab(browser());
+ // Focus should now be on the tab contents.
+ EXPECT_EQ(browser_view->GetTabContentsContainerView(),
+ focus_manager->GetFocusedView());
+}
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698