| Index: chrome/browser/ui/browser_browsertest.cc
|
| diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
|
| index 43ca35392af70c3aa35e25a9a6f3b1be1c7afd72..59dad6a3b85cd400e99535f47ff19397d7ef0ad0 100644
|
| --- a/chrome/browser/ui/browser_browsertest.cc
|
| +++ b/chrome/browser/ui/browser_browsertest.cc
|
| @@ -384,7 +384,8 @@ class SecurityStyleTestObserver : public WebContentsObserver {
|
|
|
| // Check that |observer|'s latest event was for an expired certificate
|
| // and that it saw the proper SecurityStyle and explanations.
|
| -void CheckExpiredSecurityStyle(const SecurityStyleTestObserver& observer) {
|
| +void CheckBrokenSecurityStyle(const SecurityStyleTestObserver& observer,
|
| + int error) {
|
| EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN,
|
| observer.latest_security_style());
|
|
|
| @@ -397,8 +398,7 @@ void CheckExpiredSecurityStyle(const SecurityStyleTestObserver& observer) {
|
| EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR),
|
| expired_explanation.broken_explanations[0].summary);
|
|
|
| - base::string16 error_string =
|
| - base::UTF8ToUTF16(net::ErrorToString(net::ERR_CERT_DATE_INVALID));
|
| + base::string16 error_string = base::UTF8ToUTF16(net::ErrorToString(error));
|
| EXPECT_EQ(l10n_util::GetStringFUTF8(
|
| IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string),
|
| expired_explanation.broken_explanations[0].description);
|
| @@ -2942,14 +2942,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) {
|
| EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
|
| EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
|
|
|
| - // Visit a valid HTTPS url.
|
| - GURL valid_https_url(https_test_server.GetURL(std::string()));
|
| - ui_test_utils::NavigateToURL(browser(), valid_https_url);
|
| - EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
|
| - observer.latest_security_style());
|
| - EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
|
| - EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
|
| -
|
| // Visit an (otherwise valid) HTTPS page that displays mixed content.
|
| std::string replacement_path;
|
| ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
|
| @@ -2977,10 +2969,11 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) {
|
| // interstitial should fire.
|
| content::WaitForInterstitialAttach(web_contents);
|
| EXPECT_TRUE(web_contents->ShowingInterstitialPage());
|
| - CheckExpiredSecurityStyle(observer);
|
| + CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID);
|
|
|
| // Before clicking through, navigate to a different page, and then go
|
| // back to the interstitial.
|
| + GURL valid_https_url(https_test_server.GetURL(std::string()));
|
| ui_test_utils::NavigateToURL(browser(), valid_https_url);
|
| EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
|
| observer.latest_security_style());
|
| @@ -2992,16 +2985,76 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserver) {
|
| ui_test_utils::NavigateToURL(browser(), expired_url);
|
| content::WaitForInterstitialAttach(web_contents);
|
| EXPECT_TRUE(web_contents->ShowingInterstitialPage());
|
| - CheckExpiredSecurityStyle(observer);
|
| + CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID);
|
|
|
| // Since the next expected style is the same as the previous, clear
|
| // the observer (to make sure that the event fires twice and we don't
|
| // just see the previous event's style).
|
| observer.ClearLatestSecurityStyleAndExplanations();
|
|
|
| - // Other conditions cannot be tested after clicking through because
|
| - // once the interstitial is clicked through, all URLs for this host
|
| - // will remain in a broken state.
|
| + // Other conditions cannot be tested on this host after clicking
|
| + // through because once the interstitial is clicked through, all URLs
|
| + // for this host will remain in a broken state.
|
| + ProceedThroughInterstitial(web_contents);
|
| + CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID);
|
| +}
|
| +
|
| +// Visit a valid HTTPS page, then a broken HTTPS page, and then go back,
|
| +// and test that the observed security style matches.
|
| +IN_PROC_BROWSER_TEST_F(BrowserTest, SecurityStyleChangedObserverGoBack) {
|
| + net::SpawnedTestServer https_test_server(net::SpawnedTestServer::TYPE_HTTPS,
|
| + net::SpawnedTestServer::kLocalhost,
|
| + base::FilePath(kDocRoot));
|
| +
|
| + // Use a separate server to work around a mysterious SSL handshake
|
| + // timeout when both requests go to the same server. See
|
| + // crbug.com/515906.
|
| + net::SpawnedTestServer https_test_server_expired(
|
| + net::SpawnedTestServer::TYPE_HTTPS,
|
| + net::SpawnedTestServer::SSLOptions(
|
| + net::SpawnedTestServer::SSLOptions::CERT_EXPIRED),
|
| + base::FilePath(kDocRoot));
|
| +
|
| + ASSERT_TRUE(https_test_server.Start());
|
| + ASSERT_TRUE(https_test_server_expired.Start());
|
| +
|
| + content::WebContents* web_contents =
|
| + browser()->tab_strip_model()->GetActiveWebContents();
|
| + SecurityStyleTestObserver observer(web_contents);
|
| +
|
| + // Visit a valid HTTPS url.
|
| + GURL valid_https_url(https_test_server.GetURL(std::string()));
|
| + ui_test_utils::NavigateToURL(browser(), valid_https_url);
|
| + EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
|
| + observer.latest_security_style());
|
| + EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
|
| + EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
|
| +
|
| + // Navigate to a bad HTTPS page on a different host, and then click
|
| + // Back to verify that the previous good security style is seen again.
|
| + GURL expired_https_url(https_test_server_expired.GetURL(std::string()));
|
| + host_resolver()->AddRule("www.example_broken.test", "127.0.0.1");
|
| + GURL::Replacements replace_host;
|
| + replace_host.SetHostStr("www.example_broken.test");
|
| + GURL https_url_different_host =
|
| + expired_https_url.ReplaceComponents(replace_host);
|
| +
|
| + ui_test_utils::NavigateToURL(browser(), https_url_different_host);
|
| +
|
| + content::WaitForInterstitialAttach(web_contents);
|
| + EXPECT_TRUE(web_contents->ShowingInterstitialPage());
|
| + CheckBrokenSecurityStyle(observer, net::ERR_CERT_COMMON_NAME_INVALID);
|
| ProceedThroughInterstitial(web_contents);
|
| - CheckExpiredSecurityStyle(observer);
|
| + CheckBrokenSecurityStyle(observer, net::ERR_CERT_COMMON_NAME_INVALID);
|
| +
|
| + content::WindowedNotificationObserver back_nav_load_observer(
|
| + content::NOTIFICATION_LOAD_STOP,
|
| + content::Source<NavigationController>(&web_contents->GetController()));
|
| + chrome::GoBack(browser(), CURRENT_TAB);
|
| + back_nav_load_observer.Wait();
|
| +
|
| + EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
|
| + observer.latest_security_style());
|
| + EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size());
|
| + EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size());
|
| }
|
|
|