| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 554 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 555 browser(), ui::VKEY_TAB, false, false, false, false, | 555 browser(), ui::VKEY_TAB, false, false, false, false, |
| 556 chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER, | 556 chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER, |
| 557 content::NotificationSource(content::Source<Browser>(browser())))); | 557 content::NotificationSource(content::Source<Browser>(browser())))); |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 | 560 |
| 561 // At this point the renderer has sent us a message asking to advance the | 561 // At this point the renderer has sent us a message asking to advance the |
| 562 // focus (as the end of the focus loop was reached in the renderer). | 562 // focus (as the end of the focus loop was reached in the renderer). |
| 563 // We need to run the message loop to process it. | 563 // We need to run the message loop to process it. |
| 564 ui_test_utils::RunAllPendingInMessageLoop(); | 564 content::RunAllPendingInMessageLoop(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 // Now let's try reverse focus traversal. | 567 // Now let's try reverse focus traversal. |
| 568 for (int i = 0; i < 3; ++i) { | 568 for (int i = 0; i < 3; ++i) { |
| 569 SCOPED_TRACE(base::StringPrintf("outer loop: %d", i)); | 569 SCOPED_TRACE(base::StringPrintf("outer loop: %d", i)); |
| 570 // Location bar should be focused. | 570 // Location bar should be focused. |
| 571 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); | 571 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); |
| 572 | 572 |
| 573 // Move the caret to the end, otherwise the next Tab key may not move focus. | 573 // Move the caret to the end, otherwise the next Tab key may not move focus. |
| 574 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 574 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 606 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 607 L"", | 607 L"", |
| 608 L"window.domAutomationController.send(getFocusedElement());", | 608 L"window.domAutomationController.send(getFocusedElement());", |
| 609 &actual)); | 609 &actual)); |
| 610 ASSERT_STREQ(next_element, actual.c_str()); | 610 ASSERT_STREQ(next_element, actual.c_str()); |
| 611 } | 611 } |
| 612 | 612 |
| 613 // At this point the renderer has sent us a message asking to advance the | 613 // At this point the renderer has sent us a message asking to advance the |
| 614 // focus (as the end of the focus loop was reached in the renderer). | 614 // focus (as the end of the focus loop was reached in the renderer). |
| 615 // We need to run the message loop to process it. | 615 // We need to run the message loop to process it. |
| 616 ui_test_utils::RunAllPendingInMessageLoop(); | 616 content::RunAllPendingInMessageLoop(); |
| 617 } | 617 } |
| 618 } | 618 } |
| 619 | 619 |
| 620 // Focus traversal while an interstitial is showing. | 620 // Focus traversal while an interstitial is showing. |
| 621 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { | 621 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { |
| 622 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 622 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 623 ASSERT_TRUE(test_server()->Start()); | 623 ASSERT_TRUE(test_server()->Start()); |
| 624 | 624 |
| 625 // First we navigate to our test page. | 625 // First we navigate to our test page. |
| 626 GURL url = test_server()->GetURL(kSimplePage); | 626 GURL url = test_server()->GetURL(kSimplePage); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 } | 681 } |
| 682 | 682 |
| 683 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 683 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
| 684 browser(), ui::VKEY_TAB, false, false, false, false, | 684 browser(), ui::VKEY_TAB, false, false, false, false, |
| 685 notification_type, notification_source)); | 685 notification_type, notification_source)); |
| 686 } | 686 } |
| 687 | 687 |
| 688 // At this point the renderer has sent us a message asking to advance the | 688 // At this point the renderer has sent us a message asking to advance the |
| 689 // focus (as the end of the focus loop was reached in the renderer). | 689 // focus (as the end of the focus loop was reached in the renderer). |
| 690 // We need to run the message loop to process it. | 690 // We need to run the message loop to process it. |
| 691 ui_test_utils::RunAllPendingInMessageLoop(); | 691 content::RunAllPendingInMessageLoop(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 // Now let's try reverse focus traversal. | 694 // Now let's try reverse focus traversal. |
| 695 for (int i = 0; i < 2; ++i) { | 695 for (int i = 0; i < 2; ++i) { |
| 696 // Location bar should be focused. | 696 // Location bar should be focused. |
| 697 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); | 697 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); |
| 698 | 698 |
| 699 // Move the caret to the end, otherwise the next Tab key may not move focus. | 699 // Move the caret to the end, otherwise the next Tab key may not move focus. |
| 700 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 700 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 701 browser(), ui::VKEY_END, false, false, false, false)); | 701 browser(), ui::VKEY_END, false, false, false, false)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 724 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 724 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( |
| 725 interstitial_page->render_view_host(), L"", | 725 interstitial_page->render_view_host(), L"", |
| 726 L"window.domAutomationController.send(getFocusedElement());", | 726 L"window.domAutomationController.send(getFocusedElement());", |
| 727 &actual)); | 727 &actual)); |
| 728 ASSERT_STREQ(kExpElementIDs[6 - j], actual.c_str()); | 728 ASSERT_STREQ(kExpElementIDs[6 - j], actual.c_str()); |
| 729 } | 729 } |
| 730 | 730 |
| 731 // At this point the renderer has sent us a message asking to advance the | 731 // At this point the renderer has sent us a message asking to advance the |
| 732 // focus (as the end of the focus loop was reached in the renderer). | 732 // focus (as the end of the focus loop was reached in the renderer). |
| 733 // We need to run the message loop to process it. | 733 // We need to run the message loop to process it. |
| 734 ui_test_utils::RunAllPendingInMessageLoop(); | 734 content::RunAllPendingInMessageLoop(); |
| 735 } | 735 } |
| 736 } | 736 } |
| 737 | 737 |
| 738 // Focus stays on page with interstitials. | 738 // Focus stays on page with interstitials. |
| 739 // http://crbug.com/81451 | 739 // http://crbug.com/81451 |
| 740 #if defined(OS_MACOSX) || defined(OS_WIN) | 740 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 741 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_InterstitialFocus) { | 741 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_InterstitialFocus) { |
| 742 #else | 742 #else |
| 743 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) { | 743 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) { |
| 744 #endif | 744 #endif |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 ASSERT_TRUE(test_server()->Start()); | 871 ASSERT_TRUE(test_server()->Start()); |
| 872 | 872 |
| 873 // Open the new tab, reload. | 873 // Open the new tab, reload. |
| 874 { | 874 { |
| 875 content::WindowedNotificationObserver observer( | 875 content::WindowedNotificationObserver observer( |
| 876 content::NOTIFICATION_LOAD_STOP, | 876 content::NOTIFICATION_LOAD_STOP, |
| 877 content::NotificationService::AllSources()); | 877 content::NotificationService::AllSources()); |
| 878 chrome::NewTab(browser()); | 878 chrome::NewTab(browser()); |
| 879 observer.Wait(); | 879 observer.Wait(); |
| 880 } | 880 } |
| 881 ui_test_utils::RunAllPendingInMessageLoop(); | 881 content::RunAllPendingInMessageLoop(); |
| 882 | 882 |
| 883 { | 883 { |
| 884 content::WindowedNotificationObserver observer( | 884 content::WindowedNotificationObserver observer( |
| 885 content::NOTIFICATION_LOAD_STOP, | 885 content::NOTIFICATION_LOAD_STOP, |
| 886 content::Source<NavigationController>( | 886 content::Source<NavigationController>( |
| 887 &chrome::GetActiveWebContents(browser())->GetController())); | 887 &chrome::GetActiveWebContents(browser())->GetController())); |
| 888 chrome::Reload(browser(), CURRENT_TAB); | 888 chrome::Reload(browser(), CURRENT_TAB); |
| 889 observer.Wait(); | 889 observer.Wait(); |
| 890 } | 890 } |
| 891 // Focus should stay on the location bar. | 891 // Focus should stay on the location bar. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 chrome::Reload(browser(), CURRENT_TAB); | 925 chrome::Reload(browser(), CURRENT_TAB); |
| 926 observer.Wait(); | 926 observer.Wait(); |
| 927 } | 927 } |
| 928 | 928 |
| 929 // Focus should now be on the tab contents. | 929 // Focus should now be on the tab contents. |
| 930 chrome::ShowDownloads(browser()); | 930 chrome::ShowDownloads(browser()); |
| 931 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 931 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
| 932 } | 932 } |
| 933 | 933 |
| 934 } // namespace | 934 } // namespace |
| OLD | NEW |