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

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

Issue 2400673003: Remove SSLStatus::security_style member and content::SecurityStyle (Closed)
Patch Set: rebase 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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 1468
1466 std::string replacement_path; 1469 std::string replacement_path;
1467 GetFilePathWithHostAndPortReplacement( 1470 GetFilePathWithHostAndPortReplacement(
1468 "/ssl/page_displays_insecure_content.html", 1471 "/ssl/page_displays_insecure_content.html",
1469 embedded_test_server()->host_port_pair(), &replacement_path); 1472 embedded_test_server()->host_port_pair(), &replacement_path);
1470 1473
1471 // Load a page that displays insecure content. 1474 // Load a page that displays insecure content.
1472 ui_test_utils::NavigateToURL(browser(), 1475 ui_test_utils::NavigateToURL(browser(),
1473 https_server_.GetURL(replacement_path)); 1476 https_server_.GetURL(replacement_path));
1474 1477
1475 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), 1478 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(),
1476 AuthState::DISPLAYED_INSECURE_CONTENT); 1479 CertError::NONE, security_state::SecurityStateModel::NONE,
1480 AuthState::DISPLAYED_INSECURE_CONTENT);
1477 } 1481 }
1478 1482
1479 // Test that if the user proceeds and the checkbox is checked, a report 1483 // Test that if the user proceeds and the checkbox is checked, a report
1480 // is sent or not sent depending on the Finch config. 1484 // is sent or not sent depending on the Finch config.
1481 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting, 1485 IN_PROC_BROWSER_TEST_F(SSLUITestWithExtendedReporting,
1482 TestBrokenHTTPSProceedReporting) { 1486 TestBrokenHTTPSProceedReporting) {
1483 certificate_reporting_test_utils::ExpectReport expect_report = 1487 certificate_reporting_test_utils::ExpectReport expect_report =
1484 certificate_reporting_test_utils::GetReportExpectedFromFinch(); 1488 certificate_reporting_test_utils::GetReportExpectedFromFinch();
1485 TestBrokenHTTPSReporting( 1489 TestBrokenHTTPSReporting(
1486 certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN, 1490 certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN,
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 params.tabstrip_index = 0; 1736 params.tabstrip_index = 0;
1733 params.source_contents = tab1; 1737 params.source_contents = tab1;
1734 content::WindowedNotificationObserver observer( 1738 content::WindowedNotificationObserver observer(
1735 content::NOTIFICATION_LOAD_STOP, 1739 content::NOTIFICATION_LOAD_STOP,
1736 content::NotificationService::AllSources()); 1740 content::NotificationService::AllSources());
1737 chrome::Navigate(&params); 1741 chrome::Navigate(&params);
1738 WebContents* tab2 = params.target_contents; 1742 WebContents* tab2 = params.target_contents;
1739 observer.Wait(); 1743 observer.Wait();
1740 1744
1741 // The new tab has insecure content. 1745 // The new tab has insecure content.
1742 CheckAuthenticatedState(tab2, AuthState::DISPLAYED_INSECURE_CONTENT); 1746 CheckSecurityState(tab2, CertError::NONE,
1747 security_state::SecurityStateModel::NONE,
1748 AuthState::DISPLAYED_INSECURE_CONTENT);
1743 1749
1744 // The original tab should not be contaminated. 1750 // The original tab should not be contaminated.
1745 CheckAuthenticatedState(tab1, AuthState::NONE); 1751 CheckAuthenticatedState(tab1, AuthState::NONE);
1746 } 1752 }
1747 1753
1748 // Visits two pages from the same origin: one that runs insecure content and one 1754 // 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 1755 // that doesn't. The test checks that we propagate the insecure content state
1750 // from one to the other. 1756 // from one to the other.
1751 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { 1757 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) {
1752 ASSERT_TRUE(embedded_test_server()->Start()); 1758 ASSERT_TRUE(embedded_test_server()->Start());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 // Load original page over HTTP. 1813 // Load original page over HTTP.
1808 const GURL url_http = embedded_test_server()->GetURL(replacement_path); 1814 const GURL url_http = embedded_test_server()->GetURL(replacement_path);
1809 ui_test_utils::NavigateToURL(browser(), url_http); 1815 ui_test_utils::NavigateToURL(browser(), url_http);
1810 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1816 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1811 CheckUnauthenticatedState(tab, AuthState::NONE); 1817 CheckUnauthenticatedState(tab, AuthState::NONE);
1812 1818
1813 // Load again but over SSL. It should be marked as displaying insecure 1819 // Load again but over SSL. It should be marked as displaying insecure
1814 // content (even though the image comes from the WebCore memory cache). 1820 // content (even though the image comes from the WebCore memory cache).
1815 const GURL url_https = https_server_.GetURL(replacement_path); 1821 const GURL url_https = https_server_.GetURL(replacement_path);
1816 ui_test_utils::NavigateToURL(browser(), url_https); 1822 ui_test_utils::NavigateToURL(browser(), url_https);
1817 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 1823 CheckSecurityState(tab, CertError::NONE,
1824 security_state::SecurityStateModel::NONE,
1825 AuthState::DISPLAYED_INSECURE_CONTENT);
1818 } 1826 }
1819 1827
1820 // http://crbug.com/84729 1828 // http://crbug.com/84729
1821 #if defined(OS_CHROMEOS) 1829 #if defined(OS_CHROMEOS)
1822 #define MAYBE_TestRunsCachedInsecureContent \ 1830 #define MAYBE_TestRunsCachedInsecureContent \
1823 DISABLED_TestRunsCachedInsecureContent 1831 DISABLED_TestRunsCachedInsecureContent
1824 #else 1832 #else
1825 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent 1833 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent
1826 #endif // defined(OS_CHROMEOS) 1834 #endif // defined(OS_CHROMEOS)
1827 1835
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 " window.domAutomationController.setAutomationId(0);" 2163 " window.domAutomationController.setAutomationId(0);"
2156 " window.domAutomationController.send('mixed-image-loaded');" 2164 " window.domAutomationController.send('mixed-image-loaded');"
2157 "};" 2165 "};"
2158 "var img = document.createElement('img');" 2166 "var img = document.createElement('img');"
2159 "img.onload = loaded;" 2167 "img.onload = loaded;"
2160 "img.src = '" + 2168 "img.src = '" +
2161 https_url.spec() + "';" 2169 https_url.spec() + "';"
2162 "document.body.appendChild(img);")); 2170 "document.body.appendChild(img);"));
2163 2171
2164 run_loop.Run(); 2172 run_loop.Run();
2165 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 2173 CheckSecurityState(tab, CertError::NONE,
2174 security_state::SecurityStateModel::NONE,
2175 AuthState::DISPLAYED_INSECURE_CONTENT);
2166 } 2176 }
2167 2177
2168 // Visits a page to which we could not connect (bad port) over http and https 2178 // Visits a page to which we could not connect (bad port) over http and https
2169 // and make sure the security style is correct. 2179 // and make sure the security style is correct.
2170 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) { 2180 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) {
2171 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17")); 2181 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17"));
2172 CheckUnauthenticatedState( 2182 CheckUnauthenticatedState(
2173 browser()->tab_strip_model()->GetActiveWebContents(), 2183 browser()->tab_strip_model()->GetActiveWebContents(),
2174 AuthState::SHOWING_ERROR); 2184 AuthState::SHOWING_ERROR);
2175 2185
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 EXPECT_EQ( 2532 EXPECT_EQ(
2523 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN, 2533 security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN,
2524 security_info.content_with_cert_errors_status); 2534 security_info.content_with_cert_errors_status);
2525 } 2535 }
2526 2536
2527 // Like the test above, but only displaying inactive content (an image). 2537 // Like the test above, but only displaying inactive content (an image).
2528 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) { 2538 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) {
2529 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2539 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2530 ASSERT_NO_FATAL_FAILURE( 2540 ASSERT_NO_FATAL_FAILURE(
2531 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html")); 2541 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html"));
2532 CheckAuthenticatedState(tab, AuthState::NONE);
2533 2542
2534 ChromeSecurityStateModelClient* client = 2543 ChromeSecurityStateModelClient* client =
2535 ChromeSecurityStateModelClient::FromWebContents(tab); 2544 ChromeSecurityStateModelClient::FromWebContents(tab);
2536 ASSERT_TRUE(client); 2545 ASSERT_TRUE(client);
2537 security_state::SecurityStateModel::SecurityInfo security_info; 2546 security_state::SecurityStateModel::SecurityInfo security_info;
2538 client->GetSecurityInfo(&security_info); 2547 client->GetSecurityInfo(&security_info);
2539 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE, 2548 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
2540 security_info.mixed_content_status); 2549 security_info.mixed_content_status);
2541 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED, 2550 EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED,
2542 security_info.content_with_cert_errors_status); 2551 security_info.content_with_cert_errors_status);
2552 EXPECT_EQ(security_state::SecurityStateModel::NONE,
2553 security_info.security_level);
2554 EXPECT_EQ(0u, security_info.cert_status);
2543 2555
2544 int img_width; 2556 int img_width;
2545 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( 2557 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2546 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); 2558 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2547 // In order to check that the image was loaded, we check its width. 2559 // 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 2560 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2549 // image is greater than 100. 2561 // image is greater than 100.
2550 EXPECT_GT(img_width, 100); 2562 EXPECT_GT(img_width, 100);
2551 } 2563 }
2552 2564
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 2909 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
2898 content::TestNavigationObserver observer( 2910 content::TestNavigationObserver observer(
2899 contents, 2911 contents,
2900 // With PlzNavigate, the renderer only sees one navigation (i.e. not the 2912 // With PlzNavigate, the renderer only sees one navigation (i.e. not the
2901 // redirect, since that happens in the browser). 2913 // redirect, since that happens in the browser).
2902 content::IsBrowserSideNavigationEnabled() ? 1 : 2); 2914 content::IsBrowserSideNavigationEnabled() ? 1 : 2);
2903 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); 2915 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url);
2904 observer.Wait(); 2916 observer.Wait();
2905 2917
2906 CheckSecurityState(contents, CertError::NONE, 2918 CheckSecurityState(contents, CertError::NONE,
2907 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); 2919 security_state::SecurityStateModel::SECURE,
2920 AuthState::NONE);
2908 replacements.SetHostStr("mail.example.com"); 2921 replacements.SetHostStr("mail.example.com");
2909 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements); 2922 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements);
2910 // Verify that the current URL is the suggested URL. 2923 // Verify that the current URL is the suggested URL.
2911 EXPECT_EQ(https_server_new_url.spec(), 2924 EXPECT_EQ(https_server_new_url.spec(),
2912 contents->GetLastCommittedURL().spec()); 2925 contents->GetLastCommittedURL().spec());
2913 } 2926 }
2914 2927
2915 // Visit the URL example.org on a server that presents a valid certificate 2928 // 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. 2929 // for www.example.org. Verify that the page redirects to www.example.org.
2917 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, 2930 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(); 2968 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
2956 content::TestNavigationObserver observer( 2969 content::TestNavigationObserver observer(
2957 contents, 2970 contents,
2958 // With PlzNavigate, the renderer only sees one navigation (i.e. not the 2971 // With PlzNavigate, the renderer only sees one navigation (i.e. not the
2959 // redirect, since that happens in the browser). 2972 // redirect, since that happens in the browser).
2960 content::IsBrowserSideNavigationEnabled() ? 1 : 2); 2973 content::IsBrowserSideNavigationEnabled() ? 1 : 2);
2961 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); 2974 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url);
2962 observer.Wait(); 2975 observer.Wait();
2963 2976
2964 CheckSecurityState(contents, CertError::NONE, 2977 CheckSecurityState(contents, CertError::NONE,
2965 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); 2978 security_state::SecurityStateModel::SECURE,
2979 AuthState::NONE);
2966 } 2980 }
2967 2981
2968 // Tests this scenario: 2982 // Tests this scenario:
2969 // - |CommonNameMismatchHandler| does not give a callback as it's set into the 2983 // - |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 2984 // state |IGNORE_REQUESTS_FOR_TESTING|. So no suggested URL check result can
2971 // arrive. 2985 // arrive.
2972 // - A cert error triggers an interstitial timer with a very long timeout. 2986 // - 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 2987 // - No suggested URL check results arrive, causing the tab to appear as loading
2974 // indefinitely (also because the timer has a long timeout). 2988 // indefinitely (also because the timer has a long timeout).
2975 // - Stopping the page load shouldn't result in any interstitials. 2989 // - 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()); 3213 ASSERT_TRUE(https_server.Start());
3200 3214
3201 mock_cert_verifier()->set_default_result( 3215 mock_cert_verifier()->set_default_result(
3202 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION); 3216 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION);
3203 3217
3204 ui_test_utils::NavigateToURL(browser(), 3218 ui_test_utils::NavigateToURL(browser(),
3205 https_server.GetURL("/ssl/google.html")); 3219 https_server.GetURL("/ssl/google.html"));
3206 3220
3207 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), 3221 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(),
3208 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION, 3222 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION,
3209 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, 3223 security_state::SecurityStateModel::DANGEROUS,
3210 AuthState::SHOWING_INTERSTITIAL); 3224 AuthState::SHOWING_INTERSTITIAL);
3211 } 3225 }
3212 3226
3213 IN_PROC_BROWSER_TEST_F(SSLUITest, RestoreHasSSLState) { 3227 IN_PROC_BROWSER_TEST_F(SSLUITest, RestoreHasSSLState) {
3214 ASSERT_TRUE(https_server_.Start()); 3228 ASSERT_TRUE(https_server_.Start());
3215 GURL url(https_server_.GetURL("/ssl/google.html")); 3229 GURL url(https_server_.GetURL("/ssl/google.html"));
3216 ui_test_utils::NavigateToURL(browser(), url); 3230 ui_test_utils::NavigateToURL(browser(), url);
3217 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3231 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
3218 CheckAuthenticatedState(tab, AuthState::NONE); 3232 CheckAuthenticatedState(tab, AuthState::NONE);
3219 3233
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 ASSERT_TRUE(embedded_test_server()->Start()); 3333 ASSERT_TRUE(embedded_test_server()->Start());
3320 ASSERT_TRUE(https_server_.Start()); 3334 ASSERT_TRUE(https_server_.Start());
3321 3335
3322 GURL url = 3336 GURL url =
3323 GURL(https_server_.GetURL("/ssl/redirect.html").spec() 3337 GURL(https_server_.GetURL("/ssl/redirect.html").spec()
3324 + "?" + 3338 + "?" +
3325 https_server_.GetURL("/ssl/page_displays_insecure_content.html").spec()); 3339 https_server_.GetURL("/ssl/page_displays_insecure_content.html").spec());
3326 3340
3327 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); 3341 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2);
3328 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3342 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
3329 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 3343 CheckSecurityState(tab, CertError::NONE,
3344 security_state::SecurityStateModel::NONE,
3345 AuthState::DISPLAYED_INSECURE_CONTENT);
3330 } 3346 }
3331 3347
3332 // Checks that in-page navigations during page load preserves SSL state. 3348 // Checks that in-page navigations during page load preserves SSL state.
3333 IN_PROC_BROWSER_TEST_F(SSLUITest, InPageNavigationDuringLoadSSLState) { 3349 IN_PROC_BROWSER_TEST_F(SSLUITest, InPageNavigationDuringLoadSSLState) {
3334 ASSERT_TRUE(https_server_.Start()); 3350 ASSERT_TRUE(https_server_.Start());
3335 3351
3336 ui_test_utils::NavigateToURL( 3352 ui_test_utils::NavigateToURL(
3337 browser(), 3353 browser(),
3338 https_server_.GetURL("/ssl/in_page_navigation_during_load.html")); 3354 https_server_.GetURL("/ssl/in_page_navigation_during_load.html"));
3339 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 3355 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 3403
3388 // Visit a page over https that contains a frame with a redirect. 3404 // Visit a page over https that contains a frame with a redirect.
3389 3405
3390 // XMLHttpRequest insecure content in synchronous mode. 3406 // XMLHttpRequest insecure content in synchronous mode.
3391 3407
3392 // XMLHttpRequest insecure content in asynchronous mode. 3408 // XMLHttpRequest insecure content in asynchronous mode.
3393 3409
3394 // XMLHttpRequest over bad ssl in synchronous mode. 3410 // XMLHttpRequest over bad ssl in synchronous mode.
3395 3411
3396 // XMLHttpRequest over OK ssl in synchronous mode. 3412 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698