Chromium Code Reviews| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 4962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4973 base::HistogramTester histograms; | 4973 base::HistogramTester histograms; |
| 4974 ui_test_utils::NavigateToURL(browser(), | 4974 ui_test_utils::NavigateToURL(browser(), |
| 4975 https_server_.GetURL("/ssl/google.html")); | 4975 https_server_.GetURL("/ssl/google.html")); |
| 4976 histograms.ExpectUniqueSample("interstitial.ssl_error_handler.superfish", | 4976 histograms.ExpectUniqueSample("interstitial.ssl_error_handler.superfish", |
| 4977 false, 1); | 4977 false, 1); |
| 4978 } | 4978 } |
| 4979 | 4979 |
| 4980 // Tests that the Superfish interstitial is shown when the Finch feature is | 4980 // Tests that the Superfish interstitial is shown when the Finch feature is |
| 4981 // enabled and the Superfish certificate is present. | 4981 // enabled and the Superfish certificate is present. |
| 4982 IN_PROC_BROWSER_TEST_F(SuperfishSSLUITest, SuperfishInterstitial) { | 4982 IN_PROC_BROWSER_TEST_F(SuperfishSSLUITest, SuperfishInterstitial) { |
| 4983 base::HistogramTester histograms; | |
| 4984 const std::string decision_histogram = "interstitial.superfish.decision"; | |
|
meacer
2017/06/30 22:53:29
nit: const char kDecisionHistogram[] instead? Same
estark
2017/06/30 23:20:30
Done.
| |
| 4985 const std::string interaction_histogram = | |
| 4986 "interstitial.superfish.interaction"; | |
| 4987 | |
| 4983 base::test::ScopedFeatureList scoped_feature_list; | 4988 base::test::ScopedFeatureList scoped_feature_list; |
| 4984 scoped_feature_list.InitFromCommandLine("SuperfishInterstitial", | 4989 scoped_feature_list.InitFromCommandLine("SuperfishInterstitial", |
| 4985 std::string()); | 4990 std::string()); |
| 4986 SetUpCertVerifier(true /* use superfish cert */); | 4991 SetUpCertVerifier(true /* use superfish cert */); |
| 4987 ui_test_utils::NavigateToURL(browser(), | 4992 ui_test_utils::NavigateToURL(browser(), |
| 4988 https_server_.GetURL("/ssl/google.html")); | 4993 https_server_.GetURL("/ssl/google.html")); |
| 4989 content::WebContents* tab = | 4994 content::WebContents* tab = |
| 4990 browser()->tab_strip_model()->GetActiveWebContents(); | 4995 browser()->tab_strip_model()->GetActiveWebContents(); |
| 4991 content::WaitForInterstitialAttach(tab); | 4996 content::WaitForInterstitialAttach(tab); |
| 4992 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 4997 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
| 4993 ASSERT_TRUE(interstitial_page); | 4998 ASSERT_TRUE(interstitial_page); |
| 4994 EXPECT_TRUE(WaitForRenderFrameReady(interstitial_page->GetMainFrame())); | 4999 EXPECT_TRUE(WaitForRenderFrameReady(interstitial_page->GetMainFrame())); |
| 4995 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 5000 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
| 4996 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 5001 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
| 4997 | 5002 |
| 4998 // Look for keywords on the page to check that the Superfish interstitial is | 5003 // Look for keywords on the page to check that the Superfish interstitial is |
| 4999 // showing. | 5004 // showing. |
| 5000 const std::string expected_title = | 5005 const std::string expected_title = |
| 5001 l10n_util::GetStringUTF8(IDS_SSL_SUPERFISH_HEADING); | 5006 l10n_util::GetStringUTF8(IDS_SSL_SUPERFISH_HEADING); |
| 5002 EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText( | 5007 EXPECT_TRUE(chrome_browser_interstitials::IsInterstitialDisplayingText( |
| 5003 interstitial_page, expected_title)); | 5008 interstitial_page, expected_title)); |
| 5009 | |
| 5010 // Check that the correct histograms were recorded. | |
| 5011 histograms.ExpectTotalCount(decision_histogram, 1); | |
| 5012 histograms.ExpectBucketCount(decision_histogram, | |
| 5013 security_interstitials::MetricsHelper::SHOW, 1); | |
| 5014 histograms.ExpectTotalCount(interaction_histogram, 1); | |
| 5015 histograms.ExpectBucketCount( | |
| 5016 interaction_histogram, | |
| 5017 security_interstitials::MetricsHelper::TOTAL_VISITS, 1); | |
| 5004 } | 5018 } |
| 5005 | 5019 |
| 5006 // Tests that the Superfish interstitial is not shown when the Finch feature is | 5020 // Tests that the Superfish interstitial is not shown when the Finch feature is |
| 5007 // disabled. | 5021 // disabled. |
| 5008 IN_PROC_BROWSER_TEST_F(SuperfishSSLUITest, SuperfishInterstitialDisabled) { | 5022 IN_PROC_BROWSER_TEST_F(SuperfishSSLUITest, SuperfishInterstitialDisabled) { |
| 5009 base::test::ScopedFeatureList scoped_feature_list; | 5023 base::test::ScopedFeatureList scoped_feature_list; |
| 5010 scoped_feature_list.InitFromCommandLine(std::string(), | 5024 scoped_feature_list.InitFromCommandLine(std::string(), |
| 5011 "SuperfishInterstitial"); | 5025 "SuperfishInterstitial"); |
| 5012 SetUpCertVerifier(true /* use superfish cert */); | 5026 SetUpCertVerifier(true /* use superfish cert */); |
| 5013 ui_test_utils::NavigateToURL(browser(), | 5027 ui_test_utils::NavigateToURL(browser(), |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 5033 | 5047 |
| 5034 // Visit a page over https that contains a frame with a redirect. | 5048 // Visit a page over https that contains a frame with a redirect. |
| 5035 | 5049 |
| 5036 // XMLHttpRequest insecure content in synchronous mode. | 5050 // XMLHttpRequest insecure content in synchronous mode. |
| 5037 | 5051 |
| 5038 // XMLHttpRequest insecure content in asynchronous mode. | 5052 // XMLHttpRequest insecure content in asynchronous mode. |
| 5039 | 5053 |
| 5040 // XMLHttpRequest over bad ssl in synchronous mode. | 5054 // XMLHttpRequest over bad ssl in synchronous mode. |
| 5041 | 5055 |
| 5042 // XMLHttpRequest over OK ssl in synchronous mode. | 5056 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |