| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" |
| 7 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" |
| 10 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 11 #include "chrome/browser/automation/ui_controls.h" | 13 #include "chrome/browser/automation/ui_controls.h" |
| 12 #include "chrome/browser/browser.h" | 14 #include "chrome/browser/browser.h" |
| 13 #include "chrome/browser/browser_window.h" | 15 #include "chrome/browser/browser_window.h" |
| 14 #include "chrome/browser/renderer_host/render_view_host.h" | 16 #include "chrome/browser/renderer_host/render_view_host.h" |
| 15 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 17 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 16 #include "chrome/browser/tab_contents/interstitial_page.h" | 18 #include "chrome/browser/tab_contents/interstitial_page.h" |
| 17 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
| 18 #include "chrome/browser/tab_contents/tab_contents_view.h" | 20 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 19 #include "chrome/browser/view_ids.h" | 21 #include "chrome/browser/view_ids.h" |
| 20 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/test/in_process_browser_test.h" | 23 #include "chrome/test/in_process_browser_test.h" |
| 22 #include "chrome/test/ui_test_utils.h" | 24 #include "chrome/test/ui_test_utils.h" |
| 25 #include "net/test/test_server.h" |
| 23 | 26 |
| 24 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) | 27 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) |
| 25 #include "views/focus/focus_manager.h" | 28 #include "views/focus/focus_manager.h" |
| 26 #include "views/view.h" | 29 #include "views/view.h" |
| 27 #include "views/window/window.h" | 30 #include "views/window/window.h" |
| 28 #endif | 31 #endif |
| 29 | 32 |
| 30 #if defined(TOOLKIT_VIEWS) | 33 #if defined(TOOLKIT_VIEWS) |
| 31 #include "chrome/browser/views/frame/browser_view.h" | 34 #include "chrome/browser/views/frame/browser_view.h" |
| 32 #include "chrome/browser/views/location_bar/location_bar_view.h" | 35 #include "chrome/browser/views/location_bar/location_bar_view.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 178 |
| 176 ClickOnView(VIEW_ID_TAB_CONTAINER); | 179 ClickOnView(VIEW_ID_TAB_CONTAINER); |
| 177 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 180 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 178 | 181 |
| 179 ClickOnView(VIEW_ID_LOCATION_BAR); | 182 ClickOnView(VIEW_ID_LOCATION_BAR); |
| 180 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | 183 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
| 181 } | 184 } |
| 182 | 185 |
| 183 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) { | 186 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) { |
| 184 BringBrowserWindowToFront(); | 187 BringBrowserWindowToFront(); |
| 185 HTTPTestServer* server = StartHTTPServer(); | 188 net::HTTPTestServer* server = StartHTTPServer(); |
| 186 ASSERT_TRUE(server); | 189 ASSERT_TRUE(server); |
| 187 | 190 |
| 188 // First we navigate to our test page. | 191 // First we navigate to our test page. |
| 189 GURL url = server->TestServerPage(kSimplePage); | 192 GURL url = server->TestServerPage(kSimplePage); |
| 190 ui_test_utils::NavigateToURL(browser(), url); | 193 ui_test_utils::NavigateToURL(browser(), url); |
| 191 | 194 |
| 192 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 195 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
| 193 | 196 |
| 194 // The focus should be on the Tab contents. | 197 // The focus should be on the Tab contents. |
| 195 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 198 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 focus_manager2->GetFocusedView()); | 243 focus_manager2->GetFocusedView()); |
| 241 | 244 |
| 242 // Close the 2nd browser to avoid a DCHECK(). | 245 // Close the 2nd browser to avoid a DCHECK(). |
| 243 browser_view2->Close(); | 246 browser_view2->Close(); |
| 244 #endif | 247 #endif |
| 245 } | 248 } |
| 246 | 249 |
| 247 // Tabs remember focus. | 250 // Tabs remember focus. |
| 248 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { | 251 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { |
| 249 BringBrowserWindowToFront(); | 252 BringBrowserWindowToFront(); |
| 250 HTTPTestServer* server = StartHTTPServer(); | 253 net::HTTPTestServer* server = StartHTTPServer(); |
| 251 ASSERT_TRUE(server); | 254 ASSERT_TRUE(server); |
| 252 | 255 |
| 253 // First we navigate to our test page. | 256 // First we navigate to our test page. |
| 254 GURL url = server->TestServerPage(kSimplePage); | 257 GURL url = server->TestServerPage(kSimplePage); |
| 255 ui_test_utils::NavigateToURL(browser(), url); | 258 ui_test_utils::NavigateToURL(browser(), url); |
| 256 | 259 |
| 257 // Create several tabs. | 260 // Create several tabs. |
| 258 for (int i = 0; i < 4; ++i) { | 261 for (int i = 0; i < 4; ++i) { |
| 259 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, | 262 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, |
| 260 TabStripModel::ADD_SELECTED, NULL, std::string()); | 263 TabStripModel::ADD_SELECTED, NULL, std::string()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 true, false, false, | 319 true, false, false, |
| 317 new MessageLoop::QuitTask()); | 320 new MessageLoop::QuitTask()); |
| 318 ui_test_utils::RunMessageLoop(); | 321 ui_test_utils::RunMessageLoop(); |
| 319 } | 322 } |
| 320 } | 323 } |
| 321 } | 324 } |
| 322 | 325 |
| 323 // Tabs remember focus with find-in-page box. | 326 // Tabs remember focus with find-in-page box. |
| 324 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) { | 327 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) { |
| 325 BringBrowserWindowToFront(); | 328 BringBrowserWindowToFront(); |
| 326 HTTPTestServer* server = StartHTTPServer(); | 329 net::HTTPTestServer* server = StartHTTPServer(); |
| 327 ASSERT_TRUE(server); | 330 ASSERT_TRUE(server); |
| 328 | 331 |
| 329 // First we navigate to our test page. | 332 // First we navigate to our test page. |
| 330 GURL url = server->TestServerPage(kSimplePage); | 333 GURL url = server->TestServerPage(kSimplePage); |
| 331 ui_test_utils::NavigateToURL(browser(), url); | 334 ui_test_utils::NavigateToURL(browser(), url); |
| 332 | 335 |
| 333 browser()->Find(); | 336 browser()->Find(); |
| 334 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), | 337 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), |
| 335 ASCIIToUTF16("a"), true, false, NULL); | 338 ASCIIToUTF16("a"), true, false, NULL); |
| 336 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 339 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 356 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 359 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 357 browser()->SelectTabContentsAt(1, true); | 360 browser()->SelectTabContentsAt(1, true); |
| 358 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 361 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 359 browser()->SelectTabContentsAt(0, true); | 362 browser()->SelectTabContentsAt(0, true); |
| 360 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 363 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 361 } | 364 } |
| 362 | 365 |
| 363 // Background window does not steal focus. | 366 // Background window does not steal focus. |
| 364 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { | 367 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { |
| 365 BringBrowserWindowToFront(); | 368 BringBrowserWindowToFront(); |
| 366 HTTPTestServer* server = StartHTTPServer(); | 369 net::HTTPTestServer* server = StartHTTPServer(); |
| 367 ASSERT_TRUE(server); | 370 ASSERT_TRUE(server); |
| 368 | 371 |
| 369 // First we navigate to our test page. | 372 // First we navigate to our test page. |
| 370 GURL url = server->TestServerPage(kSimplePage); | 373 GURL url = server->TestServerPage(kSimplePage); |
| 371 ui_test_utils::NavigateToURL(browser(), url); | 374 ui_test_utils::NavigateToURL(browser(), url); |
| 372 | 375 |
| 373 // Open a new browser window. | 376 // Open a new browser window. |
| 374 Browser* browser2 = Browser::Create(browser()->profile()); | 377 Browser* browser2 = Browser::Create(browser()->profile()); |
| 375 ASSERT_TRUE(browser2); | 378 ASSERT_TRUE(browser2); |
| 376 browser2->tabstrip_model()->delegate()->AddBlankTab(true); | 379 browser2->tabstrip_model()->delegate()->AddBlankTab(true); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 // Make sure the first browser is still active. | 416 // Make sure the first browser is still active. |
| 414 EXPECT_TRUE(focused_browser->window()->IsActive()); | 417 EXPECT_TRUE(focused_browser->window()->IsActive()); |
| 415 | 418 |
| 416 // Close the 2nd browser to avoid a DCHECK(). | 419 // Close the 2nd browser to avoid a DCHECK(). |
| 417 browser2->window()->Close(); | 420 browser2->window()->Close(); |
| 418 } | 421 } |
| 419 | 422 |
| 420 // Page cannot steal focus when focus is on location bar. | 423 // Page cannot steal focus when focus is on location bar. |
| 421 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) { | 424 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) { |
| 422 BringBrowserWindowToFront(); | 425 BringBrowserWindowToFront(); |
| 423 HTTPTestServer* server = StartHTTPServer(); | 426 net::HTTPTestServer* server = StartHTTPServer(); |
| 424 ASSERT_TRUE(server); | 427 ASSERT_TRUE(server); |
| 425 | 428 |
| 426 // Open the page that steals focus. | 429 // Open the page that steals focus. |
| 427 GURL url = server->TestServerPage(kStealFocusPage); | 430 GURL url = server->TestServerPage(kStealFocusPage); |
| 428 ui_test_utils::NavigateToURL(browser(), url); | 431 ui_test_utils::NavigateToURL(browser(), url); |
| 429 | 432 |
| 430 browser()->FocusLocationBar(); | 433 browser()->FocusLocationBar(); |
| 431 | 434 |
| 432 // Wait for the page to steal focus. | 435 // Wait for the page to steal focus. |
| 433 PlatformThread::Sleep(2000); | 436 PlatformThread::Sleep(2000); |
| 434 | 437 |
| 435 // Make sure the location bar is still focused. | 438 // Make sure the location bar is still focused. |
| 436 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | 439 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
| 437 } | 440 } |
| 438 | 441 |
| 439 // Focus traversal on a regular page. | 442 // Focus traversal on a regular page. |
| 440 // Note that this test relies on a notification from the renderer that the | 443 // Note that this test relies on a notification from the renderer that the |
| 441 // focus has changed in the page. The notification in the renderer may change | 444 // focus has changed in the page. The notification in the renderer may change |
| 442 // at which point this test would fail (see comment in | 445 // at which point this test would fail (see comment in |
| 443 // RenderWidget::didFocus()). | 446 // RenderWidget::didFocus()). |
| 444 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) { | 447 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) { |
| 445 BringBrowserWindowToFront(); | 448 BringBrowserWindowToFront(); |
| 446 HTTPTestServer* server = StartHTTPServer(); | 449 net::HTTPTestServer* server = StartHTTPServer(); |
| 447 ASSERT_TRUE(server); | 450 ASSERT_TRUE(server); |
| 448 | 451 |
| 449 // First we navigate to our test page. | 452 // First we navigate to our test page. |
| 450 GURL url = server->TestServerPage(kTypicalPage); | 453 GURL url = server->TestServerPage(kTypicalPage); |
| 451 ui_test_utils::NavigateToURL(browser(), url); | 454 ui_test_utils::NavigateToURL(browser(), url); |
| 452 | 455 |
| 453 browser()->FocusLocationBar(); | 456 browser()->FocusLocationBar(); |
| 454 | 457 |
| 455 const char* kExpElementIDs[] = { | 458 const char* kExpElementIDs[] = { |
| 456 "", // Initially no element in the page should be focused | 459 "", // Initially no element in the page should be focused |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // At this point the renderer has sent us a message asking to advance the | 533 // At this point the renderer has sent us a message asking to advance the |
| 531 // focus (as the end of the focus loop was reached in the renderer). | 534 // focus (as the end of the focus loop was reached in the renderer). |
| 532 // We need to run the message loop to process it. | 535 // We need to run the message loop to process it. |
| 533 ui_test_utils::RunAllPendingInMessageLoop(); | 536 ui_test_utils::RunAllPendingInMessageLoop(); |
| 534 } | 537 } |
| 535 } | 538 } |
| 536 | 539 |
| 537 // Focus traversal while an interstitial is showing. | 540 // Focus traversal while an interstitial is showing. |
| 538 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { | 541 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { |
| 539 BringBrowserWindowToFront(); | 542 BringBrowserWindowToFront(); |
| 540 HTTPTestServer* server = StartHTTPServer(); | 543 net::HTTPTestServer* server = StartHTTPServer(); |
| 541 ASSERT_TRUE(server); | 544 ASSERT_TRUE(server); |
| 542 | 545 |
| 543 // First we navigate to our test page. | 546 // First we navigate to our test page. |
| 544 GURL url = server->TestServerPage(kSimplePage); | 547 GURL url = server->TestServerPage(kSimplePage); |
| 545 ui_test_utils::NavigateToURL(browser(), url); | 548 ui_test_utils::NavigateToURL(browser(), url); |
| 546 | 549 |
| 547 // Focus should be on the page. | 550 // Focus should be on the page. |
| 548 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 551 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 549 | 552 |
| 550 // Let's show an interstitial. | 553 // Let's show an interstitial. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 // At this point the renderer has sent us a message asking to advance the | 625 // At this point the renderer has sent us a message asking to advance the |
| 623 // focus (as the end of the focus loop was reached in the renderer). | 626 // focus (as the end of the focus loop was reached in the renderer). |
| 624 // We need to run the message loop to process it. | 627 // We need to run the message loop to process it. |
| 625 ui_test_utils::RunAllPendingInMessageLoop(); | 628 ui_test_utils::RunAllPendingInMessageLoop(); |
| 626 } | 629 } |
| 627 } | 630 } |
| 628 | 631 |
| 629 // Focus stays on page with interstitials. | 632 // Focus stays on page with interstitials. |
| 630 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) { | 633 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) { |
| 631 BringBrowserWindowToFront(); | 634 BringBrowserWindowToFront(); |
| 632 HTTPTestServer* server = StartHTTPServer(); | 635 net::HTTPTestServer* server = StartHTTPServer(); |
| 633 ASSERT_TRUE(server); | 636 ASSERT_TRUE(server); |
| 634 | 637 |
| 635 // First we navigate to our test page. | 638 // First we navigate to our test page. |
| 636 GURL url = server->TestServerPage(kSimplePage); | 639 GURL url = server->TestServerPage(kSimplePage); |
| 637 ui_test_utils::NavigateToURL(browser(), url); | 640 ui_test_utils::NavigateToURL(browser(), url); |
| 638 | 641 |
| 639 // Page should have focus. | 642 // Page should have focus. |
| 640 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 643 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 641 EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()-> | 644 EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()-> |
| 642 HasFocus()); | 645 HasFocus()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 659 // Hide the interstitial. | 662 // Hide the interstitial. |
| 660 interstitial_page->DontProceed(); | 663 interstitial_page->DontProceed(); |
| 661 | 664 |
| 662 // Focus should be back on the original page. | 665 // Focus should be back on the original page. |
| 663 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 666 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 664 } | 667 } |
| 665 | 668 |
| 666 // Make sure Find box can request focus, even when it is already open. | 669 // Make sure Find box can request focus, even when it is already open. |
| 667 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { | 670 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { |
| 668 BringBrowserWindowToFront(); | 671 BringBrowserWindowToFront(); |
| 669 HTTPTestServer* server = StartHTTPServer(); | 672 net::HTTPTestServer* server = StartHTTPServer(); |
| 670 ASSERT_TRUE(server); | 673 ASSERT_TRUE(server); |
| 671 | 674 |
| 672 // Open some page (any page that doesn't steal focus). | 675 // Open some page (any page that doesn't steal focus). |
| 673 GURL url = server->TestServerPage(kTypicalPage); | 676 GURL url = server->TestServerPage(kTypicalPage); |
| 674 ui_test_utils::NavigateToURL(browser(), url); | 677 ui_test_utils::NavigateToURL(browser(), url); |
| 675 | 678 |
| 676 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 679 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
| 677 | 680 |
| 678 #if defined(OS_MACOSX) | 681 #if defined(OS_MACOSX) |
| 679 // Press Cmd+F, which will make the Find box open and request focus. | 682 // Press Cmd+F, which will make the Find box open and request focus. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 // Open about:blank, focus should be on the location bar. | 763 // Open about:blank, focus should be on the location bar. |
| 761 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK, | 764 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK, |
| 762 -1, TabStripModel::ADD_SELECTED, NULL, | 765 -1, TabStripModel::ADD_SELECTED, NULL, |
| 763 std::string()); | 766 std::string()); |
| 764 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | 767 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
| 765 } | 768 } |
| 766 | 769 |
| 767 // Tests that focus goes where expected when using reload. | 770 // Tests that focus goes where expected when using reload. |
| 768 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { | 771 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { |
| 769 BringBrowserWindowToFront(); | 772 BringBrowserWindowToFront(); |
| 770 HTTPTestServer* server = StartHTTPServer(); | 773 net::HTTPTestServer* server = StartHTTPServer(); |
| 771 ASSERT_TRUE(server); | 774 ASSERT_TRUE(server); |
| 772 | 775 |
| 773 // Open the new tab, reload. | 776 // Open the new tab, reload. |
| 774 browser()->NewTab(); | 777 browser()->NewTab(); |
| 775 | 778 |
| 776 ui_test_utils::RunAllPendingInMessageLoop(); | 779 ui_test_utils::RunAllPendingInMessageLoop(); |
| 777 | 780 |
| 778 browser()->Reload(CURRENT_TAB); | 781 browser()->Reload(CURRENT_TAB); |
| 779 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 782 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
| 780 // Focus should stay on the location bar. | 783 // Focus should stay on the location bar. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 795 // http://crbug.com/50025 | 798 // http://crbug.com/50025 |
| 796 #if defined(OS_CHROMEOS) && !defined(NDEBUG) | 799 #if defined(OS_CHROMEOS) && !defined(NDEBUG) |
| 797 #define MAYBE_FocusOnReloadCrashedTab DISABLED_FocusOnReloadCrashedTab | 800 #define MAYBE_FocusOnReloadCrashedTab DISABLED_FocusOnReloadCrashedTab |
| 798 #else | 801 #else |
| 799 #define MAYBE_FocusOnReloadCrashedTab FocusOnReloadCrashedTab | 802 #define MAYBE_FocusOnReloadCrashedTab FocusOnReloadCrashedTab |
| 800 #endif | 803 #endif |
| 801 | 804 |
| 802 // Tests that focus goes where expected when using reload on a crashed tab. | 805 // Tests that focus goes where expected when using reload on a crashed tab. |
| 803 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnReloadCrashedTab) { | 806 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnReloadCrashedTab) { |
| 804 BringBrowserWindowToFront(); | 807 BringBrowserWindowToFront(); |
| 805 HTTPTestServer* server = StartHTTPServer(); | 808 net::HTTPTestServer* server = StartHTTPServer(); |
| 806 ASSERT_TRUE(server); | 809 ASSERT_TRUE(server); |
| 807 | 810 |
| 808 // Open a regular page, crash, reload. | 811 // Open a regular page, crash, reload. |
| 809 ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage)); | 812 ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage)); |
| 810 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 813 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
| 811 browser()->Reload(CURRENT_TAB); | 814 browser()->Reload(CURRENT_TAB); |
| 812 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 815 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
| 813 // Focus should now be on the tab contents. | 816 // Focus should now be on the tab contents. |
| 814 browser()->ShowDownloadsTab(); | 817 browser()->ShowDownloadsTab(); |
| 815 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 818 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 816 } | 819 } |
| 817 | 820 |
| 818 } // namespace | 821 } // namespace |
| OLD | NEW |