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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix weird formatting in recent_tabs_sub_menu_model.cc Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 ui_test_utils::NavigateToURL(browser(), ntp_url); 513 ui_test_utils::NavigateToURL(browser(), ntp_url);
514 514
515 // Navigate to a 204 URL (aborts with no content) on the NTP and make sure it 515 // Navigate to a 204 URL (aborts with no content) on the NTP and make sure it
516 // sticks around so that the user can edit it. 516 // sticks around so that the user can edit it.
517 GURL abort_url(embedded_test_server()->GetURL("/nocontent")); 517 GURL abort_url(embedded_test_server()->GetURL("/nocontent"));
518 { 518 {
519 content::WindowedNotificationObserver stop_observer( 519 content::WindowedNotificationObserver stop_observer(
520 content::NOTIFICATION_LOAD_STOP, 520 content::NOTIFICATION_LOAD_STOP,
521 content::Source<NavigationController>( 521 content::Source<NavigationController>(
522 &web_contents->GetController())); 522 &web_contents->GetController()));
523 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, 523 browser()->OpenURL(OpenURLParams(abort_url, Referrer(),
524 WindowOpenDisposition::CURRENT_TAB,
524 ui::PAGE_TRANSITION_TYPED, false)); 525 ui::PAGE_TRANSITION_TYPED, false));
525 stop_observer.Wait(); 526 stop_observer.Wait();
526 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); 527 EXPECT_TRUE(web_contents->GetController().GetPendingEntry());
527 EXPECT_EQ(abort_url, web_contents->GetVisibleURL()); 528 EXPECT_EQ(abort_url, web_contents->GetVisibleURL());
528 } 529 }
529 530
530 // Navigate to a real URL. 531 // Navigate to a real URL.
531 GURL real_url(embedded_test_server()->GetURL("/title1.html")); 532 GURL real_url(embedded_test_server()->GetURL("/title1.html"));
532 ui_test_utils::NavigateToURL(browser(), real_url); 533 ui_test_utils::NavigateToURL(browser(), real_url);
533 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); 534 EXPECT_EQ(real_url, web_contents->GetVisibleURL());
534 535
535 // Now navigating to a 204 URL should clear the pending entry. 536 // Now navigating to a 204 URL should clear the pending entry.
536 { 537 {
537 content::WindowedNotificationObserver stop_observer( 538 content::WindowedNotificationObserver stop_observer(
538 content::NOTIFICATION_LOAD_STOP, 539 content::NOTIFICATION_LOAD_STOP,
539 content::Source<NavigationController>( 540 content::Source<NavigationController>(
540 &web_contents->GetController())); 541 &web_contents->GetController()));
541 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, 542 browser()->OpenURL(OpenURLParams(abort_url, Referrer(),
543 WindowOpenDisposition::CURRENT_TAB,
542 ui::PAGE_TRANSITION_TYPED, false)); 544 ui::PAGE_TRANSITION_TYPED, false));
543 stop_observer.Wait(); 545 stop_observer.Wait();
544 EXPECT_FALSE(web_contents->GetController().GetPendingEntry()); 546 EXPECT_FALSE(web_contents->GetController().GetPendingEntry());
545 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); 547 EXPECT_EQ(real_url, web_contents->GetVisibleURL());
546 } 548 }
547 } 549 }
548 550
549 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a 551 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a
550 // cross-process navigation is ready to commit. 552 // cross-process navigation is ready to commit.
551 // Flaky test, see https://crbug.com/445155. 553 // Flaky test, see https://crbug.com/445155.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 } 662 }
661 663
662 // Test for crbug.com/22004. Reloading a page with a before unload handler and 664 // Test for crbug.com/22004. Reloading a page with a before unload handler and
663 // then canceling the dialog should not leave the throbber spinning. 665 // then canceling the dialog should not leave the throbber spinning.
664 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { 666 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) {
665 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); 667 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML);
666 ui_test_utils::NavigateToURL(browser(), url); 668 ui_test_utils::NavigateToURL(browser(), url);
667 669
668 // Navigate to another page, but click cancel in the dialog. Make sure that 670 // Navigate to another page, but click cancel in the dialog. Make sure that
669 // the throbber stops spinning. 671 // the throbber stops spinning.
670 chrome::Reload(browser(), CURRENT_TAB); 672 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
671 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 673 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
672 alert->CloseModalDialog(); 674 alert->CloseModalDialog();
673 EXPECT_FALSE( 675 EXPECT_FALSE(
674 browser()->tab_strip_model()->GetActiveWebContents()->IsLoading()); 676 browser()->tab_strip_model()->GetActiveWebContents()->IsLoading());
675 677
676 // Clear the beforeunload handler so the test can easily exit. 678 // Clear the beforeunload handler so the test can easily exit.
677 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> 679 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()->
678 ExecuteJavaScriptForTests(ASCIIToUTF16("onbeforeunload=null;")); 680 ExecuteJavaScriptForTests(ASCIIToUTF16("onbeforeunload=null;"));
679 } 681 }
680 682
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 ui_test_utils::NavigateToURL(browser(), url); 783 ui_test_utils::NavigateToURL(browser(), url);
782 784
783 // Navigate to a URL that redirects to another process and approve the 785 // Navigate to a URL that redirects to another process and approve the
784 // beforeunload dialog that pops up. 786 // beforeunload dialog that pops up.
785 content::WindowedNotificationObserver nav_observer( 787 content::WindowedNotificationObserver nav_observer(
786 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 788 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
787 content::NotificationService::AllSources()); 789 content::NotificationService::AllSources());
788 GURL https_url(https_test_server.GetURL("/title1.html")); 790 GURL https_url(https_test_server.GetURL("/title1.html"));
789 GURL redirect_url( 791 GURL redirect_url(
790 embedded_test_server()->GetURL("/server-redirect?" + https_url.spec())); 792 embedded_test_server()->GetURL("/server-redirect?" + https_url.spec()));
791 browser()->OpenURL(OpenURLParams(redirect_url, Referrer(), CURRENT_TAB, 793 browser()->OpenURL(OpenURLParams(redirect_url, Referrer(),
794 WindowOpenDisposition::CURRENT_TAB,
792 ui::PAGE_TRANSITION_TYPED, false)); 795 ui::PAGE_TRANSITION_TYPED, false));
793 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 796 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
794 EXPECT_TRUE( 797 EXPECT_TRUE(
795 static_cast<JavaScriptAppModalDialog*>(alert)->is_before_unload_dialog()); 798 static_cast<JavaScriptAppModalDialog*>(alert)->is_before_unload_dialog());
796 alert->native_dialog()->AcceptAppModalDialog(); 799 alert->native_dialog()->AcceptAppModalDialog();
797 nav_observer.Wait(); 800 nav_observer.Wait();
798 801
799 // Restore previous browser client. 802 // Restore previous browser client.
800 SetBrowserClientForTesting(old_client); 803 SetBrowserClientForTesting(old_client);
801 } 804 }
802 805
803 // Test for crbug.com/80401. Canceling a before unload dialog should reset 806 // Test for crbug.com/80401. Canceling a before unload dialog should reset
804 // the URL to the previous page's URL. 807 // the URL to the previous page's URL.
805 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { 808 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) {
806 GURL url(ui_test_utils::GetTestUrl(base::FilePath( 809 GURL url(ui_test_utils::GetTestUrl(base::FilePath(
807 base::FilePath::kCurrentDirectory), base::FilePath(kBeforeUnloadFile))); 810 base::FilePath::kCurrentDirectory), base::FilePath(kBeforeUnloadFile)));
808 ui_test_utils::NavigateToURL(browser(), url); 811 ui_test_utils::NavigateToURL(browser(), url);
809 812
810 // Navigate to a page that triggers a cross-site transition. 813 // Navigate to a page that triggers a cross-site transition.
811 ASSERT_TRUE(embedded_test_server()->Start()); 814 ASSERT_TRUE(embedded_test_server()->Start());
812 GURL url2(embedded_test_server()->GetURL("/title1.html")); 815 GURL url2(embedded_test_server()->GetURL("/title1.html"));
813 browser()->OpenURL(OpenURLParams( 816 browser()->OpenURL(OpenURLParams(url2, Referrer(),
814 url2, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); 817 WindowOpenDisposition::CURRENT_TAB,
818 ui::PAGE_TRANSITION_TYPED, false));
815 819
816 content::WindowedNotificationObserver host_destroyed_observer( 820 content::WindowedNotificationObserver host_destroyed_observer(
817 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 821 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
818 content::NotificationService::AllSources()); 822 content::NotificationService::AllSources());
819 823
820 // Cancel the dialog. 824 // Cancel the dialog.
821 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 825 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
822 alert->CloseModalDialog(); 826 alert->CloseModalDialog();
823 EXPECT_FALSE( 827 EXPECT_FALSE(
824 browser()->tab_strip_model()->GetActiveWebContents()->IsLoading()); 828 browser()->tab_strip_model()->GetActiveWebContents()->IsLoading());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 #define MAYBE_BeforeUnloadVsBeforeReload BeforeUnloadVsBeforeReload 881 #define MAYBE_BeforeUnloadVsBeforeReload BeforeUnloadVsBeforeReload
878 #endif 882 #endif
879 883
880 // Test that when a page has an onunload handler, reloading a page shows a 884 // Test that when a page has an onunload handler, reloading a page shows a
881 // different dialog than navigating to a different page. 885 // different dialog than navigating to a different page.
882 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_BeforeUnloadVsBeforeReload) { 886 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_BeforeUnloadVsBeforeReload) {
883 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); 887 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML);
884 ui_test_utils::NavigateToURL(browser(), url); 888 ui_test_utils::NavigateToURL(browser(), url);
885 889
886 // Reload the page, and check that we get a "before reload" dialog. 890 // Reload the page, and check that we get a "before reload" dialog.
887 chrome::Reload(browser(), CURRENT_TAB); 891 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
888 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 892 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
889 EXPECT_TRUE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload()); 893 EXPECT_TRUE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload());
890 894
891 // Cancel the reload. 895 // Cancel the reload.
892 alert->native_dialog()->CancelAppModalDialog(); 896 alert->native_dialog()->CancelAppModalDialog();
893 897
894 // Navigate to another url, and check that we get a "before unload" dialog. 898 // Navigate to another url, and check that we get a "before unload" dialog.
895 GURL url2(url::kAboutBlankURL); 899 GURL url2(url::kAboutBlankURL);
896 browser()->OpenURL(OpenURLParams( 900 browser()->OpenURL(OpenURLParams(url2, Referrer(),
897 url2, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); 901 WindowOpenDisposition::CURRENT_TAB,
902 ui::PAGE_TRANSITION_TYPED, false));
898 903
899 alert = ui_test_utils::WaitForAppModalDialog(); 904 alert = ui_test_utils::WaitForAppModalDialog();
900 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload()); 905 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload());
901 906
902 // Accept the navigation so we end up on a page without a beforeunload hook. 907 // Accept the navigation so we end up on a page without a beforeunload hook.
903 alert->native_dialog()->AcceptAppModalDialog(); 908 alert->native_dialog()->AcceptAppModalDialog();
904 } 909 }
905 910
906 // BeforeUnloadAtQuitWithTwoWindows is a regression test for 911 // BeforeUnloadAtQuitWithTwoWindows is a regression test for
907 // http://crbug.com/11842. It opens two windows, one of which has a 912 // http://crbug.com/11842. It opens two windows, one of which has a
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 ASSERT_TRUE(embedded_test_server()->Start()); 1424 ASSERT_TRUE(embedded_test_server()->Start());
1420 1425
1421 // Load an app. 1426 // Load an app.
1422 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1427 host_resolver()->AddRule("www.example.com", "127.0.0.1");
1423 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 1428 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
1424 const Extension* extension_app = GetExtension(); 1429 const Extension* extension_app = GetExtension();
1425 1430
1426 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. 1431 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would.
1427 WebContents* app_window = OpenApplication(AppLaunchParams( 1432 WebContents* app_window = OpenApplication(AppLaunchParams(
1428 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, 1433 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW,
1429 NEW_WINDOW, extensions::SOURCE_TEST)); 1434 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST));
1430 ASSERT_TRUE(app_window); 1435 ASSERT_TRUE(app_window);
1431 1436
1432 DevToolsWindow* devtools_window = 1437 DevToolsWindow* devtools_window =
1433 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); 1438 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false);
1434 1439
1435 // The launch should have created a new app browser and a dev tools browser. 1440 // The launch should have created a new app browser and a dev tools browser.
1436 ASSERT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); 1441 ASSERT_EQ(3u, chrome::GetBrowserCount(browser()->profile()));
1437 1442
1438 // Find the new browsers. 1443 // Find the new browsers.
1439 Browser* app_browser = NULL; 1444 Browser* app_browser = NULL;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 ASSERT_TRUE(embedded_test_server()->Start()); 1544 ASSERT_TRUE(embedded_test_server()->Start());
1540 1545
1541 // Load an app 1546 // Load an app
1542 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1547 host_resolver()->AddRule("www.example.com", "127.0.0.1");
1543 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 1548 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
1544 const Extension* extension_app = GetExtension(); 1549 const Extension* extension_app = GetExtension();
1545 1550
1546 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. 1551 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would.
1547 WebContents* app_window = OpenApplication(AppLaunchParams( 1552 WebContents* app_window = OpenApplication(AppLaunchParams(
1548 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, 1553 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW,
1549 NEW_WINDOW, extensions::SOURCE_TEST)); 1554 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST));
1550 ASSERT_TRUE(app_window); 1555 ASSERT_TRUE(app_window);
1551 1556
1552 // Apps launched in a window from the NTP have an extensions tab helper but 1557 // Apps launched in a window from the NTP have an extensions tab helper but
1553 // do not have extension_app set in it. 1558 // do not have extension_app set in it.
1554 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window)); 1559 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window));
1555 EXPECT_FALSE( 1560 EXPECT_FALSE(
1556 extensions::TabHelper::FromWebContents(app_window)->extension_app()); 1561 extensions::TabHelper::FromWebContents(app_window)->extension_app());
1557 EXPECT_EQ(extensions::AppLaunchInfo::GetFullLaunchURL(extension_app), 1562 EXPECT_EQ(extensions::AppLaunchInfo::GetFullLaunchURL(extension_app),
1558 app_window->GetURL()); 1563 app_window->GetURL());
1559 1564
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 ui_test_utils::NavigateToURL( 1620 ui_test_utils::NavigateToURL(
1616 browser(), ui_test_utils::GetTestUrl( 1621 browser(), ui_test_utils::GetTestUrl(
1617 base::FilePath(base::FilePath::kCurrentDirectory), 1622 base::FilePath(base::FilePath::kCurrentDirectory),
1618 base::FilePath(kTitle1File))); 1623 base::FilePath(kTitle1File)));
1619 1624
1620 content::WindowedNotificationObserver back_nav_load_observer( 1625 content::WindowedNotificationObserver back_nav_load_observer(
1621 content::NOTIFICATION_LOAD_STOP, 1626 content::NOTIFICATION_LOAD_STOP,
1622 content::Source<NavigationController>( 1627 content::Source<NavigationController>(
1623 &browser()->tab_strip_model()->GetActiveWebContents()-> 1628 &browser()->tab_strip_model()->GetActiveWebContents()->
1624 GetController())); 1629 GetController()));
1625 chrome::GoBack(browser(), CURRENT_TAB); 1630 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
1626 back_nav_load_observer.Wait(); 1631 back_nav_load_observer.Wait();
1627 CommandUpdater* command_updater = 1632 CommandUpdater* command_updater =
1628 browser()->command_controller()->command_updater(); 1633 browser()->command_controller()->command_updater();
1629 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_FORWARD)); 1634 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_FORWARD));
1630 1635
1631 content::WindowedNotificationObserver forward_nav_load_observer( 1636 content::WindowedNotificationObserver forward_nav_load_observer(
1632 content::NOTIFICATION_LOAD_STOP, 1637 content::NOTIFICATION_LOAD_STOP,
1633 content::Source<NavigationController>( 1638 content::Source<NavigationController>(
1634 &browser()->tab_strip_model()->GetActiveWebContents()-> 1639 &browser()->tab_strip_model()->GetActiveWebContents()->
1635 GetController())); 1640 GetController()));
1636 chrome::GoForward(browser(), CURRENT_TAB); 1641 chrome::GoForward(browser(), WindowOpenDisposition::CURRENT_TAB);
1637 // This check will happen before the navigation completes, since the browser 1642 // This check will happen before the navigation completes, since the browser
1638 // won't process the renderer's response until the Wait() call below. 1643 // won't process the renderer's response until the Wait() call below.
1639 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_FORWARD)); 1644 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_FORWARD));
1640 forward_nav_load_observer.Wait(); 1645 forward_nav_load_observer.Wait();
1641 } 1646 }
1642 1647
1643 // Makes sure certain commands are disabled when Incognito mode is forced. 1648 // Makes sure certain commands are disabled when Incognito mode is forced.
1644 IN_PROC_BROWSER_TEST_F(BrowserTest, DisableMenuItemsWhenIncognitoIsForced) { 1649 IN_PROC_BROWSER_TEST_F(BrowserTest, DisableMenuItemsWhenIncognitoIsForced) {
1645 CommandUpdater* command_updater = 1650 CommandUpdater* command_updater =
1646 browser()->command_controller()->command_updater(); 1651 browser()->command_controller()->command_updater();
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 browser()->tab_strip_model()->GetActiveWebContents(); 1987 browser()->tab_strip_model()->GetActiveWebContents();
1983 MockWebContentsObserver mock_observer(web_contents); 1988 MockWebContentsObserver mock_observer(web_contents);
1984 1989
1985 ASSERT_TRUE(embedded_test_server()->Start()); 1990 ASSERT_TRUE(embedded_test_server()->Start());
1986 GURL url(embedded_test_server()->GetURL("/empty.html")); 1991 GURL url(embedded_test_server()->GetURL("/empty.html"));
1987 1992
1988 ui_test_utils::NavigateToURL(browser(), url); 1993 ui_test_utils::NavigateToURL(browser(), url);
1989 EXPECT_TRUE(mock_observer.got_user_gesture()); 1994 EXPECT_TRUE(mock_observer.got_user_gesture());
1990 1995
1991 mock_observer.set_got_user_gesture(false); 1996 mock_observer.set_got_user_gesture(false);
1992 chrome::Reload(browser(), CURRENT_TAB); 1997 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
1993 EXPECT_TRUE(mock_observer.got_user_gesture()); 1998 EXPECT_TRUE(mock_observer.got_user_gesture());
1994 } 1999 }
1995 2000
1996 // TODO(ben): this test was never enabled. It has bit-rotted since being added. 2001 // TODO(ben): this test was never enabled. It has bit-rotted since being added.
1997 // It originally lived in browser_unittest.cc, but has been moved here to make 2002 // It originally lived in browser_unittest.cc, but has been moved here to make
1998 // room for real browser unit tests. 2003 // room for real browser unit tests.
1999 #if 0 2004 #if 0
2000 class BrowserTest2 : public InProcessBrowserTest { 2005 class BrowserTest2 : public InProcessBrowserTest {
2001 public: 2006 public:
2002 BrowserTest2() { 2007 BrowserTest2() {
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 int modifiers, 2372 int modifiers,
2368 blink::WebMouseEvent::Button button, 2373 blink::WebMouseEvent::Button button,
2369 WindowOpenDisposition disposition) { 2374 WindowOpenDisposition disposition) {
2370 ui_test_utils::NavigateToURL(browser, url); 2375 ui_test_utils::NavigateToURL(browser, url);
2371 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); 2376 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile()));
2372 EXPECT_EQ(1, browser->tab_strip_model()->count()); 2377 EXPECT_EQ(1, browser->tab_strip_model()->count());
2373 content::WebContents* web_contents = 2378 content::WebContents* web_contents =
2374 browser->tab_strip_model()->GetActiveWebContents(); 2379 browser->tab_strip_model()->GetActiveWebContents();
2375 EXPECT_EQ(url, web_contents->GetURL()); 2380 EXPECT_EQ(url, web_contents->GetURL());
2376 2381
2377 if (disposition == CURRENT_TAB) { 2382 if (disposition == WindowOpenDisposition::CURRENT_TAB) {
2378 content::WebContents* web_contents = 2383 content::WebContents* web_contents =
2379 browser->tab_strip_model()->GetActiveWebContents(); 2384 browser->tab_strip_model()->GetActiveWebContents();
2380 content::TestNavigationObserver same_tab_observer(web_contents); 2385 content::TestNavigationObserver same_tab_observer(web_contents);
2381 SimulateMouseClick(web_contents, modifiers, button); 2386 SimulateMouseClick(web_contents, modifiers, button);
2382 same_tab_observer.Wait(); 2387 same_tab_observer.Wait();
2383 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); 2388 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile()));
2384 EXPECT_EQ(1, browser->tab_strip_model()->count()); 2389 EXPECT_EQ(1, browser->tab_strip_model()->count());
2385 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); 2390 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle());
2386 return; 2391 return;
2387 } 2392 }
2388 2393
2389 content::WindowedNotificationObserver observer( 2394 content::WindowedNotificationObserver observer(
2390 chrome::NOTIFICATION_TAB_ADDED, 2395 chrome::NOTIFICATION_TAB_ADDED,
2391 content::NotificationService::AllSources()); 2396 content::NotificationService::AllSources());
2392 SimulateMouseClick(web_contents, modifiers, button); 2397 SimulateMouseClick(web_contents, modifiers, button);
2393 observer.Wait(); 2398 observer.Wait();
2394 2399
2395 if (disposition == NEW_WINDOW) { 2400 if (disposition == WindowOpenDisposition::NEW_WINDOW) {
2396 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile())); 2401 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile()));
2397 return; 2402 return;
2398 } 2403 }
2399 2404
2400 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); 2405 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile()));
2401 EXPECT_EQ(2, browser->tab_strip_model()->count()); 2406 EXPECT_EQ(2, browser->tab_strip_model()->count());
2402 web_contents = browser->tab_strip_model()->GetActiveWebContents(); 2407 web_contents = browser->tab_strip_model()->GetActiveWebContents();
2403 WaitForLoadStop(web_contents); 2408 WaitForLoadStop(web_contents);
2404 if (disposition == NEW_FOREGROUND_TAB) { 2409 if (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) {
2405 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); 2410 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle());
2406 } else { 2411 } else {
2407 ASSERT_EQ(NEW_BACKGROUND_TAB, disposition); 2412 ASSERT_EQ(WindowOpenDisposition::NEW_BACKGROUND_TAB, disposition);
2408 EXPECT_EQ(getFirstPageTitle(), web_contents->GetTitle()); 2413 EXPECT_EQ(getFirstPageTitle(), web_contents->GetTitle());
2409 } 2414 }
2410 } 2415 }
2411 2416
2412 private: 2417 private:
2413 DISALLOW_COPY_AND_ASSIGN(ClickModifierTest); 2418 DISALLOW_COPY_AND_ASSIGN(ClickModifierTest);
2414 }; 2419 };
2415 2420
2416 // Tests for clicking on elements with handlers that run window.open. 2421 // Tests for clicking on elements with handlers that run window.open.
2417 2422
2418 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenBasicClickTest) { 2423 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenBasicClickTest) {
2419 int modifiers = 0; 2424 int modifiers = 0;
2420 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2425 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2421 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2426 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
2422 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2427 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2423 } 2428 }
2424 2429
2425 // TODO(ericu): Alt-click behavior on window.open is platform-dependent and not 2430 // TODO(ericu): Alt-click behavior on window.open is platform-dependent and not
2426 // well defined. Should we add tests so we know if it changes? 2431 // well defined. Should we add tests so we know if it changes?
2427 2432
2428 // Shift-clicks open in a new window. 2433 // Shift-clicks open in a new window.
2429 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftClickTest) { 2434 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftClickTest) {
2430 int modifiers = blink::WebInputEvent::ShiftKey; 2435 int modifiers = blink::WebInputEvent::ShiftKey;
2431 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2436 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2432 WindowOpenDisposition disposition = NEW_WINDOW; 2437 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_WINDOW;
2433 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2438 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2434 } 2439 }
2435 2440
2436 // Control-clicks open in a background tab. 2441 // Control-clicks open in a background tab.
2437 // On OSX meta [the command key] takes the place of control. 2442 // On OSX meta [the command key] takes the place of control.
2438 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlClickTest) { 2443 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlClickTest) {
2439 #if defined(OS_MACOSX) 2444 #if defined(OS_MACOSX)
2440 int modifiers = blink::WebInputEvent::MetaKey; 2445 int modifiers = blink::WebInputEvent::MetaKey;
2441 #else 2446 #else
2442 int modifiers = blink::WebInputEvent::ControlKey; 2447 int modifiers = blink::WebInputEvent::ControlKey;
2443 #endif 2448 #endif
2444 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2449 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2445 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; 2450 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB;
2446 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2451 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2447 } 2452 }
2448 2453
2449 // Control-shift-clicks open in a foreground tab. 2454 // Control-shift-clicks open in a foreground tab.
2450 // On OSX meta [the command key] takes the place of control. 2455 // On OSX meta [the command key] takes the place of control.
2451 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlShiftClickTest) { 2456 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlShiftClickTest) {
2452 #if defined(OS_MACOSX) 2457 #if defined(OS_MACOSX)
2453 int modifiers = blink::WebInputEvent::MetaKey; 2458 int modifiers = blink::WebInputEvent::MetaKey;
2454 #else 2459 #else
2455 int modifiers = blink::WebInputEvent::ControlKey; 2460 int modifiers = blink::WebInputEvent::ControlKey;
2456 #endif 2461 #endif
2457 modifiers |= blink::WebInputEvent::ShiftKey; 2462 modifiers |= blink::WebInputEvent::ShiftKey;
2458 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2463 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2459 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2464 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
2460 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); 2465 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
2461 } 2466 }
2462 2467
2463 // Tests for clicking on normal links. 2468 // Tests for clicking on normal links.
2464 2469
2465 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) { 2470 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) {
2466 int modifiers = 0; 2471 int modifiers = 0;
2467 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2472 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2468 WindowOpenDisposition disposition = CURRENT_TAB; 2473 WindowOpenDisposition disposition = WindowOpenDisposition::CURRENT_TAB;
2469 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2474 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2470 } 2475 }
2471 2476
2472 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well 2477 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well
2473 // defined. Should we add tests so we know if it changes? 2478 // defined. Should we add tests so we know if it changes?
2474 2479
2475 // Shift-clicks open in a new window. 2480 // Shift-clicks open in a new window.
2476 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) { 2481 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) {
2477 int modifiers = blink::WebInputEvent::ShiftKey; 2482 int modifiers = blink::WebInputEvent::ShiftKey;
2478 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2483 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2479 WindowOpenDisposition disposition = NEW_WINDOW; 2484 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_WINDOW;
2480 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2485 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2481 } 2486 }
2482 2487
2483 // Control-clicks open in a background tab. 2488 // Control-clicks open in a background tab.
2484 // On OSX meta [the command key] takes the place of control. 2489 // On OSX meta [the command key] takes the place of control.
2485 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) { 2490 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) {
2486 #if defined(OS_MACOSX) 2491 #if defined(OS_MACOSX)
2487 int modifiers = blink::WebInputEvent::MetaKey; 2492 int modifiers = blink::WebInputEvent::MetaKey;
2488 #else 2493 #else
2489 int modifiers = blink::WebInputEvent::ControlKey; 2494 int modifiers = blink::WebInputEvent::ControlKey;
2490 #endif 2495 #endif
2491 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2496 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2492 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; 2497 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB;
2493 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2498 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2494 } 2499 }
2495 2500
2496 // Control-shift-clicks open in a foreground tab. 2501 // Control-shift-clicks open in a foreground tab.
2497 // On OSX meta [the command key] takes the place of control. 2502 // On OSX meta [the command key] takes the place of control.
2498 // http://crbug.com/396347 2503 // http://crbug.com/396347
2499 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefControlShiftClickTest) { 2504 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefControlShiftClickTest) {
2500 #if defined(OS_MACOSX) 2505 #if defined(OS_MACOSX)
2501 int modifiers = blink::WebInputEvent::MetaKey; 2506 int modifiers = blink::WebInputEvent::MetaKey;
2502 #else 2507 #else
2503 int modifiers = blink::WebInputEvent::ControlKey; 2508 int modifiers = blink::WebInputEvent::ControlKey;
2504 #endif 2509 #endif
2505 modifiers |= blink::WebInputEvent::ShiftKey; 2510 modifiers |= blink::WebInputEvent::ShiftKey;
2506 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left; 2511 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Left;
2507 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2512 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
2508 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2513 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2509 } 2514 }
2510 2515
2511 // Middle-clicks open in a background tab. 2516 // Middle-clicks open in a background tab.
2512 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefMiddleClickTest) { 2517 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefMiddleClickTest) {
2513 int modifiers = 0; 2518 int modifiers = 0;
2514 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle; 2519 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle;
2515 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; 2520 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB;
2516 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2521 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2517 } 2522 }
2518 2523
2519 // Shift-middle-clicks open in a foreground tab. 2524 // Shift-middle-clicks open in a foreground tab.
2520 // http://crbug.com/396347 2525 // http://crbug.com/396347
2521 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefShiftMiddleClickTest) { 2526 IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefShiftMiddleClickTest) {
2522 int modifiers = blink::WebInputEvent::ShiftKey; 2527 int modifiers = blink::WebInputEvent::ShiftKey;
2523 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle; 2528 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::Middle;
2524 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2529 WindowOpenDisposition disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
2525 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2530 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2526 } 2531 }
2527 2532
2528 IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) { 2533 IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) {
2529 // The instant extended NTP has javascript that does not work with 2534 // The instant extended NTP has javascript that does not work with
2530 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries 2535 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries
2531 // to navigate away from the page, which causes the WebContents to end up in 2536 // to navigate away from the page, which causes the WebContents to end up in
2532 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, 2537 // an inconsistent state. (is_loaded = true, last_commited_url=ntp,
2533 // visible_url=title1.html) 2538 // visible_url=title1.html)
2534 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, 2539 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 Browser* browser = new Browser(params); 2850 Browser* browser = new Browser(params);
2846 gfx::Rect bounds = browser->window()->GetBounds(); 2851 gfx::Rect bounds = browser->window()->GetBounds();
2847 2852
2848 // Should be EXPECT_EQ, but this width is inconsistent across platforms. 2853 // Should be EXPECT_EQ, but this width is inconsistent across platforms.
2849 // See https://crbug.com/567925. 2854 // See https://crbug.com/567925.
2850 EXPECT_GE(bounds.width(), 100); 2855 EXPECT_GE(bounds.width(), 100);
2851 EXPECT_EQ(122, bounds.height()); 2856 EXPECT_EQ(122, bounds.height());
2852 browser->window()->Close(); 2857 browser->window()->Close();
2853 } 2858 }
2854 } 2859 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698