| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" | 17 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" |
| 18 #include "chrome/browser/net/certificate_error_reporter.h" | 18 #include "chrome/browser/net/certificate_error_reporter.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/safe_browsing/ping_manager.h" | 20 #include "chrome/browser/safe_browsing/ping_manager.h" |
| 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 22 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 22 #include "chrome/browser/ssl/ssl_blocking_page.h" | 23 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_commands.h" | 25 #include "chrome/browser/ui/browser_commands.h" |
| 25 #include "chrome/browser/ui/browser_navigator.h" | 26 #include "chrome/browser/ui/browser_navigator.h" |
| 26 #include "chrome/browser/ui/browser_tabstrip.h" | 27 #include "chrome/browser/ui/browser_tabstrip.h" |
| 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/test/base/in_process_browser_test.h" | 32 #include "chrome/test/base/in_process_browser_test.h" |
| 32 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
| 33 #include "components/content_settings/core/browser/host_content_settings_map.h" | 34 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 34 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 35 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 35 #include "content/public/browser/browser_context.h" | 36 #include "content/public/browser/browser_context.h" |
| 36 #include "content/public/browser/interstitial_page.h" | 37 #include "content/public/browser/interstitial_page.h" |
| 37 #include "content/public/browser/navigation_controller.h" | 38 #include "content/public/browser/navigation_controller.h" |
| 38 #include "content/public/browser/navigation_entry.h" | 39 #include "content/public/browser/navigation_entry.h" |
| 39 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 40 #include "content/public/browser/render_frame_host.h" | 41 #include "content/public/browser/render_frame_host.h" |
| 42 #include "content/public/browser/render_process_host.h" |
| 41 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
| 42 #include "content/public/browser/render_widget_host_view.h" | 44 #include "content/public/browser/render_widget_host_view.h" |
| 43 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/browser/web_contents_observer.h" | 46 #include "content/public/browser/web_contents_observer.h" |
| 45 #include "content/public/common/security_style.h" | 47 #include "content/public/common/security_style.h" |
| 46 #include "content/public/common/ssl_status.h" | 48 #include "content/public/common/ssl_status.h" |
| 47 #include "content/public/test/browser_test_utils.h" | 49 #include "content/public/test/browser_test_utils.h" |
| 48 #include "content/public/test/download_test_observer.h" | 50 #include "content/public/test/download_test_observer.h" |
| 49 #include "content/public/test/test_renderer_host.h" | 51 #include "content/public/test/test_renderer_host.h" |
| 52 #include "net/base/host_port_pair.h" |
| 50 #include "net/base/net_errors.h" | 53 #include "net/base/net_errors.h" |
| 51 #include "net/base/test_data_directory.h" | 54 #include "net/base/test_data_directory.h" |
| 52 #include "net/cert/cert_status_flags.h" | 55 #include "net/cert/cert_status_flags.h" |
| 56 #include "net/cert/test_root_certs.h" |
| 53 #include "net/cert/x509_certificate.h" | 57 #include "net/cert/x509_certificate.h" |
| 58 #include "net/dns/host_resolver.h" |
| 59 #include "net/dns/mock_host_resolver.h" |
| 60 #include "net/http/http_transaction_factory.h" |
| 54 #include "net/ssl/ssl_info.h" | 61 #include "net/ssl/ssl_info.h" |
| 55 #include "net/test/spawned_test_server/spawned_test_server.h" | 62 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 56 #include "net/url_request/url_request_context.h" | 63 #include "net/url_request/url_request_context.h" |
| 64 #include "net/url_request/url_request_context_getter.h" |
| 57 | 65 |
| 58 #if defined(USE_NSS) | 66 #if defined(USE_NSS) |
| 59 #include "chrome/browser/net/nss_context.h" | 67 #include "chrome/browser/net/nss_context.h" |
| 60 #include "net/base/crypto_module.h" | 68 #include "net/base/crypto_module.h" |
| 61 #include "net/cert/nss_cert_database.h" | 69 #include "net/cert/nss_cert_database.h" |
| 62 #endif // defined(USE_NSS) | 70 #endif // defined(USE_NSS) |
| 63 | 71 |
| 64 using base::ASCIIToUTF16; | 72 using base::ASCIIToUTF16; |
| 65 using chrome_browser_interstitials::SecurityInterstitialIDNTest; | 73 using chrome_browser_interstitials::SecurityInterstitialIDNTest; |
| 66 using chrome_browser_net::CertificateErrorReporter; | 74 using chrome_browser_net::CertificateErrorReporter; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 }; | 223 }; |
| 216 | 224 |
| 217 void SetUpMockReporter(SafeBrowsingService* safe_browsing_service, | 225 void SetUpMockReporter(SafeBrowsingService* safe_browsing_service, |
| 218 MockReporter* reporter) { | 226 MockReporter* reporter) { |
| 219 safe_browsing_service->ping_manager()->SetCertificateErrorReporterForTesting( | 227 safe_browsing_service->ping_manager()->SetCertificateErrorReporterForTesting( |
| 220 scoped_ptr<CertificateErrorReporter>(reporter)); | 228 scoped_ptr<CertificateErrorReporter>(reporter)); |
| 221 } | 229 } |
| 222 | 230 |
| 223 } // namespace CertificateReporting | 231 } // namespace CertificateReporting |
| 224 | 232 |
| 233 void RootCertsChangedOnIOThread( |
| 234 const scoped_refptr<net::URLRequestContextGetter> context_getter) { |
| 235 net::CertDatabase::GetInstance()->NotifyObserversOfCACertChanged(NULL); |
| 236 context_getter->GetURLRequestContext() |
| 237 ->http_transaction_factory() |
| 238 ->GetSession() |
| 239 ->CloseAllConnections(); |
| 240 } |
| 241 |
| 242 // Alerts the URLRequestContext for the given WebContents that a root |
| 243 // certificate has changed state or been removed. This, in turn, clears any |
| 244 // cached certificate validation in the cert verifier. This will also close all |
| 245 // connections in the socket pool of |contents|, so calls to this should be made |
| 246 // with care. |
| 247 void RootCertsChanged(WebContents* contents) { |
| 248 scoped_refptr<net::URLRequestContextGetter> url_request_context = |
| 249 contents->GetBrowserContext()->GetRequestContextForRenderProcess( |
| 250 contents->GetRenderProcessHost()->GetID()); |
| 251 base::RunLoop run_loop; |
| 252 content::BrowserThread::PostTaskAndReply( |
| 253 content::BrowserThread::IO, FROM_HERE, |
| 254 base::Bind(&RootCertsChangedOnIOThread, url_request_context), |
| 255 run_loop.QuitClosure()); |
| 256 run_loop.Run(); |
| 257 base::RunLoop().RunUntilIdle(); |
| 258 } |
| 259 |
| 225 } // namespace | 260 } // namespace |
| 226 | 261 |
| 227 class SSLUITest : public InProcessBrowserTest { | 262 class SSLUITest : public InProcessBrowserTest { |
| 228 public: | 263 public: |
| 229 SSLUITest() | 264 SSLUITest() |
| 230 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, | 265 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, |
| 231 SSLOptions(SSLOptions::CERT_OK), | 266 SSLOptions(SSLOptions::CERT_OK), |
| 232 base::FilePath(kDocRoot)), | 267 base::FilePath(kDocRoot)), |
| 233 https_server_expired_(net::SpawnedTestServer::TYPE_HTTPS, | 268 https_server_expired_(net::SpawnedTestServer::TYPE_HTTPS, |
| 234 SSLOptions(SSLOptions::CERT_EXPIRED), | 269 SSLOptions(SSLOptions::CERT_EXPIRED), |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 std::vector<net::SpawnedTestServer::StringPair> replacement_text_top_frame; | 423 std::vector<net::SpawnedTestServer::StringPair> replacement_text_top_frame; |
| 389 replacement_text_top_frame.push_back( | 424 replacement_text_top_frame.push_back( |
| 390 make_pair("REPLACE_WITH_FRAME_LEFT_PATH", frame_left_path)); | 425 make_pair("REPLACE_WITH_FRAME_LEFT_PATH", frame_left_path)); |
| 391 return net::SpawnedTestServer::GetFilePathWithReplacements( | 426 return net::SpawnedTestServer::GetFilePathWithReplacements( |
| 392 "files/ssl/top_frame.html", | 427 "files/ssl/top_frame.html", |
| 393 replacement_text_top_frame, | 428 replacement_text_top_frame, |
| 394 top_frame_path); | 429 top_frame_path); |
| 395 } | 430 } |
| 396 | 431 |
| 397 static bool GetPageWithUnsafeWorkerPath( | 432 static bool GetPageWithUnsafeWorkerPath( |
| 398 const net::SpawnedTestServer& expired_https_server, | 433 const net::SpawnedTestServer& https_server, |
| 399 std::string* page_with_unsafe_worker_path) { | 434 std::string* page_with_unsafe_worker_path) { |
| 400 // Get the "imported.js" URL from the expired https server and | 435 // Get the "imported.js" URL from the expired https server and |
| 401 // substitute it into the unsafe_worker.js file. | 436 // substitute it into the unsafe_worker.js file. |
| 402 GURL imported_js_url = expired_https_server.GetURL("files/ssl/imported.js"); | 437 GURL imported_js_url = https_server.GetURL("files/ssl/imported.js"); |
| 403 std::vector<net::SpawnedTestServer::StringPair> | 438 std::vector<net::SpawnedTestServer::StringPair> |
| 404 replacement_text_for_unsafe_worker; | 439 replacement_text_for_unsafe_worker; |
| 405 replacement_text_for_unsafe_worker.push_back( | 440 replacement_text_for_unsafe_worker.push_back( |
| 406 make_pair("REPLACE_WITH_IMPORTED_JS_URL", imported_js_url.spec())); | 441 make_pair("REPLACE_WITH_IMPORTED_JS_URL", imported_js_url.spec())); |
| 407 std::string unsafe_worker_path; | 442 std::string unsafe_worker_path; |
| 408 if (!net::SpawnedTestServer::GetFilePathWithReplacements( | 443 if (!net::SpawnedTestServer::GetFilePathWithReplacements( |
| 409 "unsafe_worker.js", | 444 "unsafe_worker.js", |
| 410 replacement_text_for_unsafe_worker, | 445 replacement_text_for_unsafe_worker, |
| 411 &unsafe_worker_path)) | 446 &unsafe_worker_path)) |
| 412 return false; | 447 return false; |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 &page_with_unsafe_worker_path)); | 1941 &page_with_unsafe_worker_path)); |
| 1907 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( | 1942 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( |
| 1908 page_with_unsafe_worker_path)); | 1943 page_with_unsafe_worker_path)); |
| 1909 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1944 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1910 // Expect Worker not to load insecure content. | 1945 // Expect Worker not to load insecure content. |
| 1911 CheckWorkerLoadResult(tab, false); | 1946 CheckWorkerLoadResult(tab, false); |
| 1912 // The bad content is filtered, expect the state to be authenticated. | 1947 // The bad content is filtered, expect the state to be authenticated. |
| 1913 CheckAuthenticatedState(tab, AuthState::NONE); | 1948 CheckAuthenticatedState(tab, AuthState::NONE); |
| 1914 } | 1949 } |
| 1915 | 1950 |
| 1916 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorker) { | 1951 // This test, and the related test TestUnsafeContentsWithUserException, verify |
| 1952 // that if unsafe content is loaded but the host of that unsafe content has a |
| 1953 // user exception, the content runs and the security style remains |
| 1954 // authenticated. This is not necessarily the behavior that should exist, but it |
| 1955 // is verification that it does behave that way. See https://crbug.com/477868 |
| 1956 // for more inforamtion on this. |
| 1957 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerWithUserException) { |
| 1917 ASSERT_TRUE(https_server_.Start()); | 1958 ASSERT_TRUE(https_server_.Start()); |
| 1918 ASSERT_TRUE(https_server_expired_.Start()); | 1959 // Note that it is necessary to user https_server_mismatched_ here over the |
| 1960 // other invalid cert servers. This is because the test relies on the two |
| 1961 // servers having different hosts since SSL exceptions are per-host, not per |
| 1962 // origin, and https_server_mismatched_ uses 'localhost' rather than |
| 1963 // '127.0.0.1'. |
| 1964 ASSERT_TRUE(https_server_mismatched_.Start()); |
| 1919 | 1965 |
| 1920 // Navigate to an unsafe site. Proceed with interstitial page to indicate | 1966 // Navigate to an unsafe site. Proceed with interstitial page to indicate |
| 1921 // the user approves the bad certificate. | 1967 // the user approves the bad certificate. |
| 1922 ui_test_utils::NavigateToURL(browser(), | 1968 ui_test_utils::NavigateToURL( |
| 1923 https_server_expired_.GetURL("files/ssl/blank_page.html")); | 1969 browser(), https_server_mismatched_.GetURL("files/ssl/blank_page.html")); |
| 1924 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1970 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1925 CheckAuthenticationBrokenState( | 1971 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
| 1926 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1972 AuthState::SHOWING_INTERSTITIAL); |
| 1927 ProceedThroughInterstitial(tab); | 1973 ProceedThroughInterstitial(tab); |
| 1928 CheckAuthenticationBrokenState( | 1974 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
| 1929 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 1975 AuthState::NONE); |
| 1930 | 1976 |
| 1931 // Navigate to safe page that has Worker loading unsafe content. | 1977 // Navigate to safe page that has Worker loading unsafe content. |
| 1932 // Expect content to load but be marked as auth broken due to running insecure | 1978 // Expect content to load but be marked as auth broken due to running insecure |
| 1933 // content. | 1979 // content. |
| 1934 std::string page_with_unsafe_worker_path; | 1980 std::string page_with_unsafe_worker_path; |
| 1935 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_expired_, | 1981 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_mismatched_, |
| 1936 &page_with_unsafe_worker_path)); | 1982 &page_with_unsafe_worker_path)); |
| 1937 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( | 1983 ui_test_utils::NavigateToURL( |
| 1938 page_with_unsafe_worker_path)); | 1984 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); |
| 1939 CheckWorkerLoadResult(tab, true); // Worker loads insecure content | 1985 CheckWorkerLoadResult(tab, true); // Worker loads insecure content |
| 1940 CheckAuthenticationBrokenState( | 1986 CheckAuthenticatedState(tab, CertError::NONE); |
| 1941 tab, CertError::NONE, AuthState::RAN_INSECURE_CONTENT); | 1987 } |
| 1988 |
| 1989 // Visits a page with unsafe content and makes sure that if a user exception to |
| 1990 // the certificate error is present, the image is loaded and script executes. |
| 1991 // |
| 1992 // See the comment above SSLUITest.TestUnsafeContentsInWorkerWithUserException |
| 1993 // for a discussion about the desired behavior. |
| 1994 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { |
| 1995 ASSERT_TRUE(https_server_.Start()); |
| 1996 // Note that it is necessary to user https_server_mismatched_ here over the |
| 1997 // other invalid cert servers. This is because the test relies on the two |
| 1998 // servers having different hosts since SSL exceptions are per-host, not per |
| 1999 // origin, and https_server_mismatched_ uses 'localhost' rather than |
| 2000 // '127.0.0.1'. |
| 2001 ASSERT_TRUE(https_server_mismatched_.Start()); |
| 2002 |
| 2003 // Navigate to an unsafe site. Proceed with interstitial page to indicate |
| 2004 // the user approves the bad certificate. |
| 2005 ui_test_utils::NavigateToURL( |
| 2006 browser(), https_server_mismatched_.GetURL("files/ssl/blank_page.html")); |
| 2007 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2008 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
| 2009 AuthState::SHOWING_INTERSTITIAL); |
| 2010 ProceedThroughInterstitial(tab); |
| 2011 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
| 2012 AuthState::NONE); |
| 2013 |
| 2014 std::string replacement_path; |
| 2015 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
| 2016 "files/ssl/page_with_unsafe_contents.html", |
| 2017 https_server_mismatched_.host_port_pair(), &replacement_path)); |
| 2018 ui_test_utils::NavigateToURL(browser(), |
| 2019 https_server_.GetURL(replacement_path)); |
| 2020 |
| 2021 // When the bad content is filtered, the state is expected to be |
| 2022 // authenticated. |
| 2023 CheckAuthenticatedState(tab, AuthState::NONE); |
| 2024 |
| 2025 int img_width; |
| 2026 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( |
| 2027 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); |
| 2028 // In order to check that the image was loaded, we check its width. |
| 2029 // The actual image (Google logo) is 114 pixels wide, so we assume a good |
| 2030 // image is greater than 100. |
| 2031 EXPECT_GT(img_width, 100); |
| 2032 |
| 2033 bool js_result = false; |
| 2034 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 2035 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); |
| 2036 EXPECT_TRUE(js_result); |
| 2037 CheckAuthenticatedState(tab, CertError::NONE); |
| 1942 } | 2038 } |
| 1943 | 2039 |
| 1944 // Test that when the browser blocks displaying insecure content (images), the | 2040 // Test that when the browser blocks displaying insecure content (images), the |
| 1945 // indicator shows a secure page, because the blocking made the otherwise | 2041 // indicator shows a secure page, because the blocking made the otherwise |
| 1946 // unsafe page safe (the notification of this state is handled by other means). | 2042 // unsafe page safe (the notification of this state is handled by other means). |
| 1947 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureImage) { | 2043 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureImage) { |
| 1948 ASSERT_TRUE(test_server()->Start()); | 2044 ASSERT_TRUE(test_server()->Start()); |
| 1949 ASSERT_TRUE(https_server_.Start()); | 2045 ASSERT_TRUE(https_server_.Start()); |
| 1950 | 2046 |
| 1951 std::string replacement_path; | 2047 std::string replacement_path; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 ui::PAGE_TRANSITION_TYPED); | 2218 ui::PAGE_TRANSITION_TYPED); |
| 2123 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 2219 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 2124 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 2220 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 2125 EXPECT_EQ(tab, browser()->tab_strip_model()->GetWebContentsAt(1)); | 2221 EXPECT_EQ(tab, browser()->tab_strip_model()->GetWebContentsAt(1)); |
| 2126 EXPECT_FALSE(tab->GetRenderWidgetHostView()->IsShowing()); | 2222 EXPECT_FALSE(tab->GetRenderWidgetHostView()->IsShowing()); |
| 2127 | 2223 |
| 2128 browser()->tab_strip_model()->ActivateTabAt(1, true); | 2224 browser()->tab_strip_model()->ActivateTabAt(1, true); |
| 2129 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); | 2225 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
| 2130 } | 2226 } |
| 2131 | 2227 |
| 2228 // Verifies that if a bad certificate is seen for a host and the user proceeds |
| 2229 // through the interstitial, the decision to proceed is initially remembered. |
| 2230 // However, if this is followed by another visit, and a good certificate |
| 2231 // is seen for the same host, the original exception is forgotten. |
| 2232 IN_PROC_BROWSER_TEST_F(SSLUITest, BadCertFollowedByGoodCert) { |
| 2233 ASSERT_TRUE(https_server_.Start()); |
| 2234 std::string https_server_host = |
| 2235 https_server_.GetURL("files/ssl/google.html").host(); |
| 2236 |
| 2237 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2238 net::TestRootCerts* root_certs = net::TestRootCerts::GetInstance(); |
| 2239 |
| 2240 ASSERT_TRUE(root_certs); |
| 2241 root_certs->Clear(); |
| 2242 |
| 2243 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 2244 ChromeSSLHostStateDelegate* state = |
| 2245 reinterpret_cast<ChromeSSLHostStateDelegate*>( |
| 2246 profile->GetSSLHostStateDelegate()); |
| 2247 |
| 2248 ui_test_utils::NavigateToURL(browser(), |
| 2249 https_server_.GetURL("files/ssl/google.html")); |
| 2250 |
| 2251 ProceedThroughInterstitial(tab); |
| 2252 EXPECT_TRUE(state->HasAllowException(https_server_host)); |
| 2253 |
| 2254 ASSERT_TRUE(https_server_.LoadTestRootCert()); |
| 2255 RootCertsChanged(tab); |
| 2256 ui_test_utils::NavigateToURL(browser(), |
| 2257 https_server_.GetURL("files/ssl/google.html")); |
| 2258 ASSERT_FALSE(tab->GetInterstitialPage()); |
| 2259 EXPECT_FALSE(state->HasAllowException(https_server_host)); |
| 2260 } |
| 2261 |
| 2132 class SSLBlockingPageIDNTest : public SecurityInterstitialIDNTest { | 2262 class SSLBlockingPageIDNTest : public SecurityInterstitialIDNTest { |
| 2133 protected: | 2263 protected: |
| 2134 // SecurityInterstitialIDNTest implementation | 2264 // SecurityInterstitialIDNTest implementation |
| 2135 SecurityInterstitialPage* CreateInterstitial( | 2265 SecurityInterstitialPage* CreateInterstitial( |
| 2136 content::WebContents* contents, | 2266 content::WebContents* contents, |
| 2137 const GURL& request_url) const override { | 2267 const GURL& request_url) const override { |
| 2138 net::SSLInfo ssl_info; | 2268 net::SSLInfo ssl_info; |
| 2139 ssl_info.cert = new net::X509Certificate( | 2269 ssl_info.cert = new net::X509Certificate( |
| 2140 request_url.host(), "CA", base::Time::Max(), base::Time::Max()); | 2270 request_url.host(), "CA", base::Time::Max(), base::Time::Max()); |
| 2141 return new SSLBlockingPage( | 2271 return new SSLBlockingPage( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2152 | 2282 |
| 2153 // Visit a page over https that contains a frame with a redirect. | 2283 // Visit a page over https that contains a frame with a redirect. |
| 2154 | 2284 |
| 2155 // XMLHttpRequest insecure content in synchronous mode. | 2285 // XMLHttpRequest insecure content in synchronous mode. |
| 2156 | 2286 |
| 2157 // XMLHttpRequest insecure content in asynchronous mode. | 2287 // XMLHttpRequest insecure content in asynchronous mode. |
| 2158 | 2288 |
| 2159 // XMLHttpRequest over bad ssl in synchronous mode. | 2289 // XMLHttpRequest over bad ssl in synchronous mode. |
| 2160 | 2290 |
| 2161 // XMLHttpRequest over OK ssl in synchronous mode. | 2291 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |