| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/security_state/security_state_model.h" | 5 #include "components/security_state/security_state_model.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 client.UseHttpUrl(); | 297 client.UseHttpUrl(); |
| 298 SecurityStateModel model; | 298 SecurityStateModel model; |
| 299 model.SetClient(&client); | 299 model.SetClient(&client); |
| 300 SecurityStateModel::SecurityInfo security_info; | 300 SecurityStateModel::SecurityInfo security_info; |
| 301 model.GetSecurityInfo(&security_info); | 301 model.GetSecurityInfo(&security_info); |
| 302 EXPECT_FALSE(security_info.displayed_private_user_data_input_on_http); | 302 EXPECT_FALSE(security_info.displayed_private_user_data_input_on_http); |
| 303 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level); | 303 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level); |
| 304 } | 304 } |
| 305 | 305 |
| 306 // Tests that SSL.MarkHttpAsStatus histogram is updated when security state is | 306 // Tests that SSL.MarkHttpAsStatus histogram is updated when security state is |
| 307 // computed for a page containing a password field on HTTP. | 307 // computed for a page. |
| 308 TEST(SecurityStateModelTest, MarkHttpAsStatusHistogram) { | 308 TEST(SecurityStateModelTest, MarkHttpAsStatusHistogram) { |
| 309 const char* kHistogramName = "SSL.MarkHttpAsStatus"; | 309 const char* kHistogramName = "SSL.MarkHttpAsStatus"; |
| 310 base::HistogramTester histograms; | 310 base::HistogramTester histograms; |
| 311 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 311 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 312 switches::kMarkHttpAs, switches::kMarkHttpWithPasswordsOrCcWithChip); | 312 switches::kMarkHttpAs, switches::kMarkHttpWithPasswordsOrCcWithChip); |
| 313 TestSecurityStateModelClient client; | 313 TestSecurityStateModelClient client; |
| 314 client.UseHttpUrl(); | 314 client.UseHttpUrl(); |
| 315 SecurityStateModel model; | 315 SecurityStateModel model; |
| 316 model.SetClient(&client); | 316 model.SetClient(&client); |
| 317 |
| 318 // Ensure histogram recorded correctly when a non-secure password input is |
| 319 // found on the page. |
| 317 client.set_displayed_password_field_on_http(true); | 320 client.set_displayed_password_field_on_http(true); |
| 318 SecurityStateModel::SecurityInfo security_info; | 321 SecurityStateModel::SecurityInfo security_info; |
| 319 histograms.ExpectTotalCount(kHistogramName, 0); | 322 histograms.ExpectTotalCount(kHistogramName, 0); |
| 320 model.GetSecurityInfo(&security_info); | 323 model.GetSecurityInfo(&security_info); |
| 321 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 1); | 324 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 1); |
| 325 |
| 326 // Ensure histogram recorded correctly even without a password input. |
| 327 client.set_displayed_password_field_on_http(false); |
| 328 model.GetSecurityInfo(&security_info); |
| 329 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2); |
| 322 } | 330 } |
| 323 | 331 |
| 324 } // namespace | 332 } // namespace |
| 325 | 333 |
| 326 } // namespace security_state | 334 } // namespace security_state |
| OLD | NEW |