Index: chrome/browser/ssl/ssl_browser_tests.cc |
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc |
index ee444e10b774b24f561bb50bf656c51b20075a06..272faa04962f6ff2bb6c14c879d6033350eeb6ed 100644 |
--- a/chrome/browser/ssl/ssl_browser_tests.cc |
+++ b/chrome/browser/ssl/ssl_browser_tests.cc |
@@ -68,6 +68,7 @@ |
#include "components/security_state/core/security_state.h" |
#include "components/security_state/core/switches.h" |
#include "components/ssl_errors/error_classification.h" |
+#include "components/strings/grit/components_strings.h" |
#include "components/variations/variations_associated_data.h" |
#include "components/variations/variations_switches.h" |
#include "components/web_modal/web_contents_modal_dialog_manager.h" |
@@ -114,6 +115,7 @@ |
#include "net/url_request/url_request_filter.h" |
#include "net/url_request/url_request_job.h" |
#include "net/url_request/url_request_test_util.h" |
+#include "ui/base/l10n/l10n_util.h" |
#if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
#include "chrome/browser/ssl/captive_portal_blocking_page.h" |
@@ -3933,7 +3935,7 @@ class SSLBlockingPageIDNTest : public SecurityInterstitialIDNTest { |
net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); |
return SSLBlockingPage::Create( |
contents, net::ERR_CERT_CONTAINS_ERRORS, ssl_info, request_url, 0, |
- base::Time::NowFromSystemTime(), nullptr, |
+ base::Time::NowFromSystemTime(), nullptr, false /* is superfish */, |
base::Callback<void(content::CertificateRequestResultType)>()); |
} |
}; |
@@ -4752,6 +4754,57 @@ IN_PROC_BROWSER_TEST_F(SuperfishSSLUITest, NoSuperfishRecorded) { |
false, 1); |
} |
+// Tests that the Superfish interstitial is shown when the Finch feature is |
+// enabled and the Superfish certificate is present. |
+IN_PROC_BROWSER_TEST_F(SuperfishSSLUITest, SuperfishInterstitial) { |
+ base::test::ScopedFeatureList scoped_feature_list; |
+ scoped_feature_list.InitFromCommandLine("SuperfishInterstitial", |
+ std::string()); |
+ SetUpCertVerifier(true /* use superfish cert */); |
+ ui_test_utils::NavigateToURL(browser(), |
+ https_server_.GetURL("/ssl/google.html")); |
+ content::WebContents* tab = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::WaitForInterstitialAttach(tab); |
+ InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
+ ASSERT_TRUE(interstitial_page); |
+ EXPECT_TRUE(WaitForRenderFrameReady(interstitial_page->GetMainFrame())); |
+ EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
+ interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
+ |
+ // Look for keywords on the page to check that the Superfish interstitial is |
+ // showing. |
+ std::string expected_title = |
meacer
2017/06/22 22:35:37
nit: const
estark
2017/06/22 23:17:48
Done.
|
+ l10n_util::GetStringUTF8(IDS_SSL_SUPERFISH_HEADING); |
+ EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText( |
estark
2017/06/22 22:01:05
I spent like an hour trying to rewrite this method
|
+ interstitial_page, expected_title)); |
+} |
+ |
+// Tests that the Superfish interstitial is not shown when the Finch feature is |
+// disabled. |
+IN_PROC_BROWSER_TEST_F(SuperfishSSLUITest, SuperfishInterstitialDisabled) { |
+ base::test::ScopedFeatureList scoped_feature_list; |
+ scoped_feature_list.InitFromCommandLine(std::string(), |
+ "SuperfishInterstitial"); |
+ SetUpCertVerifier(true /* use superfish cert */); |
+ ui_test_utils::NavigateToURL(browser(), |
+ https_server_.GetURL("/ssl/google.html")); |
+ content::WebContents* tab = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::WaitForInterstitialAttach(tab); |
+ InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
+ ASSERT_TRUE(interstitial_page); |
+ EXPECT_TRUE(WaitForRenderFrameReady(interstitial_page->GetMainFrame())); |
+ EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
+ interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
+ |
+ // Look for keywords on the page to check that the Superfish interstitial is |
+ // not showing. |
+ std::string expected_title = l10n_util::GetStringUTF8(IDS_SSL_V2_HEADING); |
meacer
2017/06/22 22:35:37
const
estark
2017/06/22 23:17:48
Done.
|
+ EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText( |
+ interstitial_page, expected_title)); |
+} |
+ |
// TODO(jcampan): more tests to do below. |
// Visit a page over https that contains a frame with a redirect. |