| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 | 1046 |
| 1047 // Now go to a bad HTTPS page that shows an interstitial. | 1047 // Now go to a bad HTTPS page that shows an interstitial. |
| 1048 ui_test_utils::NavigateToURL( | 1048 ui_test_utils::NavigateToURL( |
| 1049 browser(), https_server_expired_.GetURL("/ssl/google.html")); | 1049 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
| 1050 CheckAuthenticationBrokenState( | 1050 CheckAuthenticationBrokenState( |
| 1051 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1051 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
| 1052 | 1052 |
| 1053 ProvisionalLoadWaiter load_failed_observer(tab); | 1053 ProvisionalLoadWaiter load_failed_observer(tab); |
| 1054 | 1054 |
| 1055 // Simulate user clicking on back button (crbug.com/39248). | 1055 // Simulate user clicking on back button (crbug.com/39248). |
| 1056 chrome::GoBack(browser(), CURRENT_TAB); | 1056 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 1057 | 1057 |
| 1058 // Wait until we hear the load failure, and make sure we haven't changed | 1058 // Wait until we hear the load failure, and make sure we haven't changed |
| 1059 // the previous RFH. Prevents regression of http://crbug.com/82667. | 1059 // the previous RFH. Prevents regression of http://crbug.com/82667. |
| 1060 load_failed_observer.Wait(); | 1060 load_failed_observer.Wait(); |
| 1061 EXPECT_EQ(rfh, tab->GetMainFrame()); | 1061 EXPECT_EQ(rfh, tab->GetMainFrame()); |
| 1062 | 1062 |
| 1063 // We should be back at the original good page. | 1063 // We should be back at the original good page. |
| 1064 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> | 1064 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> |
| 1065 GetInterstitialPage()); | 1065 GetInterstitialPage()); |
| 1066 CheckUnauthenticatedState(tab, AuthState::NONE); | 1066 CheckUnauthenticatedState(tab, AuthState::NONE); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 | 1474 |
| 1475 // There should still be an interstitial at this point. Press the | 1475 // There should still be an interstitial at this point. Press the |
| 1476 // back button on the browser. Note that this doesn't wait for a | 1476 // back button on the browser. Note that this doesn't wait for a |
| 1477 // NAV_ENTRY_COMMITTED notification because going back with an | 1477 // NAV_ENTRY_COMMITTED notification because going back with an |
| 1478 // active interstitial simply hides the interstitial. | 1478 // active interstitial simply hides the interstitial. |
| 1479 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); | 1479 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); |
| 1480 ASSERT_EQ( | 1480 ASSERT_EQ( |
| 1481 SSLBlockingPage::kTypeForTesting, | 1481 SSLBlockingPage::kTypeForTesting, |
| 1482 tab->GetInterstitialPage()->GetDelegateForTesting()->GetTypeForTesting()); | 1482 tab->GetInterstitialPage()->GetDelegateForTesting()->GetTypeForTesting()); |
| 1483 EXPECT_TRUE(chrome::CanGoBack(browser())); | 1483 EXPECT_TRUE(chrome::CanGoBack(browser())); |
| 1484 chrome::GoBack(browser(), CURRENT_TAB); | 1484 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 1485 | 1485 |
| 1486 dangerous_download_observer.WaitForFinished(); | 1486 dangerous_download_observer.WaitForFinished(); |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 // | 1489 // |
| 1490 // Insecure content | 1490 // Insecure content |
| 1491 // | 1491 // |
| 1492 | 1492 |
| 1493 #if defined(OS_WIN) | 1493 #if defined(OS_WIN) |
| 1494 // http://crbug.com/152940 Flaky on win. | 1494 // http://crbug.com/152940 Flaky on win. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 CheckAuthenticatedState(tab1, AuthState::NONE); | 1760 CheckAuthenticatedState(tab1, AuthState::NONE); |
| 1761 | 1761 |
| 1762 // Create a new tab. | 1762 // Create a new tab. |
| 1763 std::string replacement_path; | 1763 std::string replacement_path; |
| 1764 GetFilePathWithHostAndPortReplacement( | 1764 GetFilePathWithHostAndPortReplacement( |
| 1765 "/ssl/page_displays_insecure_content.html", | 1765 "/ssl/page_displays_insecure_content.html", |
| 1766 embedded_test_server()->host_port_pair(), &replacement_path); | 1766 embedded_test_server()->host_port_pair(), &replacement_path); |
| 1767 | 1767 |
| 1768 GURL url = https_server_.GetURL(replacement_path); | 1768 GURL url = https_server_.GetURL(replacement_path); |
| 1769 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); | 1769 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
| 1770 params.disposition = NEW_FOREGROUND_TAB; | 1770 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 1771 params.tabstrip_index = 0; | 1771 params.tabstrip_index = 0; |
| 1772 params.source_contents = tab1; | 1772 params.source_contents = tab1; |
| 1773 content::WindowedNotificationObserver observer( | 1773 content::WindowedNotificationObserver observer( |
| 1774 content::NOTIFICATION_LOAD_STOP, | 1774 content::NOTIFICATION_LOAD_STOP, |
| 1775 content::NotificationService::AllSources()); | 1775 content::NotificationService::AllSources()); |
| 1776 chrome::Navigate(¶ms); | 1776 chrome::Navigate(¶ms); |
| 1777 WebContents* tab2 = params.target_contents; | 1777 WebContents* tab2 = params.target_contents; |
| 1778 observer.Wait(); | 1778 observer.Wait(); |
| 1779 | 1779 |
| 1780 // The new tab has insecure content. | 1780 // The new tab has insecure content. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1802 std::string replacement_path; | 1802 std::string replacement_path; |
| 1803 GetFilePathWithHostAndPortReplacement( | 1803 GetFilePathWithHostAndPortReplacement( |
| 1804 "/ssl/page_runs_insecure_content.html", | 1804 "/ssl/page_runs_insecure_content.html", |
| 1805 embedded_test_server()->host_port_pair(), &replacement_path); | 1805 embedded_test_server()->host_port_pair(), &replacement_path); |
| 1806 | 1806 |
| 1807 // Create a new tab in the same process. Using a NEW_FOREGROUND_TAB | 1807 // Create a new tab in the same process. Using a NEW_FOREGROUND_TAB |
| 1808 // disposition won't usually stay in the same process, but this works | 1808 // disposition won't usually stay in the same process, but this works |
| 1809 // because we are using process-per-site in SetUpCommandLine. | 1809 // because we are using process-per-site in SetUpCommandLine. |
| 1810 GURL url = https_server_.GetURL(replacement_path); | 1810 GURL url = https_server_.GetURL(replacement_path); |
| 1811 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); | 1811 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
| 1812 params.disposition = NEW_FOREGROUND_TAB; | 1812 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 1813 params.source_contents = tab1; | 1813 params.source_contents = tab1; |
| 1814 content::WindowedNotificationObserver observer( | 1814 content::WindowedNotificationObserver observer( |
| 1815 content::NOTIFICATION_LOAD_STOP, | 1815 content::NOTIFICATION_LOAD_STOP, |
| 1816 content::NotificationService::AllSources()); | 1816 content::NotificationService::AllSources()); |
| 1817 chrome::Navigate(¶ms); | 1817 chrome::Navigate(¶ms); |
| 1818 WebContents* tab2 = params.target_contents; | 1818 WebContents* tab2 = params.target_contents; |
| 1819 observer.Wait(); | 1819 observer.Wait(); |
| 1820 | 1820 |
| 1821 // Both tabs should have the same process. | 1821 // Both tabs should have the same process. |
| 1822 EXPECT_EQ(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost()); | 1822 EXPECT_EQ(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost()); |
| (...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2928 https_server_url.ReplaceComponents(replacements); | 2928 https_server_url.ReplaceComponents(replacements); |
| 2929 | 2929 |
| 2930 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2930 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2931 CommonNameMismatchHandler::set_state_for_testing( | 2931 CommonNameMismatchHandler::set_state_for_testing( |
| 2932 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 2932 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
| 2933 // Set delay long enough so that the page appears loading. | 2933 // Set delay long enough so that the page appears loading. |
| 2934 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 2934 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
| 2935 SSLInterstitialTimerObserver interstitial_timer_observer(contents); | 2935 SSLInterstitialTimerObserver interstitial_timer_observer(contents); |
| 2936 | 2936 |
| 2937 ui_test_utils::NavigateToURLWithDisposition( | 2937 ui_test_utils::NavigateToURLWithDisposition( |
| 2938 browser(), https_server_mismatched_url, CURRENT_TAB, | 2938 browser(), https_server_mismatched_url, |
| 2939 ui_test_utils::BROWSER_TEST_NONE); | 2939 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 2940 interstitial_timer_observer.WaitForTimerStarted(); | 2940 interstitial_timer_observer.WaitForTimerStarted(); |
| 2941 | 2941 |
| 2942 EXPECT_TRUE(contents->IsLoading()); | 2942 EXPECT_TRUE(contents->IsLoading()); |
| 2943 content::WindowedNotificationObserver observer( | 2943 content::WindowedNotificationObserver observer( |
| 2944 content::NOTIFICATION_LOAD_STOP, | 2944 content::NOTIFICATION_LOAD_STOP, |
| 2945 content::NotificationService::AllSources()); | 2945 content::NotificationService::AllSources()); |
| 2946 contents->Stop(); | 2946 contents->Stop(); |
| 2947 observer.Wait(); | 2947 observer.Wait(); |
| 2948 | 2948 |
| 2949 SSLErrorHandler* ssl_error_handler = | 2949 SSLErrorHandler* ssl_error_handler = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 https_server_url.ReplaceComponents(replacements); | 2996 https_server_url.ReplaceComponents(replacements); |
| 2997 | 2997 |
| 2998 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2998 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2999 CommonNameMismatchHandler::set_state_for_testing( | 2999 CommonNameMismatchHandler::set_state_for_testing( |
| 3000 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 3000 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
| 3001 // Set delay long enough so that the page appears loading. | 3001 // Set delay long enough so that the page appears loading. |
| 3002 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 3002 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
| 3003 SSLInterstitialTimerObserver interstitial_timer_observer(contents); | 3003 SSLInterstitialTimerObserver interstitial_timer_observer(contents); |
| 3004 | 3004 |
| 3005 ui_test_utils::NavigateToURLWithDisposition( | 3005 ui_test_utils::NavigateToURLWithDisposition( |
| 3006 browser(), https_server_mismatched_url, CURRENT_TAB, | 3006 browser(), https_server_mismatched_url, |
| 3007 ui_test_utils::BROWSER_TEST_NONE); | 3007 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 3008 interstitial_timer_observer.WaitForTimerStarted(); | 3008 interstitial_timer_observer.WaitForTimerStarted(); |
| 3009 | 3009 |
| 3010 EXPECT_TRUE(contents->IsLoading()); | 3010 EXPECT_TRUE(contents->IsLoading()); |
| 3011 content::TestNavigationObserver observer(contents, 1); | 3011 content::TestNavigationObserver observer(contents, 1); |
| 3012 chrome::Reload(browser(), CURRENT_TAB); | 3012 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 3013 observer.Wait(); | 3013 observer.Wait(); |
| 3014 | 3014 |
| 3015 SSLErrorHandler* ssl_error_handler = | 3015 SSLErrorHandler* ssl_error_handler = |
| 3016 SSLErrorHandler::FromWebContents(contents); | 3016 SSLErrorHandler::FromWebContents(contents); |
| 3017 // Make sure that the |SSLErrorHandler| is deleted. | 3017 // Make sure that the |SSLErrorHandler| is deleted. |
| 3018 EXPECT_FALSE(ssl_error_handler); | 3018 EXPECT_FALSE(ssl_error_handler); |
| 3019 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 3019 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
| 3020 EXPECT_FALSE(contents->IsLoading()); | 3020 EXPECT_FALSE(contents->IsLoading()); |
| 3021 } | 3021 } |
| 3022 | 3022 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3062 https_server_url.ReplaceComponents(replacements); | 3062 https_server_url.ReplaceComponents(replacements); |
| 3063 | 3063 |
| 3064 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 3064 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 3065 CommonNameMismatchHandler::set_state_for_testing( | 3065 CommonNameMismatchHandler::set_state_for_testing( |
| 3066 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 3066 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
| 3067 // Set delay long enough so that the page appears loading. | 3067 // Set delay long enough so that the page appears loading. |
| 3068 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 3068 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
| 3069 SSLInterstitialTimerObserver interstitial_timer_observer(contents); | 3069 SSLInterstitialTimerObserver interstitial_timer_observer(contents); |
| 3070 | 3070 |
| 3071 ui_test_utils::NavigateToURLWithDisposition( | 3071 ui_test_utils::NavigateToURLWithDisposition( |
| 3072 browser(), https_server_mismatched_url, CURRENT_TAB, | 3072 browser(), https_server_mismatched_url, |
| 3073 ui_test_utils::BROWSER_TEST_NONE); | 3073 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 3074 interstitial_timer_observer.WaitForTimerStarted(); | 3074 interstitial_timer_observer.WaitForTimerStarted(); |
| 3075 | 3075 |
| 3076 EXPECT_TRUE(contents->IsLoading()); | 3076 EXPECT_TRUE(contents->IsLoading()); |
| 3077 content::TestNavigationObserver observer(contents, 1); | 3077 content::TestNavigationObserver observer(contents, 1); |
| 3078 browser()->OpenURL(content::OpenURLParams(GURL("https://google.com"), | 3078 browser()->OpenURL(content::OpenURLParams( |
| 3079 content::Referrer(), CURRENT_TAB, | 3079 GURL("https://google.com"), content::Referrer(), |
| 3080 ui::PAGE_TRANSITION_TYPED, false)); | 3080 WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 3081 observer.Wait(); | 3081 observer.Wait(); |
| 3082 | 3082 |
| 3083 SSLErrorHandler* ssl_error_handler = | 3083 SSLErrorHandler* ssl_error_handler = |
| 3084 SSLErrorHandler::FromWebContents(contents); | 3084 SSLErrorHandler::FromWebContents(contents); |
| 3085 // Make sure that the |SSLErrorHandler| is deleted. | 3085 // Make sure that the |SSLErrorHandler| is deleted. |
| 3086 EXPECT_FALSE(ssl_error_handler); | 3086 EXPECT_FALSE(ssl_error_handler); |
| 3087 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 3087 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
| 3088 EXPECT_FALSE(contents->IsLoading()); | 3088 EXPECT_FALSE(contents->IsLoading()); |
| 3089 } | 3089 } |
| 3090 | 3090 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3129 | 3129 |
| 3130 // Visit a page over https that contains a frame with a redirect. | 3130 // Visit a page over https that contains a frame with a redirect. |
| 3131 | 3131 |
| 3132 // XMLHttpRequest insecure content in synchronous mode. | 3132 // XMLHttpRequest insecure content in synchronous mode. |
| 3133 | 3133 |
| 3134 // XMLHttpRequest insecure content in asynchronous mode. | 3134 // XMLHttpRequest insecure content in asynchronous mode. |
| 3135 | 3135 |
| 3136 // XMLHttpRequest over bad ssl in synchronous mode. | 3136 // XMLHttpRequest over bad ssl in synchronous mode. |
| 3137 | 3137 |
| 3138 // XMLHttpRequest over OK ssl in synchronous mode. | 3138 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |