| OLD | NEW |
| 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 <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" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/strings/string_split.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/chrome_content_browser_client.h" | 19 #include "chrome/browser/chrome_content_browser_client.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/command_updater.h" | 21 #include "chrome/browser/command_updater.h" |
| 21 #include "chrome/browser/defaults.h" | 22 #include "chrome/browser/defaults.h" |
| 22 #include "chrome/browser/devtools/devtools_window_testing.h" | 23 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 23 #include "chrome/browser/extensions/extension_browsertest.h" | 24 #include "chrome/browser/extensions/extension_browsertest.h" |
| 24 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 #include "content/public/test/test_navigation_observer.h" | 94 #include "content/public/test/test_navigation_observer.h" |
| 94 #include "extensions/browser/extension_registry.h" | 95 #include "extensions/browser/extension_registry.h" |
| 95 #include "extensions/browser/extension_system.h" | 96 #include "extensions/browser/extension_system.h" |
| 96 #include "extensions/browser/uninstall_reason.h" | 97 #include "extensions/browser/uninstall_reason.h" |
| 97 #include "extensions/common/constants.h" | 98 #include "extensions/common/constants.h" |
| 98 #include "extensions/common/extension.h" | 99 #include "extensions/common/extension.h" |
| 99 #include "extensions/common/extension_set.h" | 100 #include "extensions/common/extension_set.h" |
| 100 #include "net/base/net_errors.h" | 101 #include "net/base/net_errors.h" |
| 101 #include "net/dns/mock_host_resolver.h" | 102 #include "net/dns/mock_host_resolver.h" |
| 102 #include "net/ssl/ssl_connection_status_flags.h" | 103 #include "net/ssl/ssl_connection_status_flags.h" |
| 104 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 105 #include "net/test/embedded_test_server/request_handler_util.h" |
| 103 #include "net/test/spawned_test_server/spawned_test_server.h" | 106 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 104 #include "net/test/url_request/url_request_mock_http_job.h" | 107 #include "net/test/url_request/url_request_mock_http_job.h" |
| 105 #include "net/url_request/url_request_filter.h" | 108 #include "net/url_request/url_request_filter.h" |
| 106 #include "net/url_request/url_request_test_util.h" | 109 #include "net/url_request/url_request_test_util.h" |
| 107 #include "ui/base/l10n/l10n_util.h" | 110 #include "ui/base/l10n/l10n_util.h" |
| 108 #include "ui/base/page_transition_types.h" | 111 #include "ui/base/page_transition_types.h" |
| 109 | 112 |
| 110 #if defined(OS_MACOSX) | 113 #if defined(OS_MACOSX) |
| 111 #include "base/mac/mac_util.h" | 114 #include "base/mac/mac_util.h" |
| 112 #include "base/mac/scoped_nsautorelease_pool.h" | 115 #include "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 InterstitialPage* interstitial_page = web_contents->GetInterstitialPage(); | 338 InterstitialPage* interstitial_page = web_contents->GetInterstitialPage(); |
| 336 ASSERT_TRUE(interstitial_page); | 339 ASSERT_TRUE(interstitial_page); |
| 337 | 340 |
| 338 content::WindowedNotificationObserver observer( | 341 content::WindowedNotificationObserver observer( |
| 339 content::NOTIFICATION_LOAD_STOP, | 342 content::NOTIFICATION_LOAD_STOP, |
| 340 content::Source<NavigationController>(&web_contents->GetController())); | 343 content::Source<NavigationController>(&web_contents->GetController())); |
| 341 interstitial_page->Proceed(); | 344 interstitial_page->Proceed(); |
| 342 observer.Wait(); | 345 observer.Wait(); |
| 343 } | 346 } |
| 344 | 347 |
| 345 bool GetFilePathWithHostAndPortReplacement( | 348 void GetFilePathWithHostAndPortReplacement( |
| 346 const std::string& original_file_path, | 349 const std::string& original_file_path, |
| 347 const net::HostPortPair& host_port_pair, | 350 const net::HostPortPair& host_port_pair, |
| 348 std::string* replacement_path) { | 351 std::string* replacement_path) { |
| 349 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 352 base::StringPairs replacement_text; |
| 350 replacement_text.push_back( | 353 replacement_text.push_back( |
| 351 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); | 354 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); |
| 352 return net::SpawnedTestServer::GetFilePathWithReplacements( | 355 net::test_server::GetFilePathWithReplacements( |
| 353 original_file_path, replacement_text, replacement_path); | 356 original_file_path, replacement_text, replacement_path); |
| 354 } | 357 } |
| 355 | 358 |
| 356 // A WebContentsObserver useful for testing the SecurityStyleChanged() | 359 // A WebContentsObserver useful for testing the SecurityStyleChanged() |
| 357 // method: it keeps track of the latest security style and explanation | 360 // method: it keeps track of the latest security style and explanation |
| 358 // that was fired. | 361 // that was fired. |
| 359 class SecurityStyleTestObserver : public WebContentsObserver { | 362 class SecurityStyleTestObserver : public WebContentsObserver { |
| 360 public: | 363 public: |
| 361 explicit SecurityStyleTestObserver(content::WebContents* web_contents) | 364 explicit SecurityStyleTestObserver(content::WebContents* web_contents) |
| 362 : content::WebContentsObserver(web_contents), | 365 : content::WebContentsObserver(web_contents), |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 EXPECT_GE(CountRenderProcessHosts(), kExpectedProcessCount); | 639 EXPECT_GE(CountRenderProcessHosts(), kExpectedProcessCount); |
| 637 } else { | 640 } else { |
| 638 EXPECT_LT(CountRenderProcessHosts(), kExpectedProcessCount); | 641 EXPECT_LT(CountRenderProcessHosts(), kExpectedProcessCount); |
| 639 } | 642 } |
| 640 } | 643 } |
| 641 | 644 |
| 642 // Test that a browser-initiated navigation to an aborted URL load leaves around | 645 // Test that a browser-initiated navigation to an aborted URL load leaves around |
| 643 // a pending entry if we start from the NTP but not from a normal page. | 646 // a pending entry if we start from the NTP but not from a normal page. |
| 644 // See http://crbug.com/355537. | 647 // See http://crbug.com/355537. |
| 645 IN_PROC_BROWSER_TEST_F(BrowserTest, ClearPendingOnFailUnlessNTP) { | 648 IN_PROC_BROWSER_TEST_F(BrowserTest, ClearPendingOnFailUnlessNTP) { |
| 646 ASSERT_TRUE(test_server()->Start()); | 649 ASSERT_TRUE(embedded_test_server()->Start()); |
| 647 WebContents* web_contents = | 650 WebContents* web_contents = |
| 648 browser()->tab_strip_model()->GetActiveWebContents(); | 651 browser()->tab_strip_model()->GetActiveWebContents(); |
| 649 GURL ntp_url(search::GetNewTabPageURL(browser()->profile())); | 652 GURL ntp_url(search::GetNewTabPageURL(browser()->profile())); |
| 650 ui_test_utils::NavigateToURL(browser(), ntp_url); | 653 ui_test_utils::NavigateToURL(browser(), ntp_url); |
| 651 | 654 |
| 652 // Navigate to a 204 URL (aborts with no content) on the NTP and make sure it | 655 // Navigate to a 204 URL (aborts with no content) on the NTP and make sure it |
| 653 // sticks around so that the user can edit it. | 656 // sticks around so that the user can edit it. |
| 654 GURL abort_url(test_server()->GetURL("nocontent")); | 657 GURL abort_url(embedded_test_server()->GetURL("/nocontent")); |
| 655 { | 658 { |
| 656 content::WindowedNotificationObserver stop_observer( | 659 content::WindowedNotificationObserver stop_observer( |
| 657 content::NOTIFICATION_LOAD_STOP, | 660 content::NOTIFICATION_LOAD_STOP, |
| 658 content::Source<NavigationController>( | 661 content::Source<NavigationController>( |
| 659 &web_contents->GetController())); | 662 &web_contents->GetController())); |
| 660 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, | 663 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, |
| 661 ui::PAGE_TRANSITION_TYPED, false)); | 664 ui::PAGE_TRANSITION_TYPED, false)); |
| 662 stop_observer.Wait(); | 665 stop_observer.Wait(); |
| 663 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); | 666 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); |
| 664 EXPECT_EQ(abort_url, web_contents->GetVisibleURL()); | 667 EXPECT_EQ(abort_url, web_contents->GetVisibleURL()); |
| 665 } | 668 } |
| 666 | 669 |
| 667 // Navigate to a real URL. | 670 // Navigate to a real URL. |
| 668 GURL real_url(test_server()->GetURL("title1.html")); | 671 GURL real_url(embedded_test_server()->GetURL("/title1.html")); |
| 669 ui_test_utils::NavigateToURL(browser(), real_url); | 672 ui_test_utils::NavigateToURL(browser(), real_url); |
| 670 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); | 673 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); |
| 671 | 674 |
| 672 // Now navigating to a 204 URL should clear the pending entry. | 675 // Now navigating to a 204 URL should clear the pending entry. |
| 673 { | 676 { |
| 674 content::WindowedNotificationObserver stop_observer( | 677 content::WindowedNotificationObserver stop_observer( |
| 675 content::NOTIFICATION_LOAD_STOP, | 678 content::NOTIFICATION_LOAD_STOP, |
| 676 content::Source<NavigationController>( | 679 content::Source<NavigationController>( |
| 677 &web_contents->GetController())); | 680 &web_contents->GetController())); |
| 678 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, | 681 browser()->OpenURL(OpenURLParams(abort_url, Referrer(), CURRENT_TAB, |
| 679 ui::PAGE_TRANSITION_TYPED, false)); | 682 ui::PAGE_TRANSITION_TYPED, false)); |
| 680 stop_observer.Wait(); | 683 stop_observer.Wait(); |
| 681 EXPECT_FALSE(web_contents->GetController().GetPendingEntry()); | 684 EXPECT_FALSE(web_contents->GetController().GetPendingEntry()); |
| 682 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); | 685 EXPECT_EQ(real_url, web_contents->GetVisibleURL()); |
| 683 } | 686 } |
| 684 } | 687 } |
| 685 | 688 |
| 686 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a | 689 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a |
| 687 // cross-process navigation is ready to commit. | 690 // cross-process navigation is ready to commit. |
| 688 // Flaky test, see https://crbug.com/445155. | 691 // Flaky test, see https://crbug.com/445155. |
| 689 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_CrossProcessNavCancelsDialogs) { | 692 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_CrossProcessNavCancelsDialogs) { |
| 690 ASSERT_TRUE(test_server()->Start()); | 693 ASSERT_TRUE(embedded_test_server()->Start()); |
| 691 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 694 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 692 GURL url(test_server()->GetURL("empty.html")); | 695 GURL url(embedded_test_server()->GetURL("/empty.html")); |
| 693 ui_test_utils::NavigateToURL(browser(), url); | 696 ui_test_utils::NavigateToURL(browser(), url); |
| 694 | 697 |
| 695 // Test this with multiple alert dialogs to ensure that we can navigate away | 698 // Test this with multiple alert dialogs to ensure that we can navigate away |
| 696 // even if the renderer tries to synchronously create more. | 699 // even if the renderer tries to synchronously create more. |
| 697 // See http://crbug.com/312490. | 700 // See http://crbug.com/312490. |
| 698 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 701 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 699 contents->GetMainFrame()->ExecuteJavaScriptForTests( | 702 contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 700 ASCIIToUTF16("alert('one'); alert('two');")); | 703 ASCIIToUTF16("alert('one'); alert('two');")); |
| 701 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 704 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 702 EXPECT_TRUE(alert->IsValid()); | 705 EXPECT_TRUE(alert->IsValid()); |
| 703 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 706 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 704 EXPECT_TRUE(dialog_queue->HasActiveDialog()); | 707 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
| 705 | 708 |
| 706 // A cross-site navigation should force the dialog to close. | 709 // A cross-site navigation should force the dialog to close. |
| 707 GURL url2("http://www.example.com/empty.html"); | 710 GURL url2("http://www.example.com/empty.html"); |
| 708 ui_test_utils::NavigateToURL(browser(), url2); | 711 ui_test_utils::NavigateToURL(browser(), url2); |
| 709 EXPECT_FALSE(dialog_queue->HasActiveDialog()); | 712 EXPECT_FALSE(dialog_queue->HasActiveDialog()); |
| 710 | 713 |
| 711 // Make sure input events still work in the renderer process. | 714 // Make sure input events still work in the renderer process. |
| 712 EXPECT_FALSE(contents->GetRenderProcessHost()->IgnoreInputEvents()); | 715 EXPECT_FALSE(contents->GetRenderProcessHost()->IgnoreInputEvents()); |
| 713 } | 716 } |
| 714 | 717 |
| 715 // Make sure that dialogs are closed after a renderer process dies, and that | 718 // Make sure that dialogs are closed after a renderer process dies, and that |
| 716 // subsequent navigations work. See http://crbug/com/343265. | 719 // subsequent navigations work. See http://crbug/com/343265. |
| 717 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsDialogs) { | 720 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsDialogs) { |
| 718 ASSERT_TRUE(test_server()->Start()); | 721 ASSERT_TRUE(embedded_test_server()->Start()); |
| 719 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 722 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 720 GURL beforeunload_url(test_server()->GetURL("files/beforeunload.html")); | 723 GURL beforeunload_url(embedded_test_server()->GetURL("/beforeunload.html")); |
| 721 ui_test_utils::NavigateToURL(browser(), beforeunload_url); | 724 ui_test_utils::NavigateToURL(browser(), beforeunload_url); |
| 722 | 725 |
| 723 // Start a navigation to trigger the beforeunload dialog. | 726 // Start a navigation to trigger the beforeunload dialog. |
| 724 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 727 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 725 contents->GetMainFrame()->ExecuteJavaScriptForTests( | 728 contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 726 ASCIIToUTF16("window.location.href = 'data:text/html,foo'")); | 729 ASCIIToUTF16("window.location.href = 'data:text/html,foo'")); |
| 727 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 730 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 728 EXPECT_TRUE(alert->IsValid()); | 731 EXPECT_TRUE(alert->IsValid()); |
| 729 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 732 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 730 EXPECT_TRUE(dialog_queue->HasActiveDialog()); | 733 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
| 731 | 734 |
| 732 // Crash the renderer process and ensure the dialog is gone. | 735 // Crash the renderer process and ensure the dialog is gone. |
| 733 content::RenderProcessHost* child_process = contents->GetRenderProcessHost(); | 736 content::RenderProcessHost* child_process = contents->GetRenderProcessHost(); |
| 734 content::RenderProcessHostWatcher crash_observer( | 737 content::RenderProcessHostWatcher crash_observer( |
| 735 child_process, | 738 child_process, |
| 736 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 739 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 737 child_process->Shutdown(0, false); | 740 child_process->Shutdown(0, false); |
| 738 crash_observer.Wait(); | 741 crash_observer.Wait(); |
| 739 EXPECT_FALSE(dialog_queue->HasActiveDialog()); | 742 EXPECT_FALSE(dialog_queue->HasActiveDialog()); |
| 740 | 743 |
| 741 // Make sure subsequent navigations work. | 744 // Make sure subsequent navigations work. |
| 742 GURL url2("http://www.example.com/files/empty.html"); | 745 GURL url2("http://www.example.com/empty.html"); |
| 743 ui_test_utils::NavigateToURL(browser(), url2); | 746 ui_test_utils::NavigateToURL(browser(), url2); |
| 744 } | 747 } |
| 745 | 748 |
| 746 // Make sure that dialogs opened by subframes are closed when the process dies. | 749 // Make sure that dialogs opened by subframes are closed when the process dies. |
| 747 // See http://crbug.com/366510. | 750 // See http://crbug.com/366510. |
| 748 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsSubframeDialogs) { | 751 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsSubframeDialogs) { |
| 749 // Navigate to an iframe that opens an alert dialog. | 752 // Navigate to an iframe that opens an alert dialog. |
| 750 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 753 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 751 contents->GetMainFrame()->ExecuteJavaScriptForTests( | 754 contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 752 ASCIIToUTF16("window.location.href = 'data:text/html," | 755 ASCIIToUTF16("window.location.href = 'data:text/html," |
| (...skipping 14 matching lines...) Expand all Loading... |
| 767 | 770 |
| 768 // Make sure subsequent navigations work. | 771 // Make sure subsequent navigations work. |
| 769 GURL url2("data:text/html,foo"); | 772 GURL url2("data:text/html,foo"); |
| 770 ui_test_utils::NavigateToURL(browser(), url2); | 773 ui_test_utils::NavigateToURL(browser(), url2); |
| 771 } | 774 } |
| 772 | 775 |
| 773 // Make sure modal dialogs within a guestview are closed when an interstitial | 776 // Make sure modal dialogs within a guestview are closed when an interstitial |
| 774 // page is showing. See crbug.com/482380. | 777 // page is showing. See crbug.com/482380. |
| 775 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCancelsGuestViewDialogs) { | 778 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCancelsGuestViewDialogs) { |
| 776 // Navigate to a PDF, which is loaded within a guestview. | 779 // Navigate to a PDF, which is loaded within a guestview. |
| 777 ASSERT_TRUE(test_server()->Start()); | 780 ASSERT_TRUE(embedded_test_server()->Start()); |
| 778 GURL pdf_with_dialog(test_server()->GetURL("files/alert_dialog.pdf")); | 781 GURL pdf_with_dialog(embedded_test_server()->GetURL("/alert_dialog.pdf")); |
| 779 ui_test_utils::NavigateToURL(browser(), pdf_with_dialog); | 782 ui_test_utils::NavigateToURL(browser(), pdf_with_dialog); |
| 780 | 783 |
| 781 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 784 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 782 EXPECT_TRUE(alert->IsValid()); | 785 EXPECT_TRUE(alert->IsValid()); |
| 783 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 786 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 784 EXPECT_TRUE(dialog_queue->HasActiveDialog()); | 787 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
| 785 | 788 |
| 786 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 789 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 787 | 790 |
| 788 TestInterstitialPage* interstitial = | 791 TestInterstitialPage* interstitial = |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 | 846 |
| 844 DISALLOW_COPY_AND_ASSIGN(RedirectObserver); | 847 DISALLOW_COPY_AND_ASSIGN(RedirectObserver); |
| 845 }; | 848 }; |
| 846 | 849 |
| 847 // Ensure that a transferred cross-process navigation does not generate | 850 // Ensure that a transferred cross-process navigation does not generate |
| 848 // DidStopLoading events until the navigation commits. If it did, then | 851 // DidStopLoading events until the navigation commits. If it did, then |
| 849 // ui_test_utils::NavigateToURL would proceed before the URL had committed. | 852 // ui_test_utils::NavigateToURL would proceed before the URL had committed. |
| 850 // http://crbug.com/243957. | 853 // http://crbug.com/243957. |
| 851 IN_PROC_BROWSER_TEST_F(BrowserTest, NoStopDuringTransferUntilCommit) { | 854 IN_PROC_BROWSER_TEST_F(BrowserTest, NoStopDuringTransferUntilCommit) { |
| 852 // Create HTTP and HTTPS servers for a cross-site transition. | 855 // Create HTTP and HTTPS servers for a cross-site transition. |
| 853 ASSERT_TRUE(test_server()->Start()); | 856 ASSERT_TRUE(embedded_test_server()->Start()); |
| 854 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 857 net::EmbeddedTestServer https_test_server( |
| 855 net::SpawnedTestServer::kLocalhost, | 858 net::EmbeddedTestServer::TYPE_HTTPS); |
| 856 base::FilePath(kDocRoot)); | 859 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 857 ASSERT_TRUE(https_test_server.Start()); | 860 ASSERT_TRUE(https_test_server.Start()); |
| 858 | 861 |
| 859 // Temporarily replace ContentBrowserClient with one that will cause a | 862 // Temporarily replace ContentBrowserClient with one that will cause a |
| 860 // process swap on all redirects to HTTPS URLs. | 863 // process swap on all redirects to HTTPS URLs. |
| 861 TransferHttpsRedirectsContentBrowserClient new_client; | 864 TransferHttpsRedirectsContentBrowserClient new_client; |
| 862 content::ContentBrowserClient* old_client = | 865 content::ContentBrowserClient* old_client = |
| 863 SetBrowserClientForTesting(&new_client); | 866 SetBrowserClientForTesting(&new_client); |
| 864 | 867 |
| 865 GURL init_url(test_server()->GetURL("files/title1.html")); | 868 GURL init_url(embedded_test_server()->GetURL("/title1.html")); |
| 866 ui_test_utils::NavigateToURL(browser(), init_url); | 869 ui_test_utils::NavigateToURL(browser(), init_url); |
| 867 | 870 |
| 868 // Navigate to a same-site page that redirects, causing a transfer. | 871 // Navigate to a same-site page that redirects, causing a transfer. |
| 869 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 872 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 870 | 873 |
| 871 // Create a RedirectObserver that goes away before we close the tab. | 874 // Create a RedirectObserver that goes away before we close the tab. |
| 872 { | 875 { |
| 873 RedirectObserver redirect_observer(contents); | 876 RedirectObserver redirect_observer(contents); |
| 874 GURL dest_url(https_test_server.GetURL("files/title2.html")); | 877 GURL dest_url(https_test_server.GetURL("/title2.html")); |
| 875 GURL redirect_url(test_server()->GetURL("server-redirect?" + | 878 GURL redirect_url( |
| 876 dest_url.spec())); | 879 embedded_test_server()->GetURL("/server-redirect?" + dest_url.spec())); |
| 877 ui_test_utils::NavigateToURL(browser(), redirect_url); | 880 ui_test_utils::NavigateToURL(browser(), redirect_url); |
| 878 | 881 |
| 879 // We should immediately see the new committed entry. | 882 // We should immediately see the new committed entry. |
| 880 EXPECT_FALSE(contents->GetController().GetPendingEntry()); | 883 EXPECT_FALSE(contents->GetController().GetPendingEntry()); |
| 881 EXPECT_EQ(dest_url, | 884 EXPECT_EQ(dest_url, |
| 882 contents->GetController().GetLastCommittedEntry()->GetURL()); | 885 contents->GetController().GetLastCommittedEntry()->GetURL()); |
| 883 | 886 |
| 884 // We should keep track of the original request URL, redirect chain, and | 887 // We should keep track of the original request URL, redirect chain, and |
| 885 // page transition type during a transfer, since these are necessary for | 888 // page transition type during a transfer, since these are necessary for |
| 886 // history autocomplete to work. | 889 // history autocomplete to work. |
| 887 EXPECT_EQ(redirect_url, contents->GetController().GetLastCommittedEntry()-> | 890 EXPECT_EQ(redirect_url, contents->GetController().GetLastCommittedEntry()-> |
| 888 GetOriginalRequestURL()); | 891 GetOriginalRequestURL()); |
| 889 EXPECT_EQ(2U, redirect_observer.params().redirects.size()); | 892 EXPECT_EQ(2U, redirect_observer.params().redirects.size()); |
| 890 EXPECT_EQ(redirect_url, redirect_observer.params().redirects.at(0)); | 893 EXPECT_EQ(redirect_url, redirect_observer.params().redirects.at(0)); |
| 891 EXPECT_EQ(dest_url, redirect_observer.params().redirects.at(1)); | 894 EXPECT_EQ(dest_url, redirect_observer.params().redirects.at(1)); |
| 892 EXPECT_TRUE(ui::PageTransitionCoreTypeIs( | 895 EXPECT_TRUE(ui::PageTransitionCoreTypeIs( |
| 893 redirect_observer.params().transition, ui::PAGE_TRANSITION_TYPED)); | 896 redirect_observer.params().transition, ui::PAGE_TRANSITION_TYPED)); |
| 894 } | 897 } |
| 895 | 898 |
| 896 // Restore previous browser client. | 899 // Restore previous browser client. |
| 897 SetBrowserClientForTesting(old_client); | 900 SetBrowserClientForTesting(old_client); |
| 898 } | 901 } |
| 899 | 902 |
| 900 // Tests that a cross-process redirect will only cause the beforeunload | 903 // Tests that a cross-process redirect will only cause the beforeunload |
| 901 // handler to run once. | 904 // handler to run once. |
| 902 IN_PROC_BROWSER_TEST_F(BrowserTest, SingleBeforeUnloadAfterRedirect) { | 905 IN_PROC_BROWSER_TEST_F(BrowserTest, SingleBeforeUnloadAfterRedirect) { |
| 903 // Create HTTP and HTTPS servers for a cross-site transition. | 906 // Create HTTP and HTTPS servers for a cross-site transition. |
| 904 ASSERT_TRUE(test_server()->Start()); | 907 ASSERT_TRUE(embedded_test_server()->Start()); |
| 905 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 908 net::EmbeddedTestServer https_test_server( |
| 906 net::SpawnedTestServer::kLocalhost, | 909 net::EmbeddedTestServer::TYPE_HTTPS); |
| 907 base::FilePath(kDocRoot)); | 910 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 908 ASSERT_TRUE(https_test_server.Start()); | 911 ASSERT_TRUE(https_test_server.Start()); |
| 909 | 912 |
| 910 // Temporarily replace ContentBrowserClient with one that will cause a | 913 // Temporarily replace ContentBrowserClient with one that will cause a |
| 911 // process swap on all redirects to HTTPS URLs. | 914 // process swap on all redirects to HTTPS URLs. |
| 912 TransferHttpsRedirectsContentBrowserClient new_client; | 915 TransferHttpsRedirectsContentBrowserClient new_client; |
| 913 content::ContentBrowserClient* old_client = | 916 content::ContentBrowserClient* old_client = |
| 914 SetBrowserClientForTesting(&new_client); | 917 SetBrowserClientForTesting(&new_client); |
| 915 | 918 |
| 916 // Navigate to a page with a beforeunload handler. | 919 // Navigate to a page with a beforeunload handler. |
| 917 GURL url(test_server()->GetURL("files/beforeunload.html")); | 920 GURL url(embedded_test_server()->GetURL("/beforeunload.html")); |
| 918 ui_test_utils::NavigateToURL(browser(), url); | 921 ui_test_utils::NavigateToURL(browser(), url); |
| 919 | 922 |
| 920 // Navigate to a URL that redirects to another process and approve the | 923 // Navigate to a URL that redirects to another process and approve the |
| 921 // beforeunload dialog that pops up. | 924 // beforeunload dialog that pops up. |
| 922 content::WindowedNotificationObserver nav_observer( | 925 content::WindowedNotificationObserver nav_observer( |
| 923 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 926 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 924 content::NotificationService::AllSources()); | 927 content::NotificationService::AllSources()); |
| 925 GURL https_url(https_test_server.GetURL("files/title1.html")); | 928 GURL https_url(https_test_server.GetURL("/title1.html")); |
| 926 GURL redirect_url(test_server()->GetURL("server-redirect?" + | 929 GURL redirect_url( |
| 927 https_url.spec())); | 930 embedded_test_server()->GetURL("/server-redirect?" + https_url.spec())); |
| 928 browser()->OpenURL(OpenURLParams(redirect_url, Referrer(), CURRENT_TAB, | 931 browser()->OpenURL(OpenURLParams(redirect_url, Referrer(), CURRENT_TAB, |
| 929 ui::PAGE_TRANSITION_TYPED, false)); | 932 ui::PAGE_TRANSITION_TYPED, false)); |
| 930 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 933 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 931 EXPECT_TRUE( | 934 EXPECT_TRUE( |
| 932 static_cast<JavaScriptAppModalDialog*>(alert)->is_before_unload_dialog()); | 935 static_cast<JavaScriptAppModalDialog*>(alert)->is_before_unload_dialog()); |
| 933 alert->native_dialog()->AcceptAppModalDialog(); | 936 alert->native_dialog()->AcceptAppModalDialog(); |
| 934 nav_observer.Wait(); | 937 nav_observer.Wait(); |
| 935 | 938 |
| 936 // Restore previous browser client. | 939 // Restore previous browser client. |
| 937 SetBrowserClientForTesting(old_client); | 940 SetBrowserClientForTesting(old_client); |
| 938 } | 941 } |
| 939 | 942 |
| 940 // Test for crbug.com/80401. Canceling a before unload dialog should reset | 943 // Test for crbug.com/80401. Canceling a before unload dialog should reset |
| 941 // the URL to the previous page's URL. | 944 // the URL to the previous page's URL. |
| 942 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { | 945 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { |
| 943 GURL url(ui_test_utils::GetTestUrl(base::FilePath( | 946 GURL url(ui_test_utils::GetTestUrl(base::FilePath( |
| 944 base::FilePath::kCurrentDirectory), base::FilePath(kBeforeUnloadFile))); | 947 base::FilePath::kCurrentDirectory), base::FilePath(kBeforeUnloadFile))); |
| 945 ui_test_utils::NavigateToURL(browser(), url); | 948 ui_test_utils::NavigateToURL(browser(), url); |
| 946 | 949 |
| 947 // Navigate to a page that triggers a cross-site transition. | 950 // Navigate to a page that triggers a cross-site transition. |
| 948 ASSERT_TRUE(test_server()->Start()); | 951 ASSERT_TRUE(embedded_test_server()->Start()); |
| 949 GURL url2(test_server()->GetURL("files/title1.html")); | 952 GURL url2(embedded_test_server()->GetURL("/title1.html")); |
| 950 browser()->OpenURL(OpenURLParams( | 953 browser()->OpenURL(OpenURLParams( |
| 951 url2, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); | 954 url2, Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 952 | 955 |
| 953 content::WindowedNotificationObserver host_destroyed_observer( | 956 content::WindowedNotificationObserver host_destroyed_observer( |
| 954 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 957 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 955 content::NotificationService::AllSources()); | 958 content::NotificationService::AllSources()); |
| 956 | 959 |
| 957 // Cancel the dialog. | 960 // Cancel the dialog. |
| 958 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 961 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 959 alert->CloseModalDialog(); | 962 alert->CloseModalDialog(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 // Test that scripts can fork a new renderer process for a cross-site popup, | 1121 // Test that scripts can fork a new renderer process for a cross-site popup, |
| 1119 // based on http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab. | 1122 // based on http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab. |
| 1120 // The script must open a new tab, set its window.opener to null, and navigate | 1123 // The script must open a new tab, set its window.opener to null, and navigate |
| 1121 // it to a cross-site URL. It should also work for meta-refreshes. | 1124 // it to a cross-site URL. It should also work for meta-refreshes. |
| 1122 // See http://crbug.com/93517. | 1125 // See http://crbug.com/93517. |
| 1123 IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { | 1126 IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { |
| 1124 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1127 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1125 switches::kDisablePopupBlocking); | 1128 switches::kDisablePopupBlocking); |
| 1126 | 1129 |
| 1127 // Create http and https servers for a cross-site transition. | 1130 // Create http and https servers for a cross-site transition. |
| 1128 ASSERT_TRUE(test_server()->Start()); | 1131 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1129 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 1132 net::EmbeddedTestServer https_test_server( |
| 1130 net::SpawnedTestServer::kLocalhost, | 1133 net::EmbeddedTestServer::TYPE_HTTPS); |
| 1131 base::FilePath(kDocRoot)); | 1134 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 1132 ASSERT_TRUE(https_test_server.Start()); | 1135 ASSERT_TRUE(https_test_server.Start()); |
| 1133 GURL http_url(test_server()->GetURL("files/title1.html")); | 1136 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
| 1134 GURL https_url(https_test_server.GetURL(std::string())); | 1137 GURL https_url(https_test_server.GetURL(std::string("/"))); |
| 1135 | 1138 |
| 1136 // Start with an http URL. | 1139 // Start with an http URL. |
| 1137 ui_test_utils::NavigateToURL(browser(), http_url); | 1140 ui_test_utils::NavigateToURL(browser(), http_url); |
| 1138 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); | 1141 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1139 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); | 1142 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
| 1140 | 1143 |
| 1141 // Now open a tab to a blank page, set its opener to null, and redirect it | 1144 // Now open a tab to a blank page, set its opener to null, and redirect it |
| 1142 // cross-site. | 1145 // cross-site. |
| 1143 std::string redirect_popup = "w=window.open();"; | 1146 std::string redirect_popup = "w=window.open();"; |
| 1144 redirect_popup += "w.opener=null;"; | 1147 redirect_popup += "w.opener=null;"; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1210 } |
| 1208 | 1211 |
| 1209 // Tests that other popup navigations that do not follow the steps at | 1212 // Tests that other popup navigations that do not follow the steps at |
| 1210 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not | 1213 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not |
| 1211 // fork a new renderer process. | 1214 // fork a new renderer process. |
| 1212 IN_PROC_BROWSER_TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { | 1215 IN_PROC_BROWSER_TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { |
| 1213 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1216 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1214 switches::kDisablePopupBlocking); | 1217 switches::kDisablePopupBlocking); |
| 1215 | 1218 |
| 1216 // Create http and https servers for a cross-site transition. | 1219 // Create http and https servers for a cross-site transition. |
| 1217 ASSERT_TRUE(test_server()->Start()); | 1220 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1218 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 1221 net::EmbeddedTestServer https_test_server( |
| 1219 net::SpawnedTestServer::kLocalhost, | 1222 net::EmbeddedTestServer::TYPE_HTTPS); |
| 1220 base::FilePath(kDocRoot)); | 1223 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 1221 ASSERT_TRUE(https_test_server.Start()); | 1224 ASSERT_TRUE(https_test_server.Start()); |
| 1222 GURL http_url(test_server()->GetURL("files/title1.html")); | 1225 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
| 1223 GURL https_url(https_test_server.GetURL(std::string())); | 1226 GURL https_url(https_test_server.GetURL("/")); |
| 1224 | 1227 |
| 1225 // Start with an http URL. | 1228 // Start with an http URL. |
| 1226 ui_test_utils::NavigateToURL(browser(), http_url); | 1229 ui_test_utils::NavigateToURL(browser(), http_url); |
| 1227 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); | 1230 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1228 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); | 1231 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
| 1229 | 1232 |
| 1230 // Now open a tab to a blank page, set its opener to null, and redirect it | 1233 // Now open a tab to a blank page, set its opener to null, and redirect it |
| 1231 // cross-site. | 1234 // cross-site. |
| 1232 std::string dont_fork_popup = "w=window.open();"; | 1235 std::string dont_fork_popup = "w=window.open();"; |
| 1233 dont_fork_popup += "w.document.location=\""; | 1236 dont_fork_popup += "w.document.location=\""; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile))); | 1315 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile))); |
| 1313 ASSERT_TRUE(file_url.SchemeIs(url::kFileScheme)); | 1316 ASSERT_TRUE(file_url.SchemeIs(url::kFileScheme)); |
| 1314 ui_test_utils::NavigateToURL(browser(), file_url); | 1317 ui_test_utils::NavigateToURL(browser(), file_url); |
| 1315 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 1318 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 1316 } | 1319 } |
| 1317 | 1320 |
| 1318 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttp) { | 1321 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttp) { |
| 1319 CommandUpdater* command_updater = | 1322 CommandUpdater* command_updater = |
| 1320 browser()->command_controller()->command_updater(); | 1323 browser()->command_controller()->command_updater(); |
| 1321 | 1324 |
| 1322 ASSERT_TRUE(test_server()->Start()); | 1325 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1323 GURL http_url(test_server()->GetURL(std::string())); | 1326 GURL http_url(embedded_test_server()->GetURL("/")); |
| 1324 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); | 1327 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); |
| 1325 ui_test_utils::NavigateToURL(browser(), http_url); | 1328 ui_test_utils::NavigateToURL(browser(), http_url); |
| 1326 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 1329 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 1327 } | 1330 } |
| 1328 | 1331 |
| 1329 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttps) { | 1332 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttps) { |
| 1330 CommandUpdater* command_updater = | 1333 CommandUpdater* command_updater = |
| 1331 browser()->command_controller()->command_updater(); | 1334 browser()->command_controller()->command_updater(); |
| 1332 | 1335 |
| 1333 net::SpawnedTestServer test_server(net::SpawnedTestServer::TYPE_HTTPS, | 1336 net::EmbeddedTestServer https_test_server( |
| 1334 net::SpawnedTestServer::kLocalhost, | 1337 net::EmbeddedTestServer::TYPE_HTTPS); |
| 1335 base::FilePath(kDocRoot)); | 1338 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 1336 ASSERT_TRUE(test_server.Start()); | 1339 ASSERT_TRUE(https_test_server.Start()); |
| 1337 GURL https_url(test_server.GetURL("/")); | 1340 |
| 1341 GURL https_url(https_test_server.GetURL("/")); |
| 1338 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); | 1342 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); |
| 1339 ui_test_utils::NavigateToURL(browser(), https_url); | 1343 ui_test_utils::NavigateToURL(browser(), https_url); |
| 1340 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 1344 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 1341 } | 1345 } |
| 1342 | 1346 |
| 1343 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFtp) { | 1347 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFtp) { |
| 1344 CommandUpdater* command_updater = | 1348 CommandUpdater* command_updater = |
| 1345 browser()->command_controller()->command_updater(); | 1349 browser()->command_controller()->command_updater(); |
| 1346 | 1350 |
| 1347 net::SpawnedTestServer test_server(net::SpawnedTestServer::TYPE_FTP, | 1351 net::SpawnedTestServer test_server(net::SpawnedTestServer::TYPE_FTP, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1368 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 1372 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 1369 | 1373 |
| 1370 GURL blank_url(url::kAboutBlankURL); | 1374 GURL blank_url(url::kAboutBlankURL); |
| 1371 ui_test_utils::NavigateToURL(browser(), blank_url); | 1375 ui_test_utils::NavigateToURL(browser(), blank_url); |
| 1372 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 1376 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 1373 } | 1377 } |
| 1374 | 1378 |
| 1375 // Change a tab into an application window. | 1379 // Change a tab into an application window. |
| 1376 // DISABLED: http://crbug.com/72310 | 1380 // DISABLED: http://crbug.com/72310 |
| 1377 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { | 1381 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { |
| 1378 ASSERT_TRUE(test_server()->Start()); | 1382 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1379 GURL http_url(test_server()->GetURL(std::string())); | 1383 GURL http_url(embedded_test_server()->GetURL("/")); |
| 1380 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); | 1384 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); |
| 1381 | 1385 |
| 1382 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1386 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| 1383 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0); | 1387 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 1384 WebContents* app_tab = chrome::AddSelectedTabWithURL( | 1388 WebContents* app_tab = chrome::AddSelectedTabWithURL( |
| 1385 browser(), http_url, ui::PAGE_TRANSITION_TYPED); | 1389 browser(), http_url, ui::PAGE_TRANSITION_TYPED); |
| 1386 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 1390 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 1387 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 1391 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
| 1388 browser()->host_desktop_type())); | 1392 browser()->host_desktop_type())); |
| 1389 | 1393 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 // The tab in an app window should not. | 1425 // The tab in an app window should not. |
| 1422 EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 1426 EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
| 1423 } | 1427 } |
| 1424 | 1428 |
| 1425 #endif // !defined(OS_MACOSX) | 1429 #endif // !defined(OS_MACOSX) |
| 1426 | 1430 |
| 1427 // Test RenderView correctly send back favicon url for web page that redirects | 1431 // Test RenderView correctly send back favicon url for web page that redirects |
| 1428 // to an anchor in javascript body.onload handler. | 1432 // to an anchor in javascript body.onload handler. |
| 1429 IN_PROC_BROWSER_TEST_F(BrowserTest, | 1433 IN_PROC_BROWSER_TEST_F(BrowserTest, |
| 1430 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { | 1434 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { |
| 1431 ASSERT_TRUE(test_server()->Start()); | 1435 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1432 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); | 1436 GURL url(embedded_test_server()->GetURL("/onload_redirect_to_anchor.html")); |
| 1433 GURL expected_favicon_url(test_server()->GetURL("files/test.png")); | 1437 GURL expected_favicon_url(embedded_test_server()->GetURL("/test.png")); |
| 1434 | 1438 |
| 1435 ui_test_utils::NavigateToURL(browser(), url); | 1439 ui_test_utils::NavigateToURL(browser(), url); |
| 1436 | 1440 |
| 1437 NavigationEntry* entry = browser()->tab_strip_model()-> | 1441 NavigationEntry* entry = browser()->tab_strip_model()-> |
| 1438 GetActiveWebContents()->GetController().GetLastCommittedEntry(); | 1442 GetActiveWebContents()->GetController().GetLastCommittedEntry(); |
| 1439 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); | 1443 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); |
| 1440 } | 1444 } |
| 1441 | 1445 |
| 1442 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined (OS_WIN) | 1446 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined (OS_WIN) |
| 1443 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% | 1447 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1466 // http://crbug.com/172336 | 1470 // http://crbug.com/172336 |
| 1467 #if defined(OS_WIN) | 1471 #if defined(OS_WIN) |
| 1468 #define MAYBE_TabClosingWhenRemovingExtension \ | 1472 #define MAYBE_TabClosingWhenRemovingExtension \ |
| 1469 DISABLED_TabClosingWhenRemovingExtension | 1473 DISABLED_TabClosingWhenRemovingExtension |
| 1470 #else | 1474 #else |
| 1471 #define MAYBE_TabClosingWhenRemovingExtension TabClosingWhenRemovingExtension | 1475 #define MAYBE_TabClosingWhenRemovingExtension TabClosingWhenRemovingExtension |
| 1472 #endif | 1476 #endif |
| 1473 // Makes sure TabClosing is sent when uninstalling an extension that is an app | 1477 // Makes sure TabClosing is sent when uninstalling an extension that is an app |
| 1474 // tab. | 1478 // tab. |
| 1475 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TabClosingWhenRemovingExtension) { | 1479 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TabClosingWhenRemovingExtension) { |
| 1476 ASSERT_TRUE(test_server()->Start()); | 1480 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1477 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1481 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1478 GURL url(test_server()->GetURL("empty.html")); | 1482 GURL url(embedded_test_server()->GetURL("/empty.html")); |
| 1479 TabStripModel* model = browser()->tab_strip_model(); | 1483 TabStripModel* model = browser()->tab_strip_model(); |
| 1480 | 1484 |
| 1481 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1485 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 1482 | 1486 |
| 1483 const Extension* extension_app = GetExtension(); | 1487 const Extension* extension_app = GetExtension(); |
| 1484 | 1488 |
| 1485 ui_test_utils::NavigateToURL(browser(), url); | 1489 ui_test_utils::NavigateToURL(browser(), url); |
| 1486 | 1490 |
| 1487 WebContents* app_contents = WebContents::Create( | 1491 WebContents* app_contents = WebContents::Create( |
| 1488 WebContents::CreateParams(browser()->profile())); | 1492 WebContents::CreateParams(browser()->profile())); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1509 EXPECT_EQ(1, observer.closing_count()); | 1513 EXPECT_EQ(1, observer.closing_count()); |
| 1510 | 1514 |
| 1511 model->RemoveObserver(&observer); | 1515 model->RemoveObserver(&observer); |
| 1512 | 1516 |
| 1513 // There should only be one tab now. | 1517 // There should only be one tab now. |
| 1514 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1518 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| 1515 } | 1519 } |
| 1516 | 1520 |
| 1517 // Open with --app-id=<id>, and see that an application tab opens by default. | 1521 // Open with --app-id=<id>, and see that an application tab opens by default. |
| 1518 IN_PROC_BROWSER_TEST_F(BrowserTest, AppIdSwitch) { | 1522 IN_PROC_BROWSER_TEST_F(BrowserTest, AppIdSwitch) { |
| 1519 ASSERT_TRUE(test_server()->Start()); | 1523 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1520 | 1524 |
| 1521 // There should be one tab to start with. | 1525 // There should be one tab to start with. |
| 1522 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1526 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| 1523 | 1527 |
| 1524 // Load an app. | 1528 // Load an app. |
| 1525 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1529 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1526 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1530 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 1527 const Extension* extension_app = GetExtension(); | 1531 const Extension* extension_app = GetExtension(); |
| 1528 | 1532 |
| 1529 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 1533 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1549 | 1553 |
| 1550 EXPECT_EQ(expected_browsers, | 1554 EXPECT_EQ(expected_browsers, |
| 1551 chrome::GetBrowserCount(browser()->profile(), | 1555 chrome::GetBrowserCount(browser()->profile(), |
| 1552 browser()->host_desktop_type())); | 1556 browser()->host_desktop_type())); |
| 1553 EXPECT_EQ(expected_tabs, browser()->tab_strip_model()->count()); | 1557 EXPECT_EQ(expected_tabs, browser()->tab_strip_model()->count()); |
| 1554 } | 1558 } |
| 1555 | 1559 |
| 1556 // Open an app window and the dev tools window and ensure that the location | 1560 // Open an app window and the dev tools window and ensure that the location |
| 1557 // bar settings are correct. | 1561 // bar settings are correct. |
| 1558 IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldShowLocationBar) { | 1562 IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldShowLocationBar) { |
| 1559 ASSERT_TRUE(test_server()->Start()); | 1563 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1560 | 1564 |
| 1561 // Load an app. | 1565 // Load an app. |
| 1562 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1566 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1563 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1567 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 1564 const Extension* extension_app = GetExtension(); | 1568 const Extension* extension_app = GetExtension(); |
| 1565 | 1569 |
| 1566 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. | 1570 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. |
| 1567 WebContents* app_window = OpenApplication(AppLaunchParams( | 1571 WebContents* app_window = OpenApplication(AppLaunchParams( |
| 1568 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, | 1572 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, |
| 1569 NEW_WINDOW, extensions::SOURCE_TEST)); | 1573 NEW_WINDOW, extensions::SOURCE_TEST)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1606 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
| 1603 | 1607 |
| 1604 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); | 1608 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); |
| 1605 } | 1609 } |
| 1606 | 1610 |
| 1607 // Tests that the CLD (Compact Language Detection) works properly. | 1611 // Tests that the CLD (Compact Language Detection) works properly. |
| 1608 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { | 1612 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { |
| 1609 scoped_ptr<test::CldDataHarness> cld_data_harness = | 1613 scoped_ptr<test::CldDataHarness> cld_data_harness = |
| 1610 test::CldDataHarnessFactory::Get()->CreateCldDataHarness(); | 1614 test::CldDataHarnessFactory::Get()->CreateCldDataHarness(); |
| 1611 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); | 1615 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); |
| 1612 ASSERT_TRUE(test_server()->Start()); | 1616 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1613 | 1617 |
| 1614 translate::LanguageDetectionDetails details; | 1618 translate::LanguageDetectionDetails details; |
| 1615 | 1619 |
| 1616 // Open a new tab with a page in English. | 1620 // Open a new tab with a page in English. |
| 1617 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), | 1621 AddTabAtIndex(0, GURL(embedded_test_server()->GetURL("/english_page.html")), |
| 1618 ui::PAGE_TRANSITION_TYPED); | 1622 ui::PAGE_TRANSITION_TYPED); |
| 1619 | 1623 |
| 1620 WebContents* current_web_contents = | 1624 WebContents* current_web_contents = |
| 1621 browser()->tab_strip_model()->GetActiveWebContents(); | 1625 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1622 ChromeTranslateClient* chrome_translate_client = | 1626 ChromeTranslateClient* chrome_translate_client = |
| 1623 ChromeTranslateClient::FromWebContents(current_web_contents); | 1627 ChromeTranslateClient::FromWebContents(current_web_contents); |
| 1624 content::Source<WebContents> source(current_web_contents); | 1628 content::Source<WebContents> source(current_web_contents); |
| 1625 | 1629 |
| 1626 ui_test_utils::WindowedNotificationObserverWithDetails< | 1630 ui_test_utils::WindowedNotificationObserverWithDetails< |
| 1627 translate::LanguageDetectionDetails> | 1631 translate::LanguageDetectionDetails> |
| 1628 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1632 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 1629 source); | 1633 source); |
| 1630 EXPECT_EQ("", | 1634 EXPECT_EQ("", |
| 1631 chrome_translate_client->GetLanguageState().original_language()); | 1635 chrome_translate_client->GetLanguageState().original_language()); |
| 1632 en_language_detected_signal.Wait(); | 1636 en_language_detected_signal.Wait(); |
| 1633 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( | 1637 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( |
| 1634 source.map_key(), &details)); | 1638 source.map_key(), &details)); |
| 1635 EXPECT_EQ("en", details.adopted_language); | 1639 EXPECT_EQ("en", details.adopted_language); |
| 1636 EXPECT_EQ("en", | 1640 EXPECT_EQ("en", |
| 1637 chrome_translate_client->GetLanguageState().original_language()); | 1641 chrome_translate_client->GetLanguageState().original_language()); |
| 1638 | 1642 |
| 1639 // Now navigate to a page in French. | 1643 // Now navigate to a page in French. |
| 1640 ui_test_utils::WindowedNotificationObserverWithDetails< | 1644 ui_test_utils::WindowedNotificationObserverWithDetails< |
| 1641 translate::LanguageDetectionDetails> | 1645 translate::LanguageDetectionDetails> |
| 1642 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1646 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 1643 source); | 1647 source); |
| 1644 ui_test_utils::NavigateToURL( | 1648 ui_test_utils::NavigateToURL( |
| 1645 browser(), GURL(test_server()->GetURL("files/french_page.html"))); | 1649 browser(), GURL(embedded_test_server()->GetURL("/french_page.html"))); |
| 1646 fr_language_detected_signal.Wait(); | 1650 fr_language_detected_signal.Wait(); |
| 1647 details.adopted_language.clear(); | 1651 details.adopted_language.clear(); |
| 1648 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( | 1652 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( |
| 1649 source.map_key(), &details)); | 1653 source.map_key(), &details)); |
| 1650 EXPECT_EQ("fr", details.adopted_language); | 1654 EXPECT_EQ("fr", details.adopted_language); |
| 1651 EXPECT_EQ("fr", | 1655 EXPECT_EQ("fr", |
| 1652 chrome_translate_client->GetLanguageState().original_language()); | 1656 chrome_translate_client->GetLanguageState().original_language()); |
| 1653 } | 1657 } |
| 1654 | 1658 |
| 1655 // Chromeos defaults to restoring the last session, so this test isn't | 1659 // Chromeos defaults to restoring the last session, so this test isn't |
| 1656 // applicable. | 1660 // applicable. |
| 1657 #if !defined(OS_CHROMEOS) | 1661 #if !defined(OS_CHROMEOS) |
| 1658 // Makes sure pinned tabs are restored correctly on start. | 1662 // Makes sure pinned tabs are restored correctly on start. |
| 1659 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { | 1663 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { |
| 1660 ASSERT_TRUE(test_server()->Start()); | 1664 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1661 | 1665 |
| 1662 // Add a pinned tab. | 1666 // Add a pinned tab. |
| 1663 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1667 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1664 GURL url(test_server()->GetURL("empty.html")); | 1668 GURL url(embedded_test_server()->GetURL("/empty.html")); |
| 1665 TabStripModel* model = browser()->tab_strip_model(); | 1669 TabStripModel* model = browser()->tab_strip_model(); |
| 1666 ui_test_utils::NavigateToURL(browser(), url); | 1670 ui_test_utils::NavigateToURL(browser(), url); |
| 1667 model->SetTabPinned(0, true); | 1671 model->SetTabPinned(0, true); |
| 1668 | 1672 |
| 1669 // Add a non pinned tab. | 1673 // Add a non pinned tab. |
| 1670 chrome::NewTab(browser()); | 1674 chrome::NewTab(browser()); |
| 1671 ui_test_utils::NavigateToURL(browser(), url); | 1675 ui_test_utils::NavigateToURL(browser(), url); |
| 1672 | 1676 |
| 1673 // Add another pinned tab. | 1677 // Add another pinned tab. |
| 1674 chrome::NewTab(browser()); | 1678 chrome::NewTab(browser()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 if (browser_defaults::kBrowserAliveWithNoWindows) | 1725 if (browser_defaults::kBrowserAliveWithNoWindows) |
| 1722 return; | 1726 return; |
| 1723 | 1727 |
| 1724 // We need a message loop running for menus on windows. | 1728 // We need a message loop running for menus on windows. |
| 1725 base::MessageLoop::current()->task_runner()->PostTask( | 1729 base::MessageLoop::current()->task_runner()->PostTask( |
| 1726 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); | 1730 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); |
| 1727 } | 1731 } |
| 1728 | 1732 |
| 1729 #if !defined(OS_MACOSX) | 1733 #if !defined(OS_MACOSX) |
| 1730 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { | 1734 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { |
| 1731 ASSERT_TRUE(test_server()->Start()); | 1735 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1732 | 1736 |
| 1733 // Load an app | 1737 // Load an app |
| 1734 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1738 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1735 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1739 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 1736 const Extension* extension_app = GetExtension(); | 1740 const Extension* extension_app = GetExtension(); |
| 1737 | 1741 |
| 1738 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. | 1742 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. |
| 1739 WebContents* app_window = OpenApplication(AppLaunchParams( | 1743 WebContents* app_window = OpenApplication(AppLaunchParams( |
| 1740 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, | 1744 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, |
| 1741 NEW_WINDOW, extensions::SOURCE_TEST)); | 1745 NEW_WINDOW, extensions::SOURCE_TEST)); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 sub.reset(); | 2053 sub.reset(); |
| 2050 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90); | 2054 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90); |
| 2051 EXPECT_TRUE(enable_plus); | 2055 EXPECT_TRUE(enable_plus); |
| 2052 EXPECT_TRUE(enable_minus); | 2056 EXPECT_TRUE(enable_minus); |
| 2053 } | 2057 } |
| 2054 | 2058 |
| 2055 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 2059 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
| 2056 } | 2060 } |
| 2057 | 2061 |
| 2058 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { | 2062 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { |
| 2059 ASSERT_TRUE(test_server()->Start()); | 2063 ASSERT_TRUE(embedded_test_server()->Start()); |
| 2060 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 2064 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 2061 GURL url(test_server()->GetURL("empty.html")); | 2065 GURL url(embedded_test_server()->GetURL("/empty.html")); |
| 2062 ui_test_utils::NavigateToURL(browser(), url); | 2066 ui_test_utils::NavigateToURL(browser(), url); |
| 2063 | 2067 |
| 2064 CommandUpdater* command_updater = | 2068 CommandUpdater* command_updater = |
| 2065 browser()->command_controller()->command_updater(); | 2069 browser()->command_controller()->command_updater(); |
| 2066 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); | 2070 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); |
| 2067 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); | 2071 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); |
| 2068 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 2072 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
| 2069 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 2073 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
| 2070 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); | 2074 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); |
| 2071 | 2075 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2092 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); | 2096 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); |
| 2093 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); | 2097 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); |
| 2094 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 2098 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
| 2095 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 2099 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
| 2096 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); | 2100 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); |
| 2097 } | 2101 } |
| 2098 | 2102 |
| 2099 // Ensure that creating an interstitial page closes any JavaScript dialogs | 2103 // Ensure that creating an interstitial page closes any JavaScript dialogs |
| 2100 // that were present on the previous page. See http://crbug.com/295695. | 2104 // that were present on the previous page. See http://crbug.com/295695. |
| 2101 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialClosesDialogs) { | 2105 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialClosesDialogs) { |
| 2102 ASSERT_TRUE(test_server()->Start()); | 2106 ASSERT_TRUE(embedded_test_server()->Start()); |
| 2103 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 2107 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 2104 GURL url(test_server()->GetURL("empty.html")); | 2108 GURL url(embedded_test_server()->GetURL("/empty.html")); |
| 2105 ui_test_utils::NavigateToURL(browser(), url); | 2109 ui_test_utils::NavigateToURL(browser(), url); |
| 2106 | 2110 |
| 2107 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2111 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2108 contents->GetMainFrame()->ExecuteJavaScriptForTests( | 2112 contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 2109 ASCIIToUTF16("alert('Dialog showing!');")); | 2113 ASCIIToUTF16("alert('Dialog showing!');")); |
| 2110 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 2114 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 2111 EXPECT_TRUE(alert->IsValid()); | 2115 EXPECT_TRUE(alert->IsValid()); |
| 2112 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 2116 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 2113 EXPECT_TRUE(dialog_queue->HasActiveDialog()); | 2117 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
| 2114 | 2118 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 }; | 2174 }; |
| 2171 | 2175 |
| 2172 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) { | 2176 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) { |
| 2173 // Regression test for http://crbug.com/110707. Also tests that a user | 2177 // Regression test for http://crbug.com/110707. Also tests that a user |
| 2174 // gesture is sent when a normal navigation (via e.g. the omnibox) is | 2178 // gesture is sent when a normal navigation (via e.g. the omnibox) is |
| 2175 // performed. | 2179 // performed. |
| 2176 WebContents* web_contents = | 2180 WebContents* web_contents = |
| 2177 browser()->tab_strip_model()->GetActiveWebContents(); | 2181 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2178 MockWebContentsObserver mock_observer(web_contents); | 2182 MockWebContentsObserver mock_observer(web_contents); |
| 2179 | 2183 |
| 2180 ASSERT_TRUE(test_server()->Start()); | 2184 ASSERT_TRUE(embedded_test_server()->Start()); |
| 2181 GURL url(test_server()->GetURL("empty.html")); | 2185 GURL url(embedded_test_server()->GetURL("/empty.html")); |
| 2182 | 2186 |
| 2183 ui_test_utils::NavigateToURL(browser(), url); | 2187 ui_test_utils::NavigateToURL(browser(), url); |
| 2184 EXPECT_TRUE(mock_observer.got_user_gesture()); | 2188 EXPECT_TRUE(mock_observer.got_user_gesture()); |
| 2185 | 2189 |
| 2186 mock_observer.set_got_user_gesture(false); | 2190 mock_observer.set_got_user_gesture(false); |
| 2187 chrome::Reload(browser(), CURRENT_TAB); | 2191 chrome::Reload(browser(), CURRENT_TAB); |
| 2188 EXPECT_TRUE(mock_observer.got_user_gesture()); | 2192 EXPECT_TRUE(mock_observer.got_user_gesture()); |
| 2189 } | 2193 } |
| 2190 | 2194 |
| 2191 // TODO(ben): this test was never enabled. It has bit-rotted since being added. | 2195 // TODO(ben): this test was never enabled. It has bit-rotted since being added. |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 if (base::mac::IsOSMountainLion() || base::mac::IsOSLion()) | 2783 if (base::mac::IsOSMountainLion() || base::mac::IsOSLion()) |
| 2780 return; | 2784 return; |
| 2781 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 2785 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 2782 // The instant extended NTP has javascript that does not work with | 2786 // The instant extended NTP has javascript that does not work with |
| 2783 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries | 2787 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries |
| 2784 // to navigate away from the page, which causes the WebContents to end up in | 2788 // to navigate away from the page, which causes the WebContents to end up in |
| 2785 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, | 2789 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, |
| 2786 // visible_url=title1.html) | 2790 // visible_url=title1.html) |
| 2787 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, | 2791 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, |
| 2788 false); | 2792 false); |
| 2789 ASSERT_TRUE(test_server()->Start()); | 2793 ASSERT_TRUE(embedded_test_server()->Start()); |
| 2790 // Create an HTTPS server for cross-site transition. | 2794 // Create an HTTPS server for cross-site transition. |
| 2791 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 2795 net::EmbeddedTestServer https_test_server( |
| 2792 net::SpawnedTestServer::kLocalhost, | 2796 net::EmbeddedTestServer::TYPE_HTTPS); |
| 2793 base::FilePath(kDocRoot)); | 2797 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 2794 ASSERT_TRUE(https_test_server.Start()); | 2798 ASSERT_TRUE(https_test_server.Start()); |
| 2795 | 2799 |
| 2796 // Start with NTP. | 2800 // Start with NTP. |
| 2797 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | 2801 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
| 2798 ASSERT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | 2802 ASSERT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); |
| 2799 WebContents* web_contents = | 2803 WebContents* web_contents = |
| 2800 browser()->tab_strip_model()->GetActiveWebContents(); | 2804 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2801 content::RenderViewHost* prev_rvh = web_contents->GetRenderViewHost(); | 2805 content::RenderViewHost* prev_rvh = web_contents->GetRenderViewHost(); |
| 2802 const int height_inset = | 2806 const int height_inset = |
| 2803 browser()->window()->GetRenderViewHeightInsetWithDetachedBookmarkBar(); | 2807 browser()->window()->GetRenderViewHeightInsetWithDetachedBookmarkBar(); |
| 2804 const gfx::Size initial_wcv_size = | 2808 const gfx::Size initial_wcv_size = |
| 2805 web_contents->GetContainerBounds().size(); | 2809 web_contents->GetContainerBounds().size(); |
| 2806 RenderViewSizeObserver observer(web_contents, browser()->window()); | 2810 RenderViewSizeObserver observer(web_contents, browser()->window()); |
| 2807 | 2811 |
| 2808 // Navigate to a non-NTP page, without resizing WebContentsView. | 2812 // Navigate to a non-NTP page, without resizing WebContentsView. |
| 2809 ui_test_utils::NavigateToURL(browser(), | 2813 ui_test_utils::NavigateToURL(browser(), |
| 2810 test_server()->GetURL("files/title1.html")); | 2814 embedded_test_server()->GetURL("/title1.html")); |
| 2811 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 2815 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 2812 // A new RenderViewHost should be created. | 2816 // A new RenderViewHost should be created. |
| 2813 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); | 2817 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); |
| 2814 prev_rvh = web_contents->GetRenderViewHost(); | 2818 prev_rvh = web_contents->GetRenderViewHost(); |
| 2815 gfx::Size rwhv_create_size0, rwhv_commit_size0, wcv_commit_size0; | 2819 gfx::Size rwhv_create_size0, rwhv_commit_size0, wcv_commit_size0; |
| 2816 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), | 2820 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), |
| 2817 &rwhv_create_size0, | 2821 &rwhv_create_size0, |
| 2818 &rwhv_commit_size0, | 2822 &rwhv_commit_size0, |
| 2819 &wcv_commit_size0); | 2823 &wcv_commit_size0); |
| 2820 // The create height of RenderWidgetHostView should include the height inset. | 2824 // The create height of RenderWidgetHostView should include the height inset. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2838 #if defined(OS_MACOSX) | 2842 #if defined(OS_MACOSX) |
| 2839 EXPECT_EQ(gfx::Size(wcv_commit_size0.width(), | 2843 EXPECT_EQ(gfx::Size(wcv_commit_size0.width(), |
| 2840 wcv_commit_size0.height() + height_inset), | 2844 wcv_commit_size0.height() + height_inset), |
| 2841 web_contents->GetContainerBounds().size()); | 2845 web_contents->GetContainerBounds().size()); |
| 2842 #else | 2846 #else |
| 2843 EXPECT_EQ(wcv_commit_size0, web_contents->GetContainerBounds().size()); | 2847 EXPECT_EQ(wcv_commit_size0, web_contents->GetContainerBounds().size()); |
| 2844 #endif | 2848 #endif |
| 2845 | 2849 |
| 2846 // Navigate to another non-NTP page, without resizing WebContentsView. | 2850 // Navigate to another non-NTP page, without resizing WebContentsView. |
| 2847 ui_test_utils::NavigateToURL(browser(), | 2851 ui_test_utils::NavigateToURL(browser(), |
| 2848 https_test_server.GetURL("files/title2.html")); | 2852 https_test_server.GetURL("/title2.html")); |
| 2849 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 2853 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 2850 // A new RenderVieHost should be created. | 2854 // A new RenderVieHost should be created. |
| 2851 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); | 2855 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); |
| 2852 gfx::Size rwhv_create_size1, rwhv_commit_size1, wcv_commit_size1; | 2856 gfx::Size rwhv_create_size1, rwhv_commit_size1, wcv_commit_size1; |
| 2853 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), | 2857 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), |
| 2854 &rwhv_create_size1, | 2858 &rwhv_create_size1, |
| 2855 &rwhv_commit_size1, | 2859 &rwhv_commit_size1, |
| 2856 &wcv_commit_size1); | 2860 &wcv_commit_size1); |
| 2857 EXPECT_EQ(rwhv_create_size1, rwhv_commit_size1); | 2861 EXPECT_EQ(rwhv_create_size1, rwhv_commit_size1); |
| 2858 EXPECT_EQ(rwhv_commit_size1, | 2862 EXPECT_EQ(rwhv_commit_size1, |
| 2859 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2863 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
| 2860 EXPECT_EQ(wcv_commit_size1, web_contents->GetContainerBounds().size()); | 2864 EXPECT_EQ(wcv_commit_size1, web_contents->GetContainerBounds().size()); |
| 2861 | 2865 |
| 2862 // Navigate from NTP to a non-NTP page, resizing WebContentsView while | 2866 // Navigate from NTP to a non-NTP page, resizing WebContentsView while |
| 2863 // navigation entry is pending. | 2867 // navigation entry is pending. |
| 2864 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | 2868 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
| 2865 gfx::Size wcv_resize_insets(1, 1); | 2869 gfx::Size wcv_resize_insets(1, 1); |
| 2866 observer.set_wcv_resize_insets(wcv_resize_insets); | 2870 observer.set_wcv_resize_insets(wcv_resize_insets); |
| 2867 ui_test_utils::NavigateToURL(browser(), | 2871 ui_test_utils::NavigateToURL(browser(), |
| 2868 test_server()->GetURL("files/title2.html")); | 2872 embedded_test_server()->GetURL("/title2.html")); |
| 2869 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 2873 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 2870 gfx::Size rwhv_create_size2, rwhv_commit_size2, wcv_commit_size2; | 2874 gfx::Size rwhv_create_size2, rwhv_commit_size2, wcv_commit_size2; |
| 2871 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), | 2875 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), |
| 2872 &rwhv_create_size2, | 2876 &rwhv_create_size2, |
| 2873 &rwhv_commit_size2, | 2877 &rwhv_commit_size2, |
| 2874 &wcv_commit_size2); | 2878 &wcv_commit_size2); |
| 2875 | 2879 |
| 2876 // The behavior on OSX and Views is incorrect in this edge case, but they are | 2880 // The behavior on OSX and Views is incorrect in this edge case, but they are |
| 2877 // differently incorrect. | 2881 // differently incorrect. |
| 2878 // The behavior should be: | 2882 // The behavior should be: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2947 // interstitial is deleted now. | 2951 // interstitial is deleted now. |
| 2948 | 2952 |
| 2949 EXPECT_TRUE(chrome::CanDuplicateTab(browser())); | 2953 EXPECT_TRUE(chrome::CanDuplicateTab(browser())); |
| 2950 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 0)); | 2954 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 0)); |
| 2951 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 1)); | 2955 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 1)); |
| 2952 } | 2956 } |
| 2953 | 2957 |
| 2954 // Tests that the WebContentsObserver::SecurityStyleChanged event fires | 2958 // Tests that the WebContentsObserver::SecurityStyleChanged event fires |
| 2955 // with the current style on HTTP, broken HTTPS, and valid HTTPS pages. | 2959 // with the current style on HTTP, broken HTTPS, and valid HTTPS pages. |
| 2956 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) { | 2960 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) { |
| 2957 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 2961 net::EmbeddedTestServer https_test_server( |
| 2958 net::SpawnedTestServer::kLocalhost, | 2962 net::EmbeddedTestServer::TYPE_HTTPS); |
| 2959 base::FilePath(kDocRoot)); | 2963 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 2960 net::SpawnedTestServer https_test_server_expired( | 2964 ASSERT_TRUE(https_test_server.Start()); |
| 2961 net::SpawnedTestServer::TYPE_HTTPS, | 2965 |
| 2962 net::SpawnedTestServer::SSLOptions( | 2966 net::EmbeddedTestServer https_test_server_expired( |
| 2963 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | 2967 net::EmbeddedTestServer::TYPE_HTTPS); |
| 2968 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 2969 https_test_server_expired.ServeFilesFromSourceDirectory( |
| 2964 base::FilePath(kDocRoot)); | 2970 base::FilePath(kDocRoot)); |
| 2965 | |
| 2966 ASSERT_TRUE(https_test_server.Start()); | |
| 2967 ASSERT_TRUE(https_test_server_expired.Start()); | 2971 ASSERT_TRUE(https_test_server_expired.Start()); |
| 2968 ASSERT_TRUE(test_server()->Start()); | 2972 ASSERT_TRUE(embedded_test_server()->Start()); |
| 2969 | 2973 |
| 2970 content::WebContents* web_contents = | 2974 content::WebContents* web_contents = |
| 2971 browser()->tab_strip_model()->GetActiveWebContents(); | 2975 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2972 SecurityStyleTestObserver observer(web_contents); | 2976 SecurityStyleTestObserver observer(web_contents); |
| 2973 | 2977 |
| 2974 // Visit an HTTP url. | 2978 // Visit an HTTP url. |
| 2975 GURL http_url(test_server()->GetURL(std::string())); | 2979 GURL http_url(embedded_test_server()->GetURL("/")); |
| 2976 ui_test_utils::NavigateToURL(browser(), http_url); | 2980 ui_test_utils::NavigateToURL(browser(), http_url); |
| 2977 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2981 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 2978 observer.latest_security_style()); | 2982 observer.latest_security_style()); |
| 2979 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 2983 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); |
| 2980 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 2984 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 2981 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); | 2985 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); |
| 2982 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); | 2986 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); |
| 2983 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 2987 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 2984 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 2988 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 2985 | 2989 |
| 2986 // Visit an (otherwise valid) HTTPS page that displays mixed content. | 2990 // Visit an (otherwise valid) HTTPS page that displays mixed content. |
| 2987 std::string replacement_path; | 2991 std::string replacement_path; |
| 2988 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 2992 GetFilePathWithHostAndPortReplacement( |
| 2989 "files/ssl/page_displays_insecure_content.html", | 2993 "/ssl/page_displays_insecure_content.html", |
| 2990 test_server()->host_port_pair(), &replacement_path)); | 2994 embedded_test_server()->host_port_pair(), &replacement_path); |
| 2991 | 2995 |
| 2992 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); | 2996 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); |
| 2993 ui_test_utils::NavigateToURL(browser(), mixed_content_url); | 2997 ui_test_utils::NavigateToURL(browser(), mixed_content_url); |
| 2994 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2998 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 2995 observer.latest_security_style()); | 2999 observer.latest_security_style()); |
| 2996 | 3000 |
| 2997 const content::SecurityStyleExplanations& mixed_content_explanation = | 3001 const content::SecurityStyleExplanations& mixed_content_explanation = |
| 2998 observer.latest_explanations(); | 3002 observer.latest_explanations(); |
| 2999 ASSERT_EQ(0u, mixed_content_explanation.warning_explanations.size()); | 3003 ASSERT_EQ(0u, mixed_content_explanation.warning_explanations.size()); |
| 3000 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size()); | 3004 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size()); |
| 3001 CheckSecureExplanations(mixed_content_explanation.secure_explanations, | 3005 CheckSecureExplanations(mixed_content_explanation.secure_explanations, |
| 3002 VALID_CERTIFICATE, browser()); | 3006 VALID_CERTIFICATE, browser()); |
| 3003 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic); | 3007 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic); |
| 3004 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); | 3008 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); |
| 3005 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); | 3009 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); |
| 3006 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 3010 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 3007 mixed_content_explanation.displayed_insecure_content_style); | 3011 mixed_content_explanation.displayed_insecure_content_style); |
| 3008 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 3012 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
| 3009 mixed_content_explanation.ran_insecure_content_style); | 3013 mixed_content_explanation.ran_insecure_content_style); |
| 3010 | 3014 |
| 3011 // Visit a broken HTTPS url. | 3015 // Visit a broken HTTPS url. |
| 3012 GURL expired_url(https_test_server_expired.GetURL(std::string())); | 3016 GURL expired_url(https_test_server_expired.GetURL(std::string("/"))); |
| 3013 ui_test_utils::NavigateToURL(browser(), expired_url); | 3017 ui_test_utils::NavigateToURL(browser(), expired_url); |
| 3014 | 3018 |
| 3015 // An interstitial should show, and an event for the lock icon on the | 3019 // An interstitial should show, and an event for the lock icon on the |
| 3016 // interstitial should fire. | 3020 // interstitial should fire. |
| 3017 content::WaitForInterstitialAttach(web_contents); | 3021 content::WaitForInterstitialAttach(web_contents); |
| 3018 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); | 3022 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); |
| 3019 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser()); | 3023 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser()); |
| 3020 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3024 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3021 INVALID_CERTIFICATE, browser()); | 3025 INVALID_CERTIFICATE, browser()); |
| 3022 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3026 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3023 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3027 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3024 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3028 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3025 | 3029 |
| 3026 // Before clicking through, navigate to a different page, and then go | 3030 // Before clicking through, navigate to a different page, and then go |
| 3027 // back to the interstitial. | 3031 // back to the interstitial. |
| 3028 GURL valid_https_url(https_test_server.GetURL(std::string())); | 3032 GURL valid_https_url(https_test_server.GetURL(std::string("/"))); |
| 3029 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 3033 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
| 3030 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 3034 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
| 3031 observer.latest_security_style()); | 3035 observer.latest_security_style()); |
| 3032 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 3036 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); |
| 3033 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3037 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 3034 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3038 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3035 VALID_CERTIFICATE, browser()); | 3039 VALID_CERTIFICATE, browser()); |
| 3036 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3040 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3037 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3041 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3038 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3042 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3062 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3066 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3063 INVALID_CERTIFICATE, browser()); | 3067 INVALID_CERTIFICATE, browser()); |
| 3064 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3068 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3065 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3069 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3066 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3070 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3067 } | 3071 } |
| 3068 | 3072 |
| 3069 // Visit a valid HTTPS page, then a broken HTTPS page, and then go back, | 3073 // Visit a valid HTTPS page, then a broken HTTPS page, and then go back, |
| 3070 // and test that the observed security style matches. | 3074 // and test that the observed security style matches. |
| 3071 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserverGoBack) { | 3075 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserverGoBack) { |
| 3072 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 3076 net::EmbeddedTestServer https_test_server( |
| 3073 net::SpawnedTestServer::kLocalhost, | 3077 net::EmbeddedTestServer::TYPE_HTTPS); |
| 3074 base::FilePath(kDocRoot)); | 3078 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 3079 ASSERT_TRUE(https_test_server.Start()); |
| 3075 | 3080 |
| 3076 // Use a separate server to work around a mysterious SSL handshake | 3081 net::EmbeddedTestServer https_test_server_expired( |
| 3077 // timeout when both requests go to the same server. See | 3082 net::EmbeddedTestServer::TYPE_HTTPS); |
| 3078 // https://crbug.com/515906. | 3083 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 3079 net::SpawnedTestServer https_test_server_expired( | 3084 https_test_server_expired.ServeFilesFromSourceDirectory( |
| 3080 net::SpawnedTestServer::TYPE_HTTPS, | |
| 3081 net::SpawnedTestServer::SSLOptions( | |
| 3082 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | |
| 3083 base::FilePath(kDocRoot)); | 3085 base::FilePath(kDocRoot)); |
| 3084 | |
| 3085 ASSERT_TRUE(https_test_server.Start()); | |
| 3086 ASSERT_TRUE(https_test_server_expired.Start()); | 3086 ASSERT_TRUE(https_test_server_expired.Start()); |
| 3087 | 3087 |
| 3088 content::WebContents* web_contents = | 3088 content::WebContents* web_contents = |
| 3089 browser()->tab_strip_model()->GetActiveWebContents(); | 3089 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3090 SecurityStyleTestObserver observer(web_contents); | 3090 SecurityStyleTestObserver observer(web_contents); |
| 3091 | 3091 |
| 3092 // Visit a valid HTTPS url. | 3092 // Visit a valid HTTPS url. |
| 3093 GURL valid_https_url(https_test_server.GetURL(std::string())); | 3093 GURL valid_https_url(https_test_server.GetURL(std::string("/"))); |
| 3094 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 3094 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
| 3095 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 3095 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
| 3096 observer.latest_security_style()); | 3096 observer.latest_security_style()); |
| 3097 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 3097 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); |
| 3098 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3098 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 3099 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3099 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 3100 VALID_CERTIFICATE, browser()); | 3100 VALID_CERTIFICATE, browser()); |
| 3101 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3101 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 3102 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3102 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 3103 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3103 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 3104 | 3104 |
| 3105 // Navigate to a bad HTTPS page on a different host, and then click | 3105 // Navigate to a bad HTTPS page on a different host, and then click |
| 3106 // Back to verify that the previous good security style is seen again. | 3106 // Back to verify that the previous good security style is seen again. |
| 3107 GURL expired_https_url(https_test_server_expired.GetURL(std::string())); | 3107 GURL expired_https_url(https_test_server_expired.GetURL(std::string("/"))); |
| 3108 host_resolver()->AddRule("www.example_broken.test", "127.0.0.1"); | 3108 host_resolver()->AddRule("www.example_broken.test", "127.0.0.1"); |
| 3109 GURL::Replacements replace_host; | 3109 GURL::Replacements replace_host; |
| 3110 replace_host.SetHostStr("www.example_broken.test"); | 3110 replace_host.SetHostStr("www.example_broken.test"); |
| 3111 GURL https_url_different_host = | 3111 GURL https_url_different_host = |
| 3112 expired_https_url.ReplaceComponents(replace_host); | 3112 expired_https_url.ReplaceComponents(replace_host); |
| 3113 | 3113 |
| 3114 ui_test_utils::NavigateToURL(browser(), https_url_different_host); | 3114 ui_test_utils::NavigateToURL(browser(), https_url_different_host); |
| 3115 | 3115 |
| 3116 content::WaitForInterstitialAttach(web_contents); | 3116 content::WaitForInterstitialAttach(web_contents); |
| 3117 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); | 3117 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3258 false); | 3258 false); |
| 3259 | 3259 |
| 3260 // Sync navigation just to make sure IPC has passed (updated | 3260 // Sync navigation just to make sure IPC has passed (updated |
| 3261 // display mode is delivered to RP). | 3261 // display mode is delivered to RP). |
| 3262 content::TestNavigationObserver observer(app_contents, 1); | 3262 content::TestNavigationObserver observer(app_contents, 1); |
| 3263 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); | 3263 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); |
| 3264 observer.Wait(); | 3264 observer.Wait(); |
| 3265 | 3265 |
| 3266 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); | 3266 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); |
| 3267 } | 3267 } |
| OLD | NEW |