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

Unified Diff: chrome/browser/ssl/chrome_security_state_model_client_unittest.cc

Issue 2451293002: Add a histogram for each time the HTTP Bad UI is shown (Closed)
Patch Set: Update VisibleSSLStateChange to VisibleSecurityStateChange 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ssl/chrome_security_state_model_client.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/chrome_security_state_model_client_unittest.cc
diff --git a/chrome/browser/ssl/chrome_security_state_model_client_unittest.cc b/chrome/browser/ssl/chrome_security_state_model_client_unittest.cc
index 9a50d7bc05b7e937f30a2843530afc2399932d46..711c17cfcf9155fadbad38030854769bb2c2b182 100644
--- a/chrome/browser/ssl/chrome_security_state_model_client_unittest.cc
+++ b/chrome/browser/ssl/chrome_security_state_model_client_unittest.cc
@@ -4,7 +4,11 @@
#include "chrome/browser/ssl/chrome_security_state_model_client.h"
+#include "base/command_line.h"
+#include "base/test/histogram_tester.h"
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/security_state/security_state_model.h"
+#include "components/security_state/switches.h"
#include "content/public/browser/security_style_explanation.h"
#include "content/public/browser/security_style_explanations.h"
#include "net/cert/cert_status_flags.h"
@@ -14,6 +18,9 @@
namespace {
+const char kHTTPBadHistogram[] =
+ "Security.HTTPBad.UserWarnedAboutSensitiveInput";
+
// Tests that SecurityInfo flags for subresources with certificate
// errors are reflected in the SecurityStyleExplanations produced by
// ChromeSecurityStateModelClient.
@@ -242,4 +249,80 @@ TEST(ChromeSecurityStateModelClientTest, HTTPWarningInFuture) {
EXPECT_EQ(1u, explanations.info_explanations.size());
}
+class ChromeSecurityStateModelClientHistogramTest
+ : public ChromeRenderViewHostTestHarness {
+ public:
+ ChromeSecurityStateModelClientHistogramTest() {}
+ ~ChromeSecurityStateModelClientHistogramTest() override {}
+
+ void SetUp() override {
+ ChromeRenderViewHostTestHarness::SetUp();
+
+ ChromeSecurityStateModelClient::CreateForWebContents(web_contents());
+ client_ = ChromeSecurityStateModelClient::FromWebContents(web_contents());
+ navigate_to_http();
+ }
+
+ protected:
+ ChromeSecurityStateModelClient* client() { return client_; }
+
+ void signal_password() {
+ web_contents()->OnPasswordInputShownOnHttp();
+ client_->VisibleSecurityStateChanged();
+ }
+
+ void navigate_to_http() { NavigateAndCommit(GURL("http://example.test")); }
+
+ private:
+ ChromeSecurityStateModelClient* client_;
+ DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClientHistogramTest);
+};
+
+// Tests that UMA logs the omnibox warning when security level is
+// HTTP_SHOW_WARNING.
+TEST_F(ChromeSecurityStateModelClientHistogramTest,
+ HTTPOmniboxWarningHistogram) {
+ // Show Warning Chip.
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ security_state::switches::kMarkHttpAs,
+ security_state::switches::kMarkHttpWithPasswordsOrCcWithChip);
+
+ base::HistogramTester histograms;
+ signal_password();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
+
+ // Fire again and ensure no sample is recorded.
+ signal_password();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
+
+ // Navigate to a new page and ensure a sample is recorded.
+ navigate_to_http();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
+ signal_password();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 2);
+}
+
+// Tests that UMA logs the console warning when security level is NONE.
+TEST_F(ChromeSecurityStateModelClientHistogramTest,
+ HTTPConsoleWarningHistogram) {
+ // Show Neutral for HTTP
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ security_state::switches::kMarkHttpAs,
+ security_state::switches::kMarkHttpAsNeutral);
+
+ base::HistogramTester histograms;
+ signal_password();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
+
+ // Fire again and ensure no sample is recorded.
+ signal_password();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
+
+ // Navigate to a new page and ensure a sample is recorded.
+ navigate_to_http();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
+ signal_password();
+ histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 2);
+}
+
} // namespace
« no previous file with comments | « chrome/browser/ssl/chrome_security_state_model_client.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698