| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "content/public/browser/navigation_entry.h" | 69 #include "content/public/browser/navigation_entry.h" |
| 70 #include "content/public/browser/notification_service.h" | 70 #include "content/public/browser/notification_service.h" |
| 71 #include "content/public/browser/render_frame_host.h" | 71 #include "content/public/browser/render_frame_host.h" |
| 72 #include "content/public/browser/render_process_host.h" | 72 #include "content/public/browser/render_process_host.h" |
| 73 #include "content/public/browser/render_view_host.h" | 73 #include "content/public/browser/render_view_host.h" |
| 74 #include "content/public/browser/render_widget_host_view.h" | 74 #include "content/public/browser/render_widget_host_view.h" |
| 75 #include "content/public/browser/resource_context.h" | 75 #include "content/public/browser/resource_context.h" |
| 76 #include "content/public/browser/web_contents.h" | 76 #include "content/public/browser/web_contents.h" |
| 77 #include "content/public/browser/web_contents_observer.h" | 77 #include "content/public/browser/web_contents_observer.h" |
| 78 #include "content/public/common/frame_navigate_params.h" | 78 #include "content/public/common/frame_navigate_params.h" |
| 79 #include "content/public/common/page_transition_types.h" | |
| 80 #include "content/public/common/renderer_preferences.h" | 79 #include "content/public/common/renderer_preferences.h" |
| 81 #include "content/public/common/url_constants.h" | 80 #include "content/public/common/url_constants.h" |
| 82 #include "content/public/test/browser_test_utils.h" | 81 #include "content/public/test/browser_test_utils.h" |
| 83 #include "content/public/test/test_navigation_observer.h" | 82 #include "content/public/test/test_navigation_observer.h" |
| 84 #include "extensions/browser/extension_system.h" | 83 #include "extensions/browser/extension_system.h" |
| 85 #include "extensions/browser/uninstall_reason.h" | 84 #include "extensions/browser/uninstall_reason.h" |
| 86 #include "extensions/common/extension.h" | 85 #include "extensions/common/extension.h" |
| 87 #include "extensions/common/extension_set.h" | 86 #include "extensions/common/extension_set.h" |
| 88 #include "net/dns/mock_host_resolver.h" | 87 #include "net/dns/mock_host_resolver.h" |
| 89 #include "net/test/spawned_test_server/spawned_test_server.h" | 88 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 90 #include "ui/base/l10n/l10n_util.h" | 89 #include "ui/base/l10n/l10n_util.h" |
| 90 #include "ui/base/page_transition_types.h" |
| 91 | 91 |
| 92 #if defined(OS_MACOSX) | 92 #if defined(OS_MACOSX) |
| 93 #include "base/mac/mac_util.h" | 93 #include "base/mac/mac_util.h" |
| 94 #include "base/mac/scoped_nsautorelease_pool.h" | 94 #include "base/mac/scoped_nsautorelease_pool.h" |
| 95 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 95 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
| 99 #include "base/i18n/rtl.h" | 99 #include "base/i18n/rtl.h" |
| 100 #include "chrome/browser/browser_process.h" | 100 #include "chrome/browser/browser_process.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 browser()->GetWindowTitleForCurrentTab()); | 412 browser()->GetWindowTitleForCurrentTab()); |
| 413 base::string16 tab_title; | 413 base::string16 tab_title; |
| 414 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); | 414 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); |
| 415 EXPECT_EQ(test_title, tab_title); | 415 EXPECT_EQ(test_title, tab_title); |
| 416 } | 416 } |
| 417 | 417 |
| 418 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { | 418 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { |
| 419 GURL url(ui_test_utils::GetTestUrl(base::FilePath( | 419 GURL url(ui_test_utils::GetTestUrl(base::FilePath( |
| 420 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); | 420 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); |
| 421 ui_test_utils::NavigateToURL(browser(), url); | 421 ui_test_utils::NavigateToURL(browser(), url); |
| 422 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 422 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); |
| 423 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 423 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 424 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 424 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 425 WebContents* second_tab = browser()->tab_strip_model()->GetWebContentsAt(1); | 425 WebContents* second_tab = browser()->tab_strip_model()->GetWebContentsAt(1); |
| 426 ASSERT_TRUE(second_tab); | 426 ASSERT_TRUE(second_tab); |
| 427 second_tab->GetMainFrame()->ExecuteJavaScript( | 427 second_tab->GetMainFrame()->ExecuteJavaScript( |
| 428 ASCIIToUTF16("alert('Activate!');")); | 428 ASCIIToUTF16("alert('Activate!');")); |
| 429 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 429 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 430 alert->CloseModalDialog(); | 430 alert->CloseModalDialog(); |
| 431 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 431 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 432 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 432 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 447 // Warning: this test can take >30 seconds when running on a slow (low | 447 // Warning: this test can take >30 seconds when running on a slow (low |
| 448 // memory?) Mac builder. | 448 // memory?) Mac builder. |
| 449 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_ThirtyFourTabs) { | 449 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_ThirtyFourTabs) { |
| 450 GURL url(ui_test_utils::GetTestUrl(base::FilePath( | 450 GURL url(ui_test_utils::GetTestUrl(base::FilePath( |
| 451 base::FilePath::kCurrentDirectory), base::FilePath(kTitle2File))); | 451 base::FilePath::kCurrentDirectory), base::FilePath(kTitle2File))); |
| 452 | 452 |
| 453 // There is one initial tab. | 453 // There is one initial tab. |
| 454 const int kTabCount = 34; | 454 const int kTabCount = 34; |
| 455 for (int ix = 0; ix != (kTabCount - 1); ++ix) { | 455 for (int ix = 0; ix != (kTabCount - 1); ++ix) { |
| 456 chrome::AddSelectedTabWithURL(browser(), url, | 456 chrome::AddSelectedTabWithURL(browser(), url, |
| 457 content::PAGE_TRANSITION_TYPED); | 457 ui::PAGE_TRANSITION_TYPED); |
| 458 } | 458 } |
| 459 EXPECT_EQ(kTabCount, browser()->tab_strip_model()->count()); | 459 EXPECT_EQ(kTabCount, browser()->tab_strip_model()->count()); |
| 460 | 460 |
| 461 // See GetMaxRendererProcessCount() in | 461 // See GetMaxRendererProcessCount() in |
| 462 // content/browser/renderer_host/render_process_host_impl.cc | 462 // content/browser/renderer_host/render_process_host_impl.cc |
| 463 // for the algorithm to decide how many processes to create. | 463 // for the algorithm to decide how many processes to create. |
| 464 const int kExpectedProcessCount = | 464 const int kExpectedProcessCount = |
| 465 #if defined(ARCH_CPU_64_BITS) | 465 #if defined(ARCH_CPU_64_BITS) |
| 466 17; | 466 17; |
| 467 #else | 467 #else |
| (...skipping 18 matching lines...) Expand all Loading... |
| 486 | 486 |
| 487 // Navigate to a 204 URL (aborts with no content) on the NTP and make sure it | 487 // Navigate to a 204 URL (aborts with no content) on the NTP and make sure it |
| 488 // sticks around so that the user can edit it. | 488 // sticks around so that the user can edit it. |
| 489 GURL abort_url(test_server()->GetURL("nocontent")); | 489 GURL abort_url(test_server()->GetURL("nocontent")); |
| 490 { | 490 { |
| 491 content::WindowedNotificationObserver stop_observer( | 491 content::WindowedNotificationObserver stop_observer( |
| 492 content::NOTIFICATION_LOAD_STOP, | 492 content::NOTIFICATION_LOAD_STOP, |
| 493 content::Source<NavigationController>( | 493 content::Source<NavigationController>( |
| 494 &web_contents->GetController())); | 494 &web_contents->GetController())); |
| 495 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, | 495 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, |
| 496 content::PAGE_TRANSITION_TYPED, false)); | 496 ui::PAGE_TRANSITION_TYPED, false)); |
| 497 stop_observer.Wait(); | 497 stop_observer.Wait(); |
| 498 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); | 498 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); |
| 499 EXPECT_EQ(abort_url, web_contents->GetVisibleURL()); | 499 EXPECT_EQ(abort_url, web_contents->GetVisibleURL()); |
| 500 } | 500 } |
| 501 | 501 |
| 502 // Navigate to a real URL. | 502 // Navigate to a real URL. |
| 503 GURL real_url(test_server()->GetURL("title1.html")); | 503 GURL real_url(test_server()->GetURL("title1.html")); |
| 504 ui_test_utils::NavigateToURL(browser(), real_url); | 504 ui_test_utils::NavigateToURL(browser(), real_url); |
| 505 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); | 505 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); |
| 506 | 506 |
| 507 // Now navigating to a 204 URL should clear the pending entry. | 507 // Now navigating to a 204 URL should clear the pending entry. |
| 508 { | 508 { |
| 509 content::WindowedNotificationObserver stop_observer( | 509 content::WindowedNotificationObserver stop_observer( |
| 510 content::NOTIFICATION_LOAD_STOP, | 510 content::NOTIFICATION_LOAD_STOP, |
| 511 content::Source<NavigationController>( | 511 content::Source<NavigationController>( |
| 512 &web_contents->GetController())); | 512 &web_contents->GetController())); |
| 513 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, | 513 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, |
| 514 content::PAGE_TRANSITION_TYPED, false)); | 514 ui::PAGE_TRANSITION_TYPED, false)); |
| 515 stop_observer.Wait(); | 515 stop_observer.Wait(); |
| 516 EXPECT_FALSE(web_contents->GetController().GetPendingEntry()); | 516 EXPECT_FALSE(web_contents->GetController().GetPendingEntry()); |
| 517 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); | 517 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a | 521 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a |
| 522 // cross-process navigation is ready to commit. | 522 // cross-process navigation is ready to commit. |
| 523 IN_PROC_BROWSER_TEST_F(BrowserTest, CrossProcessNavCancelsDialogs) { | 523 IN_PROC_BROWSER_TEST_F(BrowserTest, CrossProcessNavCancelsDialogs) { |
| 524 ASSERT_TRUE(test_server()->Start()); | 524 ASSERT_TRUE(test_server()->Start()); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 contents->GetController().GetLastCommittedEntry()->GetURL()); | 689 contents->GetController().GetLastCommittedEntry()->GetURL()); |
| 690 | 690 |
| 691 // We should keep track of the original request URL, redirect chain, and | 691 // We should keep track of the original request URL, redirect chain, and |
| 692 // page transition type during a transfer, since these are necessary for | 692 // page transition type during a transfer, since these are necessary for |
| 693 // history autocomplete to work. | 693 // history autocomplete to work. |
| 694 EXPECT_EQ(redirect_url, contents->GetController().GetLastCommittedEntry()-> | 694 EXPECT_EQ(redirect_url, contents->GetController().GetLastCommittedEntry()-> |
| 695 GetOriginalRequestURL()); | 695 GetOriginalRequestURL()); |
| 696 EXPECT_EQ(2U, redirect_observer.params().redirects.size()); | 696 EXPECT_EQ(2U, redirect_observer.params().redirects.size()); |
| 697 EXPECT_EQ(redirect_url, redirect_observer.params().redirects.at(0)); | 697 EXPECT_EQ(redirect_url, redirect_observer.params().redirects.at(0)); |
| 698 EXPECT_EQ(dest_url, redirect_observer.params().redirects.at(1)); | 698 EXPECT_EQ(dest_url, redirect_observer.params().redirects.at(1)); |
| 699 EXPECT_TRUE(PageTransitionCoreTypeIs(redirect_observer.params().transition, | 699 EXPECT_TRUE(ui::PageTransitionCoreTypeIs( |
| 700 content::PAGE_TRANSITION_TYPED)); | 700 redirect_observer.params().transition, ui::PAGE_TRANSITION_TYPED)); |
| 701 } | 701 } |
| 702 | 702 |
| 703 // Restore previous browser client. | 703 // Restore previous browser client. |
| 704 SetBrowserClientForTesting(old_client); | 704 SetBrowserClientForTesting(old_client); |
| 705 } | 705 } |
| 706 | 706 |
| 707 // Tests that a cross-process redirect will only cause the beforeunload | 707 // Tests that a cross-process redirect will only cause the beforeunload |
| 708 // handler to run once. | 708 // handler to run once. |
| 709 IN_PROC_BROWSER_TEST_F(BrowserTest, SingleBeforeUnloadAfterRedirect) { | 709 IN_PROC_BROWSER_TEST_F(BrowserTest, SingleBeforeUnloadAfterRedirect) { |
| 710 // Create HTTP and HTTPS servers for a cross-site transition. | 710 // Create HTTP and HTTPS servers for a cross-site transition. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 726 | 726 |
| 727 // Navigate to a URL that redirects to another process and approve the | 727 // Navigate to a URL that redirects to another process and approve the |
| 728 // beforeunload dialog that pops up. | 728 // beforeunload dialog that pops up. |
| 729 content::WindowedNotificationObserver nav_observer( | 729 content::WindowedNotificationObserver nav_observer( |
| 730 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 730 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 731 content::NotificationService::AllSources()); | 731 content::NotificationService::AllSources()); |
| 732 GURL https_url(https_test_server.GetURL("files/title1.html")); | 732 GURL https_url(https_test_server.GetURL("files/title1.html")); |
| 733 GURL redirect_url(test_server()->GetURL("server-redirect?" + | 733 GURL redirect_url(test_server()->GetURL("server-redirect?" + |
| 734 https_url.spec())); | 734 https_url.spec())); |
| 735 browser()->OpenURL(OpenURLParams(redirect_url, Referrer(), CURRENT_TAB, | 735 browser()->OpenURL(OpenURLParams(redirect_url, Referrer(), CURRENT_TAB, |
| 736 content::PAGE_TRANSITION_TYPED, false)); | 736 ui::PAGE_TRANSITION_TYPED, false)); |
| 737 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 737 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 738 EXPECT_TRUE( | 738 EXPECT_TRUE( |
| 739 static_cast<JavaScriptAppModalDialog*>(alert)->is_before_unload_dialog()); | 739 static_cast<JavaScriptAppModalDialog*>(alert)->is_before_unload_dialog()); |
| 740 alert->native_dialog()->AcceptAppModalDialog(); | 740 alert->native_dialog()->AcceptAppModalDialog(); |
| 741 nav_observer.Wait(); | 741 nav_observer.Wait(); |
| 742 | 742 |
| 743 // Restore previous browser client. | 743 // Restore previous browser client. |
| 744 SetBrowserClientForTesting(old_client); | 744 SetBrowserClientForTesting(old_client); |
| 745 } | 745 } |
| 746 | 746 |
| 747 // Test for crbug.com/80401. Canceling a before unload dialog should reset | 747 // Test for crbug.com/80401. Canceling a before unload dialog should reset |
| 748 // the URL to the previous page's URL. | 748 // the URL to the previous page's URL. |
| 749 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { | 749 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { |
| 750 GURL url(ui_test_utils::GetTestUrl(base::FilePath( | 750 GURL url(ui_test_utils::GetTestUrl(base::FilePath( |
| 751 base::FilePath::kCurrentDirectory), base::FilePath(kBeforeUnloadFile))); | 751 base::FilePath::kCurrentDirectory), base::FilePath(kBeforeUnloadFile))); |
| 752 ui_test_utils::NavigateToURL(browser(), url); | 752 ui_test_utils::NavigateToURL(browser(), url); |
| 753 | 753 |
| 754 // Navigate to a page that triggers a cross-site transition. | 754 // Navigate to a page that triggers a cross-site transition. |
| 755 ASSERT_TRUE(test_server()->Start()); | 755 ASSERT_TRUE(test_server()->Start()); |
| 756 GURL url2(test_server()->GetURL("files/title1.html")); | 756 GURL url2(test_server()->GetURL("files/title1.html")); |
| 757 browser()->OpenURL(OpenURLParams( | 757 browser()->OpenURL(OpenURLParams( |
| 758 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 758 url2, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 759 | 759 |
| 760 content::WindowedNotificationObserver host_destroyed_observer( | 760 content::WindowedNotificationObserver host_destroyed_observer( |
| 761 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 761 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 762 content::NotificationService::AllSources()); | 762 content::NotificationService::AllSources()); |
| 763 | 763 |
| 764 // Cancel the dialog. | 764 // Cancel the dialog. |
| 765 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 765 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 766 alert->CloseModalDialog(); | 766 alert->CloseModalDialog(); |
| 767 EXPECT_FALSE( | 767 EXPECT_FALSE( |
| 768 browser()->tab_strip_model()->GetActiveWebContents()->IsLoading()); | 768 browser()->tab_strip_model()->GetActiveWebContents()->IsLoading()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 chrome::Reload(browser(), CURRENT_TAB); | 823 chrome::Reload(browser(), CURRENT_TAB); |
| 824 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 824 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 825 EXPECT_TRUE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload()); | 825 EXPECT_TRUE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload()); |
| 826 | 826 |
| 827 // Cancel the reload. | 827 // Cancel the reload. |
| 828 alert->native_dialog()->CancelAppModalDialog(); | 828 alert->native_dialog()->CancelAppModalDialog(); |
| 829 | 829 |
| 830 // Navigate to another url, and check that we get a "before unload" dialog. | 830 // Navigate to another url, and check that we get a "before unload" dialog. |
| 831 GURL url2(url::kAboutBlankURL); | 831 GURL url2(url::kAboutBlankURL); |
| 832 browser()->OpenURL(OpenURLParams( | 832 browser()->OpenURL(OpenURLParams( |
| 833 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 833 url2, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 834 | 834 |
| 835 alert = ui_test_utils::WaitForAppModalDialog(); | 835 alert = ui_test_utils::WaitForAppModalDialog(); |
| 836 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload()); | 836 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload()); |
| 837 | 837 |
| 838 // Accept the navigation so we end up on a page without a beforeunload hook. | 838 // Accept the navigation so we end up on a page without a beforeunload hook. |
| 839 alert->native_dialog()->AcceptAppModalDialog(); | 839 alert->native_dialog()->AcceptAppModalDialog(); |
| 840 } | 840 } |
| 841 | 841 |
| 842 // BeforeUnloadAtQuitWithTwoWindows is a regression test for | 842 // BeforeUnloadAtQuitWithTwoWindows is a regression test for |
| 843 // http://crbug.com/11842. It opens two windows, one of which has a | 843 // http://crbug.com/11842. It opens two windows, one of which has a |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 // Change a tab into an application window. | 1177 // Change a tab into an application window. |
| 1178 // DISABLED: http://crbug.com/72310 | 1178 // DISABLED: http://crbug.com/72310 |
| 1179 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { | 1179 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { |
| 1180 ASSERT_TRUE(test_server()->Start()); | 1180 ASSERT_TRUE(test_server()->Start()); |
| 1181 GURL http_url(test_server()->GetURL(std::string())); | 1181 GURL http_url(test_server()->GetURL(std::string())); |
| 1182 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); | 1182 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); |
| 1183 | 1183 |
| 1184 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1184 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| 1185 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0); | 1185 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 1186 WebContents* app_tab = chrome::AddSelectedTabWithURL( | 1186 WebContents* app_tab = chrome::AddSelectedTabWithURL( |
| 1187 browser(), http_url, content::PAGE_TRANSITION_TYPED); | 1187 browser(), http_url, ui::PAGE_TRANSITION_TYPED); |
| 1188 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 1188 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 1189 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 1189 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
| 1190 browser()->host_desktop_type())); | 1190 browser()->host_desktop_type())); |
| 1191 | 1191 |
| 1192 // Normal tabs should accept load drops. | 1192 // Normal tabs should accept load drops. |
| 1193 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 1193 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
| 1194 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 1194 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
| 1195 | 1195 |
| 1196 // Turn |app_tab| into a tab in an app panel. | 1196 // Turn |app_tab| into a tab in an app panel. |
| 1197 chrome::ConvertTabToAppWindow(browser(), app_tab); | 1197 chrome::ConvertTabToAppWindow(browser(), app_tab); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 | 1286 |
| 1287 ui_test_utils::NavigateToURL(browser(), url); | 1287 ui_test_utils::NavigateToURL(browser(), url); |
| 1288 | 1288 |
| 1289 WebContents* app_contents = WebContents::Create( | 1289 WebContents* app_contents = WebContents::Create( |
| 1290 WebContents::CreateParams(browser()->profile())); | 1290 WebContents::CreateParams(browser()->profile())); |
| 1291 extensions::TabHelper::CreateForWebContents(app_contents); | 1291 extensions::TabHelper::CreateForWebContents(app_contents); |
| 1292 extensions::TabHelper* extensions_tab_helper = | 1292 extensions::TabHelper* extensions_tab_helper = |
| 1293 extensions::TabHelper::FromWebContents(app_contents); | 1293 extensions::TabHelper::FromWebContents(app_contents); |
| 1294 extensions_tab_helper->SetExtensionApp(extension_app); | 1294 extensions_tab_helper->SetExtensionApp(extension_app); |
| 1295 | 1295 |
| 1296 model->AddWebContents(app_contents, 0, content::PageTransitionFromInt(0), | 1296 model->AddWebContents(app_contents, 0, ui::PageTransitionFromInt(0), |
| 1297 TabStripModel::ADD_NONE); | 1297 TabStripModel::ADD_NONE); |
| 1298 model->SetTabPinned(0, true); | 1298 model->SetTabPinned(0, true); |
| 1299 ui_test_utils::NavigateToURL(browser(), url); | 1299 ui_test_utils::NavigateToURL(browser(), url); |
| 1300 | 1300 |
| 1301 MockTabStripModelObserver observer; | 1301 MockTabStripModelObserver observer; |
| 1302 model->AddObserver(&observer); | 1302 model->AddObserver(&observer); |
| 1303 | 1303 |
| 1304 // Uninstall the extension and make sure TabClosing is sent. | 1304 // Uninstall the extension and make sure TabClosing is sent. |
| 1305 ExtensionService* service = extensions::ExtensionSystem::Get( | 1305 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 1306 browser()->profile())->extension_service(); | 1306 browser()->profile())->extension_service(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { | 1409 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { |
| 1410 scoped_ptr<test::CldDataHarness> cld_data_harness = | 1410 scoped_ptr<test::CldDataHarness> cld_data_harness = |
| 1411 test::CreateCldDataHarness(); | 1411 test::CreateCldDataHarness(); |
| 1412 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); | 1412 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); |
| 1413 ASSERT_TRUE(test_server()->Start()); | 1413 ASSERT_TRUE(test_server()->Start()); |
| 1414 | 1414 |
| 1415 translate::LanguageDetectionDetails details; | 1415 translate::LanguageDetectionDetails details; |
| 1416 | 1416 |
| 1417 // Open a new tab with a page in English. | 1417 // Open a new tab with a page in English. |
| 1418 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), | 1418 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), |
| 1419 content::PAGE_TRANSITION_TYPED); | 1419 ui::PAGE_TRANSITION_TYPED); |
| 1420 | 1420 |
| 1421 WebContents* current_web_contents = | 1421 WebContents* current_web_contents = |
| 1422 browser()->tab_strip_model()->GetActiveWebContents(); | 1422 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1423 ChromeTranslateClient* chrome_translate_client = | 1423 ChromeTranslateClient* chrome_translate_client = |
| 1424 ChromeTranslateClient::FromWebContents(current_web_contents); | 1424 ChromeTranslateClient::FromWebContents(current_web_contents); |
| 1425 content::Source<WebContents> source(current_web_contents); | 1425 content::Source<WebContents> source(current_web_contents); |
| 1426 | 1426 |
| 1427 ui_test_utils::WindowedNotificationObserverWithDetails< | 1427 ui_test_utils::WindowedNotificationObserverWithDetails< |
| 1428 translate::LanguageDetectionDetails> | 1428 translate::LanguageDetectionDetails> |
| 1429 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1429 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 TabStripModel* model = browser()->tab_strip_model(); | 1470 TabStripModel* model = browser()->tab_strip_model(); |
| 1471 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1471 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 1472 const Extension* extension_app = GetExtension(); | 1472 const Extension* extension_app = GetExtension(); |
| 1473 ui_test_utils::NavigateToURL(browser(), url); | 1473 ui_test_utils::NavigateToURL(browser(), url); |
| 1474 WebContents* app_contents = WebContents::Create( | 1474 WebContents* app_contents = WebContents::Create( |
| 1475 WebContents::CreateParams(browser()->profile())); | 1475 WebContents::CreateParams(browser()->profile())); |
| 1476 extensions::TabHelper::CreateForWebContents(app_contents); | 1476 extensions::TabHelper::CreateForWebContents(app_contents); |
| 1477 extensions::TabHelper* extensions_tab_helper = | 1477 extensions::TabHelper* extensions_tab_helper = |
| 1478 extensions::TabHelper::FromWebContents(app_contents); | 1478 extensions::TabHelper::FromWebContents(app_contents); |
| 1479 extensions_tab_helper->SetExtensionApp(extension_app); | 1479 extensions_tab_helper->SetExtensionApp(extension_app); |
| 1480 model->AddWebContents(app_contents, 0, content::PageTransitionFromInt(0), | 1480 model->AddWebContents(app_contents, 0, ui::PageTransitionFromInt(0), |
| 1481 TabStripModel::ADD_NONE); | 1481 TabStripModel::ADD_NONE); |
| 1482 model->SetTabPinned(0, true); | 1482 model->SetTabPinned(0, true); |
| 1483 ui_test_utils::NavigateToURL(browser(), url); | 1483 ui_test_utils::NavigateToURL(browser(), url); |
| 1484 | 1484 |
| 1485 // Add a non pinned tab. | 1485 // Add a non pinned tab. |
| 1486 chrome::NewTab(browser()); | 1486 chrome::NewTab(browser()); |
| 1487 | 1487 |
| 1488 // Add a pinned non-app tab. | 1488 // Add a pinned non-app tab. |
| 1489 chrome::NewTab(browser()); | 1489 chrome::NewTab(browser()); |
| 1490 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 1490 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 // We start with a normal browser with one tab. | 2077 // We start with a normal browser with one tab. |
| 2078 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 2078 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 2079 | 2079 |
| 2080 // Open a popup browser with a single blank foreground tab. | 2080 // Open a popup browser with a single blank foreground tab. |
| 2081 Browser* popup_browser = new Browser( | 2081 Browser* popup_browser = new Browser( |
| 2082 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); | 2082 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
| 2083 chrome::AddTabAt(popup_browser, GURL(), -1, true); | 2083 chrome::AddTabAt(popup_browser, GURL(), -1, true); |
| 2084 EXPECT_EQ(1, popup_browser->tab_strip_model()->count()); | 2084 EXPECT_EQ(1, popup_browser->tab_strip_model()->count()); |
| 2085 | 2085 |
| 2086 // Now try opening another tab in the popup browser. | 2086 // Now try opening another tab in the popup browser. |
| 2087 AddTabWithURLParams params1(url, content::PAGE_TRANSITION_TYPED); | 2087 AddTabWithURLParams params1(url, ui::PAGE_TRANSITION_TYPED); |
| 2088 popup_browser->AddTabWithURL(¶ms1); | 2088 popup_browser->AddTabWithURL(¶ms1); |
| 2089 EXPECT_EQ(popup_browser, params1.target); | 2089 EXPECT_EQ(popup_browser, params1.target); |
| 2090 | 2090 |
| 2091 // The popup should still only have one tab. | 2091 // The popup should still only have one tab. |
| 2092 EXPECT_EQ(1, popup_browser->tab_strip_model()->count()); | 2092 EXPECT_EQ(1, popup_browser->tab_strip_model()->count()); |
| 2093 | 2093 |
| 2094 // The normal browser should now have two. | 2094 // The normal browser should now have two. |
| 2095 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 2095 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 2096 | 2096 |
| 2097 // Open an app frame browser with a single blank foreground tab. | 2097 // Open an app frame browser with a single blank foreground tab. |
| 2098 Browser* app_browser = new Browser(Browser::CreateParams::CreateForApp( | 2098 Browser* app_browser = new Browser(Browser::CreateParams::CreateForApp( |
| 2099 L"Test", browser()->profile(), false)); | 2099 L"Test", browser()->profile(), false)); |
| 2100 chrome::AddTabAt(app_browser, GURL(), -1, true); | 2100 chrome::AddTabAt(app_browser, GURL(), -1, true); |
| 2101 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); | 2101 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); |
| 2102 | 2102 |
| 2103 // Now try opening another tab in the app browser. | 2103 // Now try opening another tab in the app browser. |
| 2104 AddTabWithURLParams params2(GURL(url::kAboutBlankURL), | 2104 AddTabWithURLParams params2(GURL(url::kAboutBlankURL), |
| 2105 content::PAGE_TRANSITION_TYPED); | 2105 ui::PAGE_TRANSITION_TYPED); |
| 2106 app_browser->AddTabWithURL(¶ms2); | 2106 app_browser->AddTabWithURL(¶ms2); |
| 2107 EXPECT_EQ(app_browser, params2.target); | 2107 EXPECT_EQ(app_browser, params2.target); |
| 2108 | 2108 |
| 2109 // The popup should still only have one tab. | 2109 // The popup should still only have one tab. |
| 2110 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); | 2110 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); |
| 2111 | 2111 |
| 2112 // The normal browser should now have three. | 2112 // The normal browser should now have three. |
| 2113 EXPECT_EQ(3, browser()->tab_strip_model()->count()); | 2113 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 2114 | 2114 |
| 2115 // Open an app frame popup browser with a single blank foreground tab. | 2115 // Open an app frame popup browser with a single blank foreground tab. |
| 2116 Browser* app_popup_browser = new Browser(Browser::CreateParams::CreateForApp( | 2116 Browser* app_popup_browser = new Browser(Browser::CreateParams::CreateForApp( |
| 2117 L"Test", browser()->profile(), false)); | 2117 L"Test", browser()->profile(), false)); |
| 2118 chrome::AddTabAt(app_popup_browser, GURL(), -1, true); | 2118 chrome::AddTabAt(app_popup_browser, GURL(), -1, true); |
| 2119 EXPECT_EQ(1, app_popup_browser->tab_strip_model()->count()); | 2119 EXPECT_EQ(1, app_popup_browser->tab_strip_model()->count()); |
| 2120 | 2120 |
| 2121 // Now try opening another tab in the app popup browser. | 2121 // Now try opening another tab in the app popup browser. |
| 2122 AddTabWithURLParams params3(GURL(url::kAboutBlankURL), | 2122 AddTabWithURLParams params3(GURL(url::kAboutBlankURL), |
| 2123 content::PAGE_TRANSITION_TYPED); | 2123 ui::PAGE_TRANSITION_TYPED); |
| 2124 app_popup_browser->AddTabWithURL(¶ms3); | 2124 app_popup_browser->AddTabWithURL(¶ms3); |
| 2125 EXPECT_EQ(app_popup_browser, params3.target); | 2125 EXPECT_EQ(app_popup_browser, params3.target); |
| 2126 | 2126 |
| 2127 // The popup should still only have one tab. | 2127 // The popup should still only have one tab. |
| 2128 EXPECT_EQ(1, app_popup_browser->tab_strip_model()->count()); | 2128 EXPECT_EQ(1, app_popup_browser->tab_strip_model()->count()); |
| 2129 | 2129 |
| 2130 // The normal browser should now have four. | 2130 // The normal browser should now have four. |
| 2131 EXPECT_EQ(4, browser()->tab_strip_model()->count()); | 2131 EXPECT_EQ(4, browser()->tab_strip_model()->count()); |
| 2132 | 2132 |
| 2133 // Close the additional browsers. | 2133 // Close the additional browsers. |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2713 #endif | 2713 #endif |
| 2714 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); | 2714 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); |
| 2715 EXPECT_EQ(exp_commit_size, wcv_commit_size2); | 2715 EXPECT_EQ(exp_commit_size, wcv_commit_size2); |
| 2716 gfx::Size exp_final_size(initial_wcv_size); | 2716 gfx::Size exp_final_size(initial_wcv_size); |
| 2717 exp_final_size.Enlarge(wcv_resize_insets.width(), | 2717 exp_final_size.Enlarge(wcv_resize_insets.width(), |
| 2718 wcv_resize_insets.height() + height_inset); | 2718 wcv_resize_insets.height() + height_inset); |
| 2719 EXPECT_EQ(exp_final_size, | 2719 EXPECT_EQ(exp_final_size, |
| 2720 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2720 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
| 2721 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); | 2721 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); |
| 2722 } | 2722 } |
| OLD | NEW |