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 // Chromeos defaults to restoring the last session, so this test isn't | 1611 // Chromeos defaults to restoring the last session, so this test isn't |
1608 // applicable. | 1612 // applicable. |
1609 #if !defined(OS_CHROMEOS) | 1613 #if !defined(OS_CHROMEOS) |
1610 // Makes sure pinned tabs are restored correctly on start. | 1614 // Makes sure pinned tabs are restored correctly on start. |
1611 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { | 1615 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { |
1612 ASSERT_TRUE(test_server()->Start()); | 1616 ASSERT_TRUE(embedded_test_server()->Start()); |
1613 | 1617 |
1614 // Add a pinned tab. | 1618 // Add a pinned tab. |
1615 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1619 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
1616 GURL url(test_server()->GetURL("empty.html")); | 1620 GURL url(embedded_test_server()->GetURL("/empty.html")); |
1617 TabStripModel* model = browser()->tab_strip_model(); | 1621 TabStripModel* model = browser()->tab_strip_model(); |
1618 ui_test_utils::NavigateToURL(browser(), url); | 1622 ui_test_utils::NavigateToURL(browser(), url); |
1619 model->SetTabPinned(0, true); | 1623 model->SetTabPinned(0, true); |
1620 | 1624 |
1621 // Add a non pinned tab. | 1625 // Add a non pinned tab. |
1622 chrome::NewTab(browser()); | 1626 chrome::NewTab(browser()); |
1623 ui_test_utils::NavigateToURL(browser(), url); | 1627 ui_test_utils::NavigateToURL(browser(), url); |
1624 | 1628 |
1625 // Add another pinned tab. | 1629 // Add another pinned tab. |
1626 chrome::NewTab(browser()); | 1630 chrome::NewTab(browser()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 if (browser_defaults::kBrowserAliveWithNoWindows) | 1677 if (browser_defaults::kBrowserAliveWithNoWindows) |
1674 return; | 1678 return; |
1675 | 1679 |
1676 // We need a message loop running for menus on windows. | 1680 // We need a message loop running for menus on windows. |
1677 base::MessageLoop::current()->task_runner()->PostTask( | 1681 base::MessageLoop::current()->task_runner()->PostTask( |
1678 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); | 1682 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); |
1679 } | 1683 } |
1680 | 1684 |
1681 #if !defined(OS_MACOSX) | 1685 #if !defined(OS_MACOSX) |
1682 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { | 1686 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { |
1683 ASSERT_TRUE(test_server()->Start()); | 1687 ASSERT_TRUE(embedded_test_server()->Start()); |
1684 | 1688 |
1685 // Load an app | 1689 // Load an app |
1686 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1690 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
1687 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1691 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
1688 const Extension* extension_app = GetExtension(); | 1692 const Extension* extension_app = GetExtension(); |
1689 | 1693 |
1690 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. | 1694 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. |
1691 WebContents* app_window = OpenApplication(AppLaunchParams( | 1695 WebContents* app_window = OpenApplication(AppLaunchParams( |
1692 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, | 1696 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, |
1693 NEW_WINDOW, extensions::SOURCE_TEST)); | 1697 NEW_WINDOW, extensions::SOURCE_TEST)); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2001 sub.reset(); | 2005 sub.reset(); |
2002 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90); | 2006 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90); |
2003 EXPECT_TRUE(enable_plus); | 2007 EXPECT_TRUE(enable_plus); |
2004 EXPECT_TRUE(enable_minus); | 2008 EXPECT_TRUE(enable_minus); |
2005 } | 2009 } |
2006 | 2010 |
2007 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 2011 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
2008 } | 2012 } |
2009 | 2013 |
2010 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { | 2014 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { |
2011 ASSERT_TRUE(test_server()->Start()); | 2015 ASSERT_TRUE(embedded_test_server()->Start()); |
2012 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 2016 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
2013 GURL url(test_server()->GetURL("empty.html")); | 2017 GURL url(embedded_test_server()->GetURL("/empty.html")); |
2014 ui_test_utils::NavigateToURL(browser(), url); | 2018 ui_test_utils::NavigateToURL(browser(), url); |
2015 | 2019 |
2016 CommandUpdater* command_updater = | 2020 CommandUpdater* command_updater = |
2017 browser()->command_controller()->command_updater(); | 2021 browser()->command_controller()->command_updater(); |
2018 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); | 2022 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); |
2019 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); | 2023 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); |
2020 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 2024 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
2021 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 2025 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
2022 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); | 2026 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); |
2023 | 2027 |
(...skipping 20 matching lines...) Expand all Loading... |
2044 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); | 2048 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); |
2045 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); | 2049 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); |
2046 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 2050 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
2047 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 2051 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
2048 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); | 2052 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_DUPLICATE_TAB)); |
2049 } | 2053 } |
2050 | 2054 |
2051 // Ensure that creating an interstitial page closes any JavaScript dialogs | 2055 // Ensure that creating an interstitial page closes any JavaScript dialogs |
2052 // that were present on the previous page. See http://crbug.com/295695. | 2056 // that were present on the previous page. See http://crbug.com/295695. |
2053 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialClosesDialogs) { | 2057 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialClosesDialogs) { |
2054 ASSERT_TRUE(test_server()->Start()); | 2058 ASSERT_TRUE(embedded_test_server()->Start()); |
2055 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 2059 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
2056 GURL url(test_server()->GetURL("empty.html")); | 2060 GURL url(embedded_test_server()->GetURL("/empty.html")); |
2057 ui_test_utils::NavigateToURL(browser(), url); | 2061 ui_test_utils::NavigateToURL(browser(), url); |
2058 | 2062 |
2059 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2063 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
2060 contents->GetMainFrame()->ExecuteJavaScriptForTests( | 2064 contents->GetMainFrame()->ExecuteJavaScriptForTests( |
2061 ASCIIToUTF16("alert('Dialog showing!');")); | 2065 ASCIIToUTF16("alert('Dialog showing!');")); |
2062 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 2066 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
2063 EXPECT_TRUE(alert->IsValid()); | 2067 EXPECT_TRUE(alert->IsValid()); |
2064 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 2068 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
2065 EXPECT_TRUE(dialog_queue->HasActiveDialog()); | 2069 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
2066 | 2070 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 }; | 2126 }; |
2123 | 2127 |
2124 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) { | 2128 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) { |
2125 // Regression test for http://crbug.com/110707. Also tests that a user | 2129 // Regression test for http://crbug.com/110707. Also tests that a user |
2126 // gesture is sent when a normal navigation (via e.g. the omnibox) is | 2130 // gesture is sent when a normal navigation (via e.g. the omnibox) is |
2127 // performed. | 2131 // performed. |
2128 WebContents* web_contents = | 2132 WebContents* web_contents = |
2129 browser()->tab_strip_model()->GetActiveWebContents(); | 2133 browser()->tab_strip_model()->GetActiveWebContents(); |
2130 MockWebContentsObserver mock_observer(web_contents); | 2134 MockWebContentsObserver mock_observer(web_contents); |
2131 | 2135 |
2132 ASSERT_TRUE(test_server()->Start()); | 2136 ASSERT_TRUE(embedded_test_server()->Start()); |
2133 GURL url(test_server()->GetURL("empty.html")); | 2137 GURL url(embedded_test_server()->GetURL("/empty.html")); |
2134 | 2138 |
2135 ui_test_utils::NavigateToURL(browser(), url); | 2139 ui_test_utils::NavigateToURL(browser(), url); |
2136 EXPECT_TRUE(mock_observer.got_user_gesture()); | 2140 EXPECT_TRUE(mock_observer.got_user_gesture()); |
2137 | 2141 |
2138 mock_observer.set_got_user_gesture(false); | 2142 mock_observer.set_got_user_gesture(false); |
2139 chrome::Reload(browser(), CURRENT_TAB); | 2143 chrome::Reload(browser(), CURRENT_TAB); |
2140 EXPECT_TRUE(mock_observer.got_user_gesture()); | 2144 EXPECT_TRUE(mock_observer.got_user_gesture()); |
2141 } | 2145 } |
2142 | 2146 |
2143 // TODO(ben): this test was never enabled. It has bit-rotted since being added. | 2147 // 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... |
2731 if (base::mac::IsOSMountainLion() || base::mac::IsOSLion()) | 2735 if (base::mac::IsOSMountainLion() || base::mac::IsOSLion()) |
2732 return; | 2736 return; |
2733 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 2737 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
2734 // The instant extended NTP has javascript that does not work with | 2738 // The instant extended NTP has javascript that does not work with |
2735 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries | 2739 // ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries |
2736 // to navigate away from the page, which causes the WebContents to end up in | 2740 // to navigate away from the page, which causes the WebContents to end up in |
2737 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, | 2741 // an inconsistent state. (is_loaded = true, last_commited_url=ntp, |
2738 // visible_url=title1.html) | 2742 // visible_url=title1.html) |
2739 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, | 2743 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, |
2740 false); | 2744 false); |
2741 ASSERT_TRUE(test_server()->Start()); | 2745 ASSERT_TRUE(embedded_test_server()->Start()); |
2742 // Create an HTTPS server for cross-site transition. | 2746 // Create an HTTPS server for cross-site transition. |
2743 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 2747 net::EmbeddedTestServer https_test_server( |
2744 net::SpawnedTestServer::kLocalhost, | 2748 net::EmbeddedTestServer::TYPE_HTTPS); |
2745 base::FilePath(kDocRoot)); | 2749 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
2746 ASSERT_TRUE(https_test_server.Start()); | 2750 ASSERT_TRUE(https_test_server.Start()); |
2747 | 2751 |
2748 // Start with NTP. | 2752 // Start with NTP. |
2749 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | 2753 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
2750 ASSERT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | 2754 ASSERT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); |
2751 WebContents* web_contents = | 2755 WebContents* web_contents = |
2752 browser()->tab_strip_model()->GetActiveWebContents(); | 2756 browser()->tab_strip_model()->GetActiveWebContents(); |
2753 content::RenderViewHost* prev_rvh = web_contents->GetRenderViewHost(); | 2757 content::RenderViewHost* prev_rvh = web_contents->GetRenderViewHost(); |
2754 const int height_inset = | 2758 const int height_inset = |
2755 browser()->window()->GetRenderViewHeightInsetWithDetachedBookmarkBar(); | 2759 browser()->window()->GetRenderViewHeightInsetWithDetachedBookmarkBar(); |
2756 const gfx::Size initial_wcv_size = | 2760 const gfx::Size initial_wcv_size = |
2757 web_contents->GetContainerBounds().size(); | 2761 web_contents->GetContainerBounds().size(); |
2758 RenderViewSizeObserver observer(web_contents, browser()->window()); | 2762 RenderViewSizeObserver observer(web_contents, browser()->window()); |
2759 | 2763 |
2760 // Navigate to a non-NTP page, without resizing WebContentsView. | 2764 // Navigate to a non-NTP page, without resizing WebContentsView. |
2761 ui_test_utils::NavigateToURL(browser(), | 2765 ui_test_utils::NavigateToURL(browser(), |
2762 test_server()->GetURL("files/title1.html")); | 2766 embedded_test_server()->GetURL("/title1.html")); |
2763 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 2767 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
2764 // A new RenderViewHost should be created. | 2768 // A new RenderViewHost should be created. |
2765 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); | 2769 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); |
2766 prev_rvh = web_contents->GetRenderViewHost(); | 2770 prev_rvh = web_contents->GetRenderViewHost(); |
2767 gfx::Size rwhv_create_size0, rwhv_commit_size0, wcv_commit_size0; | 2771 gfx::Size rwhv_create_size0, rwhv_commit_size0, wcv_commit_size0; |
2768 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), | 2772 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), |
2769 &rwhv_create_size0, | 2773 &rwhv_create_size0, |
2770 &rwhv_commit_size0, | 2774 &rwhv_commit_size0, |
2771 &wcv_commit_size0); | 2775 &wcv_commit_size0); |
2772 // The create height of RenderWidgetHostView should include the height inset. | 2776 // The create height of RenderWidgetHostView should include the height inset. |
(...skipping 17 matching lines...) Expand all Loading... |
2790 #if defined(OS_MACOSX) | 2794 #if defined(OS_MACOSX) |
2791 EXPECT_EQ(gfx::Size(wcv_commit_size0.width(), | 2795 EXPECT_EQ(gfx::Size(wcv_commit_size0.width(), |
2792 wcv_commit_size0.height() + height_inset), | 2796 wcv_commit_size0.height() + height_inset), |
2793 web_contents->GetContainerBounds().size()); | 2797 web_contents->GetContainerBounds().size()); |
2794 #else | 2798 #else |
2795 EXPECT_EQ(wcv_commit_size0, web_contents->GetContainerBounds().size()); | 2799 EXPECT_EQ(wcv_commit_size0, web_contents->GetContainerBounds().size()); |
2796 #endif | 2800 #endif |
2797 | 2801 |
2798 // Navigate to another non-NTP page, without resizing WebContentsView. | 2802 // Navigate to another non-NTP page, without resizing WebContentsView. |
2799 ui_test_utils::NavigateToURL(browser(), | 2803 ui_test_utils::NavigateToURL(browser(), |
2800 https_test_server.GetURL("files/title2.html")); | 2804 https_test_server.GetURL("/title2.html")); |
2801 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 2805 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
2802 // A new RenderVieHost should be created. | 2806 // A new RenderVieHost should be created. |
2803 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); | 2807 EXPECT_NE(prev_rvh, web_contents->GetRenderViewHost()); |
2804 gfx::Size rwhv_create_size1, rwhv_commit_size1, wcv_commit_size1; | 2808 gfx::Size rwhv_create_size1, rwhv_commit_size1, wcv_commit_size1; |
2805 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), | 2809 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), |
2806 &rwhv_create_size1, | 2810 &rwhv_create_size1, |
2807 &rwhv_commit_size1, | 2811 &rwhv_commit_size1, |
2808 &wcv_commit_size1); | 2812 &wcv_commit_size1); |
2809 EXPECT_EQ(rwhv_create_size1, rwhv_commit_size1); | 2813 EXPECT_EQ(rwhv_create_size1, rwhv_commit_size1); |
2810 EXPECT_EQ(rwhv_commit_size1, | 2814 EXPECT_EQ(rwhv_commit_size1, |
2811 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2815 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
2812 EXPECT_EQ(wcv_commit_size1, web_contents->GetContainerBounds().size()); | 2816 EXPECT_EQ(wcv_commit_size1, web_contents->GetContainerBounds().size()); |
2813 | 2817 |
2814 // Navigate from NTP to a non-NTP page, resizing WebContentsView while | 2818 // Navigate from NTP to a non-NTP page, resizing WebContentsView while |
2815 // navigation entry is pending. | 2819 // navigation entry is pending. |
2816 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | 2820 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
2817 gfx::Size wcv_resize_insets(1, 1); | 2821 gfx::Size wcv_resize_insets(1, 1); |
2818 observer.set_wcv_resize_insets(wcv_resize_insets); | 2822 observer.set_wcv_resize_insets(wcv_resize_insets); |
2819 ui_test_utils::NavigateToURL(browser(), | 2823 ui_test_utils::NavigateToURL(browser(), |
2820 test_server()->GetURL("files/title2.html")); | 2824 embedded_test_server()->GetURL("/title2.html")); |
2821 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 2825 ASSERT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
2822 gfx::Size rwhv_create_size2, rwhv_commit_size2, wcv_commit_size2; | 2826 gfx::Size rwhv_create_size2, rwhv_commit_size2, wcv_commit_size2; |
2823 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), | 2827 observer.GetSizeForRenderViewHost(web_contents->GetRenderViewHost(), |
2824 &rwhv_create_size2, | 2828 &rwhv_create_size2, |
2825 &rwhv_commit_size2, | 2829 &rwhv_commit_size2, |
2826 &wcv_commit_size2); | 2830 &wcv_commit_size2); |
2827 | 2831 |
2828 // The behavior on OSX and Views is incorrect in this edge case, but they are | 2832 // The behavior on OSX and Views is incorrect in this edge case, but they are |
2829 // differently incorrect. | 2833 // differently incorrect. |
2830 // The behavior should be: | 2834 // The behavior should be: |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2899 // interstitial is deleted now. | 2903 // interstitial is deleted now. |
2900 | 2904 |
2901 EXPECT_TRUE(chrome::CanDuplicateTab(browser())); | 2905 EXPECT_TRUE(chrome::CanDuplicateTab(browser())); |
2902 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 0)); | 2906 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 0)); |
2903 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 1)); | 2907 EXPECT_TRUE(chrome::CanDuplicateTabAt(browser(), 1)); |
2904 } | 2908 } |
2905 | 2909 |
2906 // Tests that the WebContentsObserver::SecurityStyleChanged event fires | 2910 // Tests that the WebContentsObserver::SecurityStyleChanged event fires |
2907 // with the current style on HTTP, broken HTTPS, and valid HTTPS pages. | 2911 // with the current style on HTTP, broken HTTPS, and valid HTTPS pages. |
2908 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) { | 2912 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) { |
2909 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 2913 net::EmbeddedTestServer https_test_server( |
2910 net::SpawnedTestServer::kLocalhost, | 2914 net::EmbeddedTestServer::TYPE_HTTPS); |
2911 base::FilePath(kDocRoot)); | 2915 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
2912 net::SpawnedTestServer https_test_server_expired( | 2916 ASSERT_TRUE(https_test_server.Start()); |
2913 net::SpawnedTestServer::TYPE_HTTPS, | 2917 |
2914 net::SpawnedTestServer::SSLOptions( | 2918 net::EmbeddedTestServer https_test_server_expired( |
2915 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | 2919 net::EmbeddedTestServer::TYPE_HTTPS); |
| 2920 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 2921 https_test_server_expired.ServeFilesFromSourceDirectory( |
2916 base::FilePath(kDocRoot)); | 2922 base::FilePath(kDocRoot)); |
2917 | |
2918 ASSERT_TRUE(https_test_server.Start()); | |
2919 ASSERT_TRUE(https_test_server_expired.Start()); | 2923 ASSERT_TRUE(https_test_server_expired.Start()); |
2920 ASSERT_TRUE(test_server()->Start()); | 2924 ASSERT_TRUE(embedded_test_server()->Start()); |
2921 | 2925 |
2922 content::WebContents* web_contents = | 2926 content::WebContents* web_contents = |
2923 browser()->tab_strip_model()->GetActiveWebContents(); | 2927 browser()->tab_strip_model()->GetActiveWebContents(); |
2924 SecurityStyleTestObserver observer(web_contents); | 2928 SecurityStyleTestObserver observer(web_contents); |
2925 | 2929 |
2926 // Visit an HTTP url. | 2930 // Visit an HTTP url. |
2927 GURL http_url(test_server()->GetURL(std::string())); | 2931 GURL http_url(embedded_test_server()->GetURL("/")); |
2928 ui_test_utils::NavigateToURL(browser(), http_url); | 2932 ui_test_utils::NavigateToURL(browser(), http_url); |
2929 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2933 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
2930 observer.latest_security_style()); | 2934 observer.latest_security_style()); |
2931 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 2935 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); |
2932 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 2936 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
2933 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); | 2937 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); |
2934 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); | 2938 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); |
2935 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 2939 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
2936 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 2940 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
2937 | 2941 |
2938 // Visit an (otherwise valid) HTTPS page that displays mixed content. | 2942 // Visit an (otherwise valid) HTTPS page that displays mixed content. |
2939 std::string replacement_path; | 2943 std::string replacement_path; |
2940 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 2944 GetFilePathWithHostAndPortReplacement( |
2941 "files/ssl/page_displays_insecure_content.html", | 2945 "/ssl/page_displays_insecure_content.html", |
2942 test_server()->host_port_pair(), &replacement_path)); | 2946 embedded_test_server()->host_port_pair(), &replacement_path); |
2943 | 2947 |
2944 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); | 2948 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); |
2945 ui_test_utils::NavigateToURL(browser(), mixed_content_url); | 2949 ui_test_utils::NavigateToURL(browser(), mixed_content_url); |
2946 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2950 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
2947 observer.latest_security_style()); | 2951 observer.latest_security_style()); |
2948 | 2952 |
2949 const content::SecurityStyleExplanations& mixed_content_explanation = | 2953 const content::SecurityStyleExplanations& mixed_content_explanation = |
2950 observer.latest_explanations(); | 2954 observer.latest_explanations(); |
2951 ASSERT_EQ(0u, mixed_content_explanation.warning_explanations.size()); | 2955 ASSERT_EQ(0u, mixed_content_explanation.warning_explanations.size()); |
2952 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size()); | 2956 ASSERT_EQ(0u, mixed_content_explanation.broken_explanations.size()); |
2953 CheckSecureExplanations(mixed_content_explanation.secure_explanations, | 2957 CheckSecureExplanations(mixed_content_explanation.secure_explanations, |
2954 VALID_CERTIFICATE, browser()); | 2958 VALID_CERTIFICATE, browser()); |
2955 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic); | 2959 EXPECT_TRUE(mixed_content_explanation.scheme_is_cryptographic); |
2956 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); | 2960 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); |
2957 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); | 2961 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); |
2958 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 2962 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
2959 mixed_content_explanation.displayed_insecure_content_style); | 2963 mixed_content_explanation.displayed_insecure_content_style); |
2960 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 2964 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
2961 mixed_content_explanation.ran_insecure_content_style); | 2965 mixed_content_explanation.ran_insecure_content_style); |
2962 | 2966 |
2963 // Visit a broken HTTPS url. | 2967 // Visit a broken HTTPS url. |
2964 GURL expired_url(https_test_server_expired.GetURL(std::string())); | 2968 GURL expired_url(https_test_server_expired.GetURL(std::string("/"))); |
2965 ui_test_utils::NavigateToURL(browser(), expired_url); | 2969 ui_test_utils::NavigateToURL(browser(), expired_url); |
2966 | 2970 |
2967 // An interstitial should show, and an event for the lock icon on the | 2971 // An interstitial should show, and an event for the lock icon on the |
2968 // interstitial should fire. | 2972 // interstitial should fire. |
2969 content::WaitForInterstitialAttach(web_contents); | 2973 content::WaitForInterstitialAttach(web_contents); |
2970 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); | 2974 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); |
2971 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser()); | 2975 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser()); |
2972 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 2976 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
2973 INVALID_CERTIFICATE, browser()); | 2977 INVALID_CERTIFICATE, browser()); |
2974 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 2978 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
2975 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 2979 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
2976 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 2980 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
2977 | 2981 |
2978 // Before clicking through, navigate to a different page, and then go | 2982 // Before clicking through, navigate to a different page, and then go |
2979 // back to the interstitial. | 2983 // back to the interstitial. |
2980 GURL valid_https_url(https_test_server.GetURL(std::string())); | 2984 GURL valid_https_url(https_test_server.GetURL(std::string("/"))); |
2981 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 2985 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
2982 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 2986 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
2983 observer.latest_security_style()); | 2987 observer.latest_security_style()); |
2984 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 2988 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); |
2985 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 2989 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
2986 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 2990 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
2987 VALID_CERTIFICATE, browser()); | 2991 VALID_CERTIFICATE, browser()); |
2988 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 2992 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
2989 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 2993 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
2990 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 2994 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
(...skipping 23 matching lines...) Expand all Loading... |
3014 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3018 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
3015 INVALID_CERTIFICATE, browser()); | 3019 INVALID_CERTIFICATE, browser()); |
3016 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3020 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
3017 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3021 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
3018 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3022 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
3019 } | 3023 } |
3020 | 3024 |
3021 // Visit a valid HTTPS page, then a broken HTTPS page, and then go back, | 3025 // Visit a valid HTTPS page, then a broken HTTPS page, and then go back, |
3022 // and test that the observed security style matches. | 3026 // and test that the observed security style matches. |
3023 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserverGoBack) { | 3027 IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserverGoBack) { |
3024 net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS, | 3028 net::EmbeddedTestServer https_test_server( |
3025 net::SpawnedTestServer::kLocalhost, | 3029 net::EmbeddedTestServer::TYPE_HTTPS); |
3026 base::FilePath(kDocRoot)); | 3030 https_test_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
| 3031 ASSERT_TRUE(https_test_server.Start()); |
3027 | 3032 |
3028 // Use a separate server to work around a mysterious SSL handshake | 3033 net::EmbeddedTestServer https_test_server_expired( |
3029 // timeout when both requests go to the same server. See | 3034 net::EmbeddedTestServer::TYPE_HTTPS); |
3030 // https://crbug.com/515906. | 3035 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
3031 net::SpawnedTestServer https_test_server_expired( | 3036 https_test_server_expired.ServeFilesFromSourceDirectory( |
3032 net::SpawnedTestServer::TYPE_HTTPS, | |
3033 net::SpawnedTestServer::SSLOptions( | |
3034 net::SpawnedTestServer::SSLOptions::CERT_EXPIRED), | |
3035 base::FilePath(kDocRoot)); | 3037 base::FilePath(kDocRoot)); |
3036 | |
3037 ASSERT_TRUE(https_test_server.Start()); | |
3038 ASSERT_TRUE(https_test_server_expired.Start()); | 3038 ASSERT_TRUE(https_test_server_expired.Start()); |
3039 | 3039 |
3040 content::WebContents* web_contents = | 3040 content::WebContents* web_contents = |
3041 browser()->tab_strip_model()->GetActiveWebContents(); | 3041 browser()->tab_strip_model()->GetActiveWebContents(); |
3042 SecurityStyleTestObserver observer(web_contents); | 3042 SecurityStyleTestObserver observer(web_contents); |
3043 | 3043 |
3044 // Visit a valid HTTPS url. | 3044 // Visit a valid HTTPS url. |
3045 GURL valid_https_url(https_test_server.GetURL(std::string())); | 3045 GURL valid_https_url(https_test_server.GetURL(std::string("/"))); |
3046 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 3046 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
3047 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 3047 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
3048 observer.latest_security_style()); | 3048 observer.latest_security_style()); |
3049 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 3049 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); |
3050 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3050 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
3051 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3051 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
3052 VALID_CERTIFICATE, browser()); | 3052 VALID_CERTIFICATE, browser()); |
3053 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3053 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
3054 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3054 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
3055 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3055 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
3056 | 3056 |
3057 // Navigate to a bad HTTPS page on a different host, and then click | 3057 // Navigate to a bad HTTPS page on a different host, and then click |
3058 // Back to verify that the previous good security style is seen again. | 3058 // Back to verify that the previous good security style is seen again. |
3059 GURL expired_https_url(https_test_server_expired.GetURL(std::string())); | 3059 GURL expired_https_url(https_test_server_expired.GetURL(std::string("/"))); |
3060 host_resolver()->AddRule("www.example_broken.test", "127.0.0.1"); | 3060 host_resolver()->AddRule("www.example_broken.test", "127.0.0.1"); |
3061 GURL::Replacements replace_host; | 3061 GURL::Replacements replace_host; |
3062 replace_host.SetHostStr("www.example_broken.test"); | 3062 replace_host.SetHostStr("www.example_broken.test"); |
3063 GURL https_url_different_host = | 3063 GURL https_url_different_host = |
3064 expired_https_url.ReplaceComponents(replace_host); | 3064 expired_https_url.ReplaceComponents(replace_host); |
3065 | 3065 |
3066 ui_test_utils::NavigateToURL(browser(), https_url_different_host); | 3066 ui_test_utils::NavigateToURL(browser(), https_url_different_host); |
3067 | 3067 |
3068 content::WaitForInterstitialAttach(web_contents); | 3068 content::WaitForInterstitialAttach(web_contents); |
3069 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); | 3069 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3212 false); | 3212 false); |
3213 | 3213 |
3214 // Sync navigation just to make sure IPC has passed (updated | 3214 // Sync navigation just to make sure IPC has passed (updated |
3215 // display mode is delivered to RP). | 3215 // display mode is delivered to RP). |
3216 content::TestNavigationObserver observer(app_contents, 1); | 3216 content::TestNavigationObserver observer(app_contents, 1); |
3217 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); | 3217 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); |
3218 observer.Wait(); | 3218 observer.Wait(); |
3219 | 3219 |
3220 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); | 3220 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); |
3221 } | 3221 } |
OLD | NEW |