Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/core/browser/autofill_metrics.h" | 5 #include "components/autofill/core/browser/autofill_metrics.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 4205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4216 // available for all forms. | 4216 // available for all forms. |
| 4217 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 4217 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
| 4218 } | 4218 } |
| 4219 | 4219 |
| 4220 // Test that the Form-Not-Secure warning user action is recorded. | 4220 // Test that the Form-Not-Secure warning user action is recorded. |
| 4221 TEST_F(AutofillMetricsTest, ShowHttpNotSecureExplanationUserAction) { | 4221 TEST_F(AutofillMetricsTest, ShowHttpNotSecureExplanationUserAction) { |
| 4222 base::UserActionTester user_action_tester; | 4222 base::UserActionTester user_action_tester; |
| 4223 external_delegate_->DidAcceptSuggestion( | 4223 external_delegate_->DidAcceptSuggestion( |
| 4224 ASCIIToUTF16("Test"), POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE, 0); | 4224 ASCIIToUTF16("Test"), POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE, 0); |
| 4225 EXPECT_EQ(1, user_action_tester.GetActionCount( | 4225 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 4226 "Autofill_ShowedHttpNotSecureExplanation")); | 4226 "Autofill_ShowedHttpNotSecureExplanation")); |
| 4227 } | |
| 4228 | |
| 4229 // Tests that credit card form submissions are logged specially when the form is | |
| 4230 // on a non-secure page. | |
| 4231 TEST_F(AutofillMetricsTest, NonsecureCreditCardForm) { | |
| 4232 personal_data_->RecreateCreditCards( | |
| 4233 true /* include_local_credit_card */, | |
| 4234 false /* include_masked_server_credit_card */, | |
| 4235 false /* include_full_server_credit_card */); | |
| 4236 | |
| 4237 // Set up our form data. | |
| 4238 FormData form; | |
| 4239 form.name = ASCIIToUTF16("TestForm"); | |
| 4240 form.origin = GURL("http://example.com/form.html"); | |
| 4241 form.action = GURL("http://example.com/submit.html"); | |
| 4242 | |
| 4243 FormFieldData field; | |
| 4244 std::vector<ServerFieldType> field_types; | |
| 4245 test::CreateTestFormField("Name on card", "cc-name", "", "text", &field); | |
| 4246 form.fields.push_back(field); | |
| 4247 field_types.push_back(CREDIT_CARD_NAME_FULL); | |
| 4248 test::CreateTestFormField("Credit card", "card", "", "text", &field); | |
| 4249 form.fields.push_back(field); | |
| 4250 field_types.push_back(CREDIT_CARD_NUMBER); | |
| 4251 test::CreateTestFormField("Month", "card_month", "", "text", &field); | |
| 4252 form.fields.push_back(field); | |
| 4253 field_types.push_back(CREDIT_CARD_EXP_MONTH); | |
| 4254 | |
| 4255 // Simulate having seen this form on page load. | |
| 4256 // |form_structure| will be owned by |autofill_manager_|. | |
| 4257 autofill_manager_->AddSeenForm(form, field_types, field_types); | |
| 4258 | |
| 4259 // Simulate an Autofill query on a credit card field. | |
| 4260 { | |
| 4261 base::UserActionTester user_action_tester; | |
| 4262 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | |
| 4263 EXPECT_EQ(1, user_action_tester.GetActionCount( | |
| 4264 "Autofill_PolledCreditCardSuggestions")); | |
| 4265 } | |
| 4266 | |
| 4267 // Simulate submitting the credit card form. | |
| 4268 { | |
| 4269 base::HistogramTester histograms; | |
| 4270 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | |
| 4271 histograms.ExpectBucketCount( | |
| 4272 "Autofill.FormEvents.CreditCard.OnNonsecurePage", | |
| 4273 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | |
|
sebsg
2017/02/03 19:28:34
Can you also make sure that the normal histograms
estark
2017/02/04 02:16:13
Done.
| |
| 4274 } | |
| 4275 } | |
| 4276 | |
| 4277 // Tests that credit card form submissions are *not* logged specially when the | |
| 4278 // form is *not* on a non-secure page. | |
| 4279 TEST_F(AutofillMetricsTest, | |
| 4280 NonsecureCreditCardFormMetricsNotRecordedOnSecurePage) { | |
| 4281 autofill_client_.set_main_url_secure(); | |
| 4282 personal_data_->RecreateCreditCards( | |
| 4283 true /* include_local_credit_card */, | |
| 4284 false /* include_masked_server_credit_card */, | |
| 4285 false /* include_full_server_credit_card */); | |
| 4286 | |
| 4287 // Set up our form data. | |
| 4288 FormData form; | |
| 4289 form.name = ASCIIToUTF16("TestForm"); | |
| 4290 form.origin = GURL("https://example.com/form.html"); | |
| 4291 form.action = GURL("http://example.com/submit.html"); | |
| 4292 | |
| 4293 FormFieldData field; | |
| 4294 std::vector<ServerFieldType> field_types; | |
| 4295 test::CreateTestFormField("Name on card", "cc-name", "", "text", &field); | |
| 4296 form.fields.push_back(field); | |
| 4297 field_types.push_back(CREDIT_CARD_NAME_FULL); | |
| 4298 test::CreateTestFormField("Credit card", "card", "", "text", &field); | |
| 4299 form.fields.push_back(field); | |
| 4300 field_types.push_back(CREDIT_CARD_NUMBER); | |
| 4301 test::CreateTestFormField("Month", "card_month", "", "text", &field); | |
| 4302 form.fields.push_back(field); | |
| 4303 field_types.push_back(CREDIT_CARD_EXP_MONTH); | |
| 4304 | |
| 4305 // Simulate having seen this form on page load. | |
| 4306 // |form_structure| will be owned by |autofill_manager_|. | |
| 4307 autofill_manager_->AddSeenForm(form, field_types, field_types); | |
| 4308 | |
| 4309 // Simulate an Autofill query on a credit card field. | |
| 4310 { | |
| 4311 base::UserActionTester user_action_tester; | |
| 4312 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | |
| 4313 EXPECT_EQ(1, user_action_tester.GetActionCount( | |
| 4314 "Autofill_PolledCreditCardSuggestions")); | |
| 4315 } | |
| 4316 | |
| 4317 // Simulate submitting the credit card form. | |
| 4318 { | |
| 4319 base::HistogramTester histograms; | |
| 4320 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | |
| 4321 histograms.ExpectBucketCount( | |
| 4322 "Autofill.FormEvents.CreditCard", | |
| 4323 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | |
| 4324 histograms.ExpectBucketCount( | |
| 4325 "Autofill.FormEvents.CreditCard", | |
| 4326 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | |
|
sebsg
2017/02/03 19:28:34
Can you add a check to make sure that nothing was
estark
2017/02/04 02:16:13
Done.
| |
| 4327 } | |
| 4227 } | 4328 } |
| 4228 | 4329 |
| 4229 } // namespace autofill | 4330 } // namespace autofill |
| OLD | NEW |