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

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 2400673003: Remove SSLStatus::security_style member and content::SecurityStyle (Closed)
Patch Set: more curly braces Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "content/public/browser/render_frame_host.h" 68 #include "content/public/browser/render_frame_host.h"
69 #include "content/public/browser/render_view_host.h" 69 #include "content/public/browser/render_view_host.h"
70 #include "content/public/browser/render_widget_host_view.h" 70 #include "content/public/browser/render_widget_host_view.h"
71 #include "content/public/browser/restore_type.h" 71 #include "content/public/browser/restore_type.h"
72 #include "content/public/browser/ssl_status.h" 72 #include "content/public/browser/ssl_status.h"
73 #include "content/public/browser/web_contents.h" 73 #include "content/public/browser/web_contents.h"
74 #include "content/public/browser/web_contents_observer.h" 74 #include "content/public/browser/web_contents_observer.h"
75 #include "content/public/common/browser_side_navigation_policy.h" 75 #include "content/public/common/browser_side_navigation_policy.h"
76 #include "content/public/common/content_switches.h" 76 #include "content/public/common/content_switches.h"
77 #include "content/public/common/page_state.h" 77 #include "content/public/common/page_state.h"
78 #include "content/public/common/security_style.h"
79 #include "content/public/test/browser_test_utils.h" 78 #include "content/public/test/browser_test_utils.h"
80 #include "content/public/test/download_test_observer.h" 79 #include "content/public/test/download_test_observer.h"
81 #include "content/public/test/test_navigation_observer.h" 80 #include "content/public/test/test_navigation_observer.h"
82 #include "content/public/test/test_renderer_host.h" 81 #include "content/public/test/test_renderer_host.h"
83 #include "content/public/test/test_utils.h" 82 #include "content/public/test/test_utils.h"
84 #include "net/base/host_port_pair.h" 83 #include "net/base/host_port_pair.h"
85 #include "net/base/net_errors.h" 84 #include "net/base/net_errors.h"
86 #include "net/cert/cert_status_flags.h" 85 #include "net/cert/cert_status_flags.h"
87 #include "net/cert/mock_cert_verifier.h" 86 #include "net/cert/mock_cert_verifier.h"
88 #include "net/cert/x509_certificate.h" 87 #include "net/cert/x509_certificate.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 bool ran_insecure_content = 152 bool ran_insecure_content =
154 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT); 153 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT);
155 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT), 154 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT),
156 ran_insecure_content); 155 ran_insecure_content);
157 } 156 }
158 157
159 } // namespace AuthState 158 } // namespace AuthState
160 159
161 namespace SecurityStyle { 160 namespace SecurityStyle {
162 161
163 void Check(const NavigationEntry& entry, 162 void Check(
164 content::SecurityStyle expected_security_style) { 163 WebContents* tab,
165 EXPECT_EQ(expected_security_style, entry.GetSSL().security_style); 164 security_state::SecurityStateModel::SecurityLevel expected_security_level) {
165 ChromeSecurityStateModelClient* model_client =
166 ChromeSecurityStateModelClient::FromWebContents(tab);
167 security_state::SecurityStateModel::SecurityInfo security_info;
168 model_client->GetSecurityInfo(&security_info);
169 EXPECT_EQ(expected_security_level, security_info.security_level);
166 } 170 }
167 171
168 } // namespace SecurityStyle 172 } // namespace SecurityStyle
169 173
170 namespace CertError { 174 namespace CertError {
171 175
172 enum CertErrorFlags { 176 enum CertErrorFlags {
173 NONE = 0 177 NONE = 0
174 }; 178 };
175 179
176 void Check(const NavigationEntry& entry, net::CertStatus error) { 180 void Check(const NavigationEntry& entry, net::CertStatus error) {
177 if (error) { 181 if (error) {
178 EXPECT_EQ(error, entry.GetSSL().cert_status & error); 182 EXPECT_EQ(error, entry.GetSSL().cert_status & error);
179 net::CertStatus extra_cert_errors = 183 net::CertStatus extra_cert_errors =
180 error ^ (entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS); 184 error ^ (entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS);
181 EXPECT_FALSE(extra_cert_errors) << "Got unexpected cert error: " 185 EXPECT_FALSE(extra_cert_errors) << "Got unexpected cert error: "
182 << extra_cert_errors; 186 << extra_cert_errors;
183 } else { 187 } else {
184 EXPECT_EQ(0U, entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS); 188 EXPECT_EQ(0U, entry.GetSSL().cert_status & net::CERT_STATUS_ALL_ERRORS);
185 } 189 }
186 } 190 }
187 191
188 } // namespace CertError 192 } // namespace CertError
189 193
190 void CheckSecurityState(WebContents* tab, 194 void CheckSecurityState(
191 net::CertStatus expected_error, 195 WebContents* tab,
192 content::SecurityStyle expected_security_style, 196 net::CertStatus expected_error,
193 int expected_authentication_state) { 197 security_state::SecurityStateModel::SecurityLevel expected_security_level,
198 int expected_authentication_state) {
194 ASSERT_FALSE(tab->IsCrashed()); 199 ASSERT_FALSE(tab->IsCrashed());
195 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 200 NavigationEntry* entry = tab->GetController().GetActiveEntry();
196 ASSERT_TRUE(entry); 201 ASSERT_TRUE(entry);
197 CertError::Check(*entry, expected_error); 202 CertError::Check(*entry, expected_error);
198 SecurityStyle::Check(*entry, expected_security_style); 203 SecurityStyle::Check(tab, expected_security_level);
199 AuthState::Check(*entry, expected_authentication_state); 204 AuthState::Check(*entry, expected_authentication_state);
200 } 205 }
201 206
202 // This observer waits for the SSLErrorHandler to start an interstitial timer 207 // This observer waits for the SSLErrorHandler to start an interstitial timer
203 // for the given web contents. 208 // for the given web contents.
204 class SSLInterstitialTimerObserver { 209 class SSLInterstitialTimerObserver {
205 public: 210 public:
206 explicit SSLInterstitialTimerObserver(content::WebContents* web_contents) 211 explicit SSLInterstitialTimerObserver(content::WebContents* web_contents)
207 : web_contents_(web_contents), message_loop_runner_(new base::RunLoop) { 212 : web_contents_(web_contents), message_loop_runner_(new base::RunLoop) {
208 callback_ = base::Bind(&SSLInterstitialTimerObserver::OnTimerStarted, 213 callback_ = base::Bind(&SSLInterstitialTimerObserver::OnTimerStarted,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 void SetUpCommandLine(base::CommandLine* command_line) override { 308 void SetUpCommandLine(base::CommandLine* command_line) override {
304 // Browser will both run and display insecure content. 309 // Browser will both run and display insecure content.
305 command_line->AppendSwitch(switches::kAllowRunningInsecureContent); 310 command_line->AppendSwitch(switches::kAllowRunningInsecureContent);
306 // Use process-per-site so that navigating to a same-site page in a 311 // Use process-per-site so that navigating to a same-site page in a
307 // new tab will use the same process. 312 // new tab will use the same process.
308 command_line->AppendSwitch(switches::kProcessPerSite); 313 command_line->AppendSwitch(switches::kProcessPerSite);
309 } 314 }
310 315
311 void CheckAuthenticatedState(WebContents* tab, 316 void CheckAuthenticatedState(WebContents* tab,
312 int expected_authentication_state) { 317 int expected_authentication_state) {
313 CheckSecurityState(tab, 318 CheckSecurityState(tab, CertError::NONE,
314 CertError::NONE, 319 security_state::SecurityStateModel::SECURE,
315 content::SECURITY_STYLE_AUTHENTICATED,
316 expected_authentication_state); 320 expected_authentication_state);
317 } 321 }
318 322
319 void CheckUnauthenticatedState(WebContents* tab, 323 void CheckUnauthenticatedState(WebContents* tab,
320 int expected_authentication_state) { 324 int expected_authentication_state) {
321 CheckSecurityState(tab, 325 CheckSecurityState(tab, CertError::NONE,
322 CertError::NONE, 326 security_state::SecurityStateModel::NONE,
323 content::SECURITY_STYLE_UNAUTHENTICATED,
324 expected_authentication_state); 327 expected_authentication_state);
325 } 328 }
326 329
327 void CheckAuthenticationBrokenState(WebContents* tab, 330 void CheckAuthenticationBrokenState(WebContents* tab,
328 net::CertStatus error, 331 net::CertStatus error,
329 int expected_authentication_state) { 332 int expected_authentication_state) {
330 CheckSecurityState(tab, 333 CheckSecurityState(tab, error,
331 error, 334 security_state::SecurityStateModel::DANGEROUS,
332 content::SECURITY_STYLE_AUTHENTICATION_BROKEN,
333 expected_authentication_state); 335 expected_authentication_state);
334 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security style 336 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security level
335 // to SECURITY_STYLE_AUTHENTICATION_BROKEN. 337 // to DANGEROUS.
336 ASSERT_NE(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION, error); 338 ASSERT_NE(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION, error);
337 } 339 }
338 340
339 void CheckWorkerLoadResult(WebContents* tab, bool expected_load) { 341 void CheckWorkerLoadResult(WebContents* tab, bool expected_load) {
340 // Workers are async and we don't have notifications for them passing 342 // Workers are async and we don't have notifications for them passing
341 // messages since they do it between renderer and worker processes. 343 // messages since they do it between renderer and worker processes.
342 // So have a polling loop, check every 200ms, timeout at 30s. 344 // So have a polling loop, check every 200ms, timeout at 30s.
343 const int kTimeoutMS = 200; 345 const int kTimeoutMS = 200;
344 base::Time time_to_quit = base::Time::Now() + 346 base::Time time_to_quit = base::Time::Now() +
345 base::TimeDelta::FromMilliseconds(30000); 347 base::TimeDelta::FromMilliseconds(30000);
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime()); 962 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime());
961 963
962 ui_test_utils::NavigateToURL(browser(), 964 ui_test_utils::NavigateToURL(browser(),
963 https_server_expired_.GetURL("/title1.html")); 965 https_server_expired_.GetURL("/title1.html"));
964 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); 966 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
965 content::WaitForInterstitialAttach(clock_tab); 967 content::WaitForInterstitialAttach(clock_tab);
966 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); 968 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
967 ASSERT_TRUE(clock_interstitial); 969 ASSERT_TRUE(clock_interstitial);
968 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 970 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
969 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 971 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
972 CheckSecurityState(clock_tab, net::CERT_STATUS_DATE_INVALID,
973 security_state::SecurityStateModel::DANGEROUS,
974 AuthState::SHOWING_INTERSTITIAL);
970 } 975 }
971 976
972 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingNetwork) { 977 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClockUsingNetwork) {
973 ASSERT_TRUE(https_server_expired_.Start()); 978 ASSERT_TRUE(https_server_expired_.Start());
974 979
975 // Set network forward ten minutes, which is sufficient to trigger 980 // Set network forward ten minutes, which is sufficient to trigger
976 // the interstitial. 981 // the interstitial.
977 g_browser_process->network_time_tracker()->UpdateNetworkTime( 982 g_browser_process->network_time_tracker()->UpdateNetworkTime(
978 base::Time::Now() + base::TimeDelta::FromMinutes(10), 983 base::Time::Now() + base::TimeDelta::FromMinutes(10),
979 base::TimeDelta::FromMilliseconds(1), /* resolution */ 984 base::TimeDelta::FromMilliseconds(1), /* resolution */
980 base::TimeDelta::FromMilliseconds(500), /* latency */ 985 base::TimeDelta::FromMilliseconds(500), /* latency */
981 base::TimeTicks::Now() /* posting time of this update */); 986 base::TimeTicks::Now() /* posting time of this update */);
982 987
983 ui_test_utils::NavigateToURL(browser(), 988 ui_test_utils::NavigateToURL(browser(),
984 https_server_expired_.GetURL("/title1.html")); 989 https_server_expired_.GetURL("/title1.html"));
985 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); 990 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
986 content::WaitForInterstitialAttach(clock_tab); 991 content::WaitForInterstitialAttach(clock_tab);
987 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); 992 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
988 ASSERT_TRUE(clock_interstitial); 993 ASSERT_TRUE(clock_interstitial);
989 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 994 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
990 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 995 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
996 CheckSecurityState(clock_tab, net::CERT_STATUS_DATE_INVALID,
997 security_state::SecurityStateModel::DANGEROUS,
998 AuthState::SHOWING_INTERSTITIAL);
991 } 999 }
992 1000
993 // Visits a page with https error and then goes back using Browser::GoBack. 1001 // Visits a page with https error and then goes back using Browser::GoBack.
994 IN_PROC_BROWSER_TEST_F(SSLUITest, 1002 IN_PROC_BROWSER_TEST_F(SSLUITest,
995 TestHTTPSExpiredCertAndGoBackViaButton) { 1003 TestHTTPSExpiredCertAndGoBackViaButton) {
996 ASSERT_TRUE(embedded_test_server()->Start()); 1004 ASSERT_TRUE(embedded_test_server()->Start());
997 ASSERT_TRUE(https_server_expired_.Start()); 1005 ASSERT_TRUE(https_server_expired_.Start());
998 1006
999 // First navigate to an HTTP page. 1007 // First navigate to an HTTP page.
1000 ui_test_utils::NavigateToURL( 1008 ui_test_utils::NavigateToURL(
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 1473
1466 std::string replacement_path; 1474 std::string replacement_path;
1467 GetFilePathWithHostAndPortReplacement( 1475 GetFilePathWithHostAndPortReplacement(
1468 "/ssl/page_displays_insecure_content.html", 1476 "/ssl/page_displays_insecure_content.html",
1469 embedded_test_server()->host_port_pair(), &replacement_path); 1477 embedded_test_server()->host_port_pair(), &replacement_path);
1470 1478
1471 // Load a page that displays insecure content. 1479 // Load a page that displays insecure content.
1472 ui_test_utils::NavigateToURL(browser(), 1480 ui_test_utils::NavigateToURL(browser(),
1473 https_server_.GetURL(replacement_path)); 1481 https_server_.GetURL(replacement_path));
1474 1482
1475 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), 1483 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(),
1476 AuthState::DISPLAYED_INSECURE_CONTENT); 1484 CertError::NONE, security_state::SecurityStateModel::NONE,
1485 AuthState::DISPLAYED_INSECURE_CONTENT);
1477 } 1486 }
1478 1487
1479 // Test that if the user proceeds and the checkbox is checked, a report 1488 // Test that if the user proceeds and the checkbox is checked, a report
1480 // is sent or not sent depending on the Finch config. 1489 // is sent or not sent depending on the Finch config.
1481 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting, 1490 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting,
1482 TestBrokenHTTPSProceedReporting) { 1491 TestBrokenHTTPSProceedReporting) {
1483 certificate_reporting_test_utils::ExpectReport expect_report = 1492 certificate_reporting_test_utils::ExpectReport expect_report =
1484 certificate_reporting_test_utils::GetReportExpectedFromFinch(); 1493 certificate_reporting_test_utils::GetReportExpectedFromFinch();
1485 TestBrokenHTTPSReporting( 1494 TestBrokenHTTPSReporting(
1486 certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN, 1495 certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 1704
1696 // Load the insecure image. 1705 // Load the insecure image.
1697 bool js_result = false; 1706 bool js_result = false;
1698 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 1707 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1699 tab, 1708 tab,
1700 "loadBadImage();", 1709 "loadBadImage();",
1701 &js_result)); 1710 &js_result));
1702 EXPECT_TRUE(js_result); 1711 EXPECT_TRUE(js_result);
1703 1712
1704 // We should now have insecure content. 1713 // We should now have insecure content.
1705 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 1714 CheckSecurityState(tab, CertError::NONE,
1715 security_state::SecurityStateModel::NONE,
1716 AuthState::DISPLAYED_INSECURE_CONTENT);
1706 } 1717 }
1707 1718
1708 // Visits two pages from the same origin: one that displays insecure content and 1719 // Visits two pages from the same origin: one that displays insecure content and
1709 // one that doesn't. The test checks that we do not propagate the insecure 1720 // one that doesn't. The test checks that we do not propagate the insecure
1710 // content state from one to the other. 1721 // content state from one to the other.
1711 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) { 1722 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) {
1712 ASSERT_TRUE(embedded_test_server()->Start()); 1723 ASSERT_TRUE(embedded_test_server()->Start());
1713 ASSERT_TRUE(https_server_.Start()); 1724 ASSERT_TRUE(https_server_.Start());
1714 1725
1715 ui_test_utils::NavigateToURL(browser(), 1726 ui_test_utils::NavigateToURL(browser(),
(...skipping 16 matching lines...) Expand all
1732 params.tabstrip_index = 0; 1743 params.tabstrip_index = 0;
1733 params.source_contents = tab1; 1744 params.source_contents = tab1;
1734 content::WindowedNotificationObserver observer( 1745 content::WindowedNotificationObserver observer(
1735 content::NOTIFICATION_LOAD_STOP, 1746 content::NOTIFICATION_LOAD_STOP,
1736 content::NotificationService::AllSources()); 1747 content::NotificationService::AllSources());
1737 chrome::Navigate(&params); 1748 chrome::Navigate(&params);
1738 WebContents* tab2 = params.target_contents; 1749 WebContents* tab2 = params.target_contents;
1739 observer.Wait(); 1750 observer.Wait();
1740 1751
1741 // The new tab has insecure content. 1752 // The new tab has insecure content.
1742 CheckAuthenticatedState(tab2, AuthState::DISPLAYED_INSECURE_CONTENT); 1753 CheckSecurityState(tab2, CertError::NONE,
1754 security_state::SecurityStateModel::NONE,
1755 AuthState::DISPLAYED_INSECURE_CONTENT);
1743 1756
1744 // The original tab should not be contaminated. 1757 // The original tab should not be contaminated.
1745 CheckAuthenticatedState(tab1, AuthState::NONE); 1758 CheckAuthenticatedState(tab1, AuthState::NONE);
1746 } 1759 }
1747 1760
1748 // Visits two pages from the same origin: one that runs insecure content and one 1761 // Visits two pages from the same origin: one that runs insecure content and one
1749 // that doesn't. The test checks that we propagate the insecure content state 1762 // that doesn't. The test checks that we propagate the insecure content state
1750 // from one to the other. 1763 // from one to the other.
1751 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { 1764 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) {
1752 ASSERT_TRUE(embedded_test_server()->Start()); 1765 ASSERT_TRUE(embedded_test_server()->Start());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 // Load original page over HTTP. 1820 // Load original page over HTTP.
1808 const GURL url_http = embedded_test_server()->GetURL(replacement_path); 1821 const GURL url_http = embedded_test_server()->GetURL(replacement_path);
1809 ui_test_utils::NavigateToURL(browser(), url_http); 1822 ui_test_utils::NavigateToURL(browser(), url_http);
1810 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1823 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1811 CheckUnauthenticatedState(tab, AuthState::NONE); 1824 CheckUnauthenticatedState(tab, AuthState::NONE);
1812 1825
1813 // Load again but over SSL. It should be marked as displaying insecure 1826 // Load again but over SSL. It should be marked as displaying insecure
1814 // content (even though the image comes from the WebCore memory cache). 1827 // content (even though the image comes from the WebCore memory cache).
1815 const GURL url_https = https_server_.GetURL(replacement_path); 1828 const GURL url_https = https_server_.GetURL(replacement_path);
1816 ui_test_utils::NavigateToURL(browser(), url_https); 1829 ui_test_utils::NavigateToURL(browser(), url_https);
1817 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 1830 CheckSecurityState(tab, CertError::NONE,
1831 security_state::SecurityStateModel::NONE,
1832 AuthState::DISPLAYED_INSECURE_CONTENT);
1818 } 1833 }
1819 1834
1820 // http://crbug.com/84729 1835 // http://crbug.com/84729
1821 #if defined(OS_CHROMEOS) 1836 #if defined(OS_CHROMEOS)
1822 #define MAYBE_TestRunsCachedInsecureContent \ 1837 #define MAYBE_TestRunsCachedInsecureContent \
1823 DISABLED_TestRunsCachedInsecureContent 1838 DISABLED_TestRunsCachedInsecureContent
1824 #else 1839 #else
1825 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent 1840 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent
1826 #endif // defined(OS_CHROMEOS) 1841 #endif // defined(OS_CHROMEOS)
1827 1842
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 " window.domAutomationController.setAutomationId(0);" 2170 " window.domAutomationController.setAutomationId(0);"
2156 " window.domAutomationController.send('mixed-image-loaded');" 2171 " window.domAutomationController.send('mixed-image-loaded');"
2157 "};" 2172 "};"
2158 "var img = document.createElement('img');" 2173 "var img = document.createElement('img');"
2159 "img.onload = loaded;" 2174 "img.onload = loaded;"
2160 "img.src = '" + 2175 "img.src = '" +
2161 https_url.spec() + "';" 2176 https_url.spec() + "';"
2162 "document.body.appendChild(img);")); 2177 "document.body.appendChild(img);"));
2163 2178
2164 run_loop.Run(); 2179 run_loop.Run();
2165 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 2180 CheckSecurityState(tab, CertError::NONE,
2181 security_state::SecurityStateModel::NONE,
2182 AuthState::DISPLAYED_INSECURE_CONTENT);
2166 } 2183 }
2167 2184
2168 // Visits a page to which we could not connect (bad port) over http and https 2185 // Visits a page to which we could not connect (bad port) over http and https
2169 // and make sure the security style is correct. 2186 // and make sure the security style is correct.
2170 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) { 2187 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) {
2171 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17")); 2188 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17"));
2172 CheckUnauthenticatedState( 2189 CheckUnauthenticatedState(
2173 browser()->tab_strip_model()->GetActiveWebContents(), 2190 browser()->tab_strip_model()->GetActiveWebContents(),
2174 AuthState::SHOWING_ERROR); 2191 AuthState::SHOWING_ERROR);
2175 2192
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 EXPECT_EQ( 2539 EXPECT_EQ(
2523 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN, 2540 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN,
2524 security_info.content_with_cert_errors_status); 2541 security_info.content_with_cert_errors_status);
2525 } 2542 }
2526 2543
2527 // Like the test above, but only displaying inactive content (an image). 2544 // Like the test above, but only displaying inactive content (an image).
2528 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) { 2545 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) {
2529 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2546 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2530 ASSERT_NO_FATAL_FAILURE( 2547 ASSERT_NO_FATAL_FAILURE(
2531 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html")); 2548 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html"));
2532 CheckAuthenticatedState(tab, AuthState::NONE);
2533 2549
2534 ChromeSecurityStateModelClient* client = 2550 ChromeSecurityStateModelClient* client =
2535 ChromeSecurityStateModelClient::FromWebContents(tab); 2551 ChromeSecurityStateModelClient::FromWebContents(tab);
2536 ASSERT_TRUE(client); 2552 ASSERT_TRUE(client);
2537 security_state::SecurityStateModel::SecurityInfo security_info; 2553 security_state::SecurityStateModel::SecurityInfo security_info;
2538 client->GetSecurityInfo(&security_info); 2554 client->GetSecurityInfo(&security_info);
2539 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE, 2555 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
2540 security_info.mixed_content_status); 2556 security_info.mixed_content_status);
2541 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED, 2557 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED,
2542 security_info.content_with_cert_errors_status); 2558 security_info.content_with_cert_errors_status);
2559 EXPECT_EQ(security_state::SecurityStateModel::NONE,
2560 security_info.security_level);
2561 EXPECT_EQ(0u, security_info.cert_status);
2543 2562
2544 int img_width; 2563 int img_width;
2545 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( 2564 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2546 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); 2565 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2547 // In order to check that the image was loaded, we check its width. 2566 // In order to check that the image was loaded, we check its width.
2548 // The actual image (Google logo) is 114 pixels wide, so we assume a good 2567 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2549 // image is greater than 100. 2568 // image is greater than 100.
2550 EXPECT_GT(img_width, 100); 2569 EXPECT_GT(img_width, 100);
2551 } 2570 }
2552 2571
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 2916 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
2898 content::TestNavigationObserver observer( 2917 content::TestNavigationObserver observer(
2899 contents, 2918 contents,
2900 // With PlzNavigate, the renderer only sees one navigation (i.e. not the 2919 // With PlzNavigate, the renderer only sees one navigation (i.e. not the
2901 // redirect, since that happens in the browser). 2920 // redirect, since that happens in the browser).
2902 content::IsBrowserSideNavigationEnabled() ? 1 : 2); 2921 content::IsBrowserSideNavigationEnabled() ? 1 : 2);
2903 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); 2922 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url);
2904 observer.Wait(); 2923 observer.Wait();
2905 2924
2906 CheckSecurityState(contents, CertError::NONE, 2925 CheckSecurityState(contents, CertError::NONE,
2907 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); 2926 security_state::SecurityStateModel::SECURE,
2927 AuthState::NONE);
2908 replacements.SetHostStr("mail.example.com"); 2928 replacements.SetHostStr("mail.example.com");
2909 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements); 2929 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements);
2910 // Verify that the current URL is the suggested URL. 2930 // Verify that the current URL is the suggested URL.
2911 EXPECT_EQ(https_server_new_url.spec(), 2931 EXPECT_EQ(https_server_new_url.spec(),
2912 contents->GetLastCommittedURL().spec()); 2932 contents->GetLastCommittedURL().spec());
2913 } 2933 }
2914 2934
2915 // Visit the URL example.org on a server that presents a valid certificate 2935 // Visit the URL example.org on a server that presents a valid certificate
2916 // for www.example.org. Verify that the page redirects to www.example.org. 2936 // for www.example.org. Verify that the page redirects to www.example.org.
2917 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, 2937 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2955 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 2975 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
2956 content::TestNavigationObserver observer( 2976 content::TestNavigationObserver observer(
2957 contents, 2977 contents,
2958 // With PlzNavigate, the renderer only sees one navigation (i.e. not the 2978 // With PlzNavigate, the renderer only sees one navigation (i.e. not the
2959 // redirect, since that happens in the browser). 2979 // redirect, since that happens in the browser).
2960 content::IsBrowserSideNavigationEnabled() ? 1 : 2); 2980 content::IsBrowserSideNavigationEnabled() ? 1 : 2);
2961 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); 2981 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url);
2962 observer.Wait(); 2982 observer.Wait();
2963 2983
2964 CheckSecurityState(contents, CertError::NONE, 2984 CheckSecurityState(contents, CertError::NONE,
2965 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); 2985 security_state::SecurityStateModel::SECURE,
2986 AuthState::NONE);
2966 } 2987 }
2967 2988
2968 // Tests this scenario: 2989 // Tests this scenario:
2969 // - |CommonNameMismatchHandler| does not give a callback as it's set into the 2990 // - |CommonNameMismatchHandler| does not give a callback as it's set into the
2970 // state |IGNORE_REQUESTS_FOR_TESTING|. So no suggested URL check result can 2991 // state |IGNORE_REQUESTS_FOR_TESTING|. So no suggested URL check result can
2971 // arrive. 2992 // arrive.
2972 // - A cert error triggers an interstitial timer with a very long timeout. 2993 // - A cert error triggers an interstitial timer with a very long timeout.
2973 // - No suggested URL check results arrive, causing the tab to appear as loading 2994 // - No suggested URL check results arrive, causing the tab to appear as loading
2974 // indefinitely (also because the timer has a long timeout). 2995 // indefinitely (also because the timer has a long timeout).
2975 // - Stopping the page load shouldn't result in any interstitials. 2996 // - Stopping the page load shouldn't result in any interstitials.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 ASSERT_TRUE(https_server.Start()); 3220 ASSERT_TRUE(https_server.Start());
3200 3221
3201 mock_cert_verifier()->set_default_result( 3222 mock_cert_verifier()->set_default_result(
3202 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION); 3223 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION);
3203 3224
3204 ui_test_utils::NavigateToURL(browser(), 3225 ui_test_utils::NavigateToURL(browser(),
3205 https_server.GetURL("/ssl/google.html")); 3226 https_server.GetURL("/ssl/google.html"));
3206 3227
3207 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), 3228 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(),
3208 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION, 3229 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION,
3209 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, 3230 security_state::SecurityStateModel::DANGEROUS,
3210 AuthState::SHOWING_INTERSTITIAL); 3231 AuthState::SHOWING_INTERSTITIAL);
3211 } 3232 }
3212 3233
3213 IN_PROC_BROWSER_TEST_F(SSLUITest, RestoreHasSSLState) { 3234 IN_PROC_BROWSER_TEST_F(SSLUITest, RestoreHasSSLState) {
3214 ASSERT_TRUE(https_server_.Start()); 3235 ASSERT_TRUE(https_server_.Start());
3215 GURL url(https_server_.GetURL("/ssl/google.html")); 3236 GURL url(https_server_.GetURL("/ssl/google.html"));
3216 ui_test_utils::NavigateToURL(browser(), url); 3237 ui_test_utils::NavigateToURL(browser(), url);
3217 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3238 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
3218 CheckAuthenticatedState(tab, AuthState::NONE); 3239 CheckAuthenticatedState(tab, AuthState::NONE);
3219 3240
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 ASSERT_TRUE(embedded_test_server()->Start()); 3340 ASSERT_TRUE(embedded_test_server()->Start());
3320 ASSERT_TRUE(https_server_.Start()); 3341 ASSERT_TRUE(https_server_.Start());
3321 3342
3322 GURL url = 3343 GURL url =
3323 GURL(https_server_.GetURL("/ssl/redirect.html").spec() 3344 GURL(https_server_.GetURL("/ssl/redirect.html").spec()
3324 + "?" + 3345 + "?" +
3325 https_server_.GetURL("/ssl/page_displays_insecure_content.html").spec()); 3346 https_server_.GetURL("/ssl/page_displays_insecure_content.html").spec());
3326 3347
3327 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); 3348 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2);
3328 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3349 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
3329 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 3350 CheckSecurityState(tab, CertError::NONE,
3351 security_state::SecurityStateModel::NONE,
3352 AuthState::DISPLAYED_INSECURE_CONTENT);
3330 } 3353 }
3331 3354
3332 // Checks that in-page navigations during page load preserves SSL state. 3355 // Checks that in-page navigations during page load preserves SSL state.
3333 IN_PROC_BROWSER_TEST_F(SSLUITest, InPageNavigationDuringLoadSSLState) { 3356 IN_PROC_BROWSER_TEST_F(SSLUITest, InPageNavigationDuringLoadSSLState) {
3334 ASSERT_TRUE(https_server_.Start()); 3357 ASSERT_TRUE(https_server_.Start());
3335 3358
3336 ui_test_utils::NavigateToURL( 3359 ui_test_utils::NavigateToURL(
3337 browser(), 3360 browser(),
3338 https_server_.GetURL("/ssl/in_page_navigation_during_load.html")); 3361 https_server_.GetURL("/ssl/in_page_navigation_during_load.html"));
3339 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3362 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 3410
3388 // Visit a page over https that contains a frame with a redirect. 3411 // Visit a page over https that contains a frame with a redirect.
3389 3412
3390 // XMLHttpRequest insecure content in synchronous mode. 3413 // XMLHttpRequest insecure content in synchronous mode.
3391 3414
3392 // XMLHttpRequest insecure content in asynchronous mode. 3415 // XMLHttpRequest insecure content in asynchronous mode.
3393 3416
3394 // XMLHttpRequest over bad ssl in synchronous mode. 3417 // XMLHttpRequest over bad ssl in synchronous mode.
3395 3418
3396 // XMLHttpRequest over OK ssl in synchronous mode. 3419 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.cc ('k') | chrome/browser/ui/autofill/chrome_autofill_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698