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

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

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

Powered by Google App Engine
This is Rietveld 408576698