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 #import "ios/chrome/browser/autofill/autofill_controller.h" | 5 #import "ios/chrome/browser/autofill/autofill_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "components/infobars/core/infobar_manager.h" | 22 #include "components/infobars/core/infobar_manager.h" |
| 23 #include "components/keyed_service/core/service_access_type.h" | 23 #include "components/keyed_service/core/service_access_type.h" |
| 24 #import "ios/chrome/browser/autofill/autofill_agent.h" | 24 #import "ios/chrome/browser/autofill/autofill_agent.h" |
| 25 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" | 25 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" |
| 26 #import "ios/chrome/browser/autofill/form_suggestion_controller.h" | 26 #import "ios/chrome/browser/autofill/form_suggestion_controller.h" |
| 27 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 27 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 28 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" | 28 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
| 29 #import "ios/chrome/browser/ui/autofill/autofill_client_ios.h" | 29 #import "ios/chrome/browser/ui/autofill/autofill_client_ios.h" |
| 30 #import "ios/chrome/browser/web/chrome_web_test.h" | 30 #import "ios/chrome/browser/web/chrome_web_test.h" |
| 31 #include "ios/chrome/browser/web_data_service_factory.h" | 31 #include "ios/chrome/browser/web_data_service_factory.h" |
| 32 #import "ios/web/public/navigation_item.h" | |
| 33 #import "ios/web/public/navigation_manager.h" | |
| 32 #import "ios/web/public/web_state/web_state.h" | 34 #import "ios/web/public/web_state/web_state.h" |
| 35 #include "ios/web/public/ssl_status.h" | |
| 33 #import "testing/gtest_mac.h" | 36 #import "testing/gtest_mac.h" |
| 34 #include "ui/base/test/ios/ui_view_test_utils.h" | 37 #include "ui/base/test/ios/ui_view_test_utils.h" |
| 35 | 38 |
| 36 #if !defined(__has_feature) || !__has_feature(objc_arc) | 39 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 37 #error "This file requires ARC support." | 40 #error "This file requires ARC support." |
| 38 #endif | 41 #endif |
| 39 | 42 |
| 40 // Real FormSuggestionController is wrapped to register the addition of | 43 // Real FormSuggestionController is wrapped to register the addition of |
| 41 // suggestions. | 44 // suggestions. |
| 42 @interface TestSuggestionController : FormSuggestionController | 45 @interface TestSuggestionController : FormSuggestionController |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 // The credit card-type form used by tests. | 109 // The credit card-type form used by tests. |
| 107 NSString* const kCreditCardFormHtml = | 110 NSString* const kCreditCardFormHtml = |
| 108 @"<form action='/submit' method='post'>" | 111 @"<form action='/submit' method='post'>" |
| 109 "Name on card: <input type='text' name='name'>" | 112 "Name on card: <input type='text' name='name'>" |
| 110 "Credit card number: <input type='text' name='CCNo'>" | 113 "Credit card number: <input type='text' name='CCNo'>" |
| 111 "Expiry Month: <input type='text' name='CCExpiresMonth'>" | 114 "Expiry Month: <input type='text' name='CCExpiresMonth'>" |
| 112 "Expiry Year: <input type='text' name='CCExpiresYear'>" | 115 "Expiry Year: <input type='text' name='CCExpiresYear'>" |
| 113 "<input type='submit' id='submit' value='Submit'>" | 116 "<input type='submit' id='submit' value='Submit'>" |
| 114 "</form>"; | 117 "</form>"; |
| 115 | 118 |
| 119 // An HTML page without a card-type form. | |
| 120 static NSString* kNoCreditCardFormHtml = | |
| 121 @"<h2>The rain in Spain stays <i>mainly</i> in the plain.</h2>"; | |
| 122 | |
| 123 // A credit card-type form with the autofocus attribute (which is detected at | |
| 124 // page load). | |
| 125 NSString* const kCreditCardAutofocusFormHtml = | |
| 126 @"<form><input type=\"text\" autofocus autocomplete=\"cc-number\"></form>"; | |
| 127 | |
| 116 // Experiment preference key. | 128 // Experiment preference key. |
| 117 NSString* const kAutofillVisible = @"AutofillVisible"; | 129 NSString* const kAutofillVisible = @"AutofillVisible"; |
| 118 | 130 |
| 119 // FAIL if a field with the supplied |name| and |fieldType| is not present on | 131 // FAIL if a field with the supplied |name| and |fieldType| is not present on |
| 120 // the |form|. | 132 // the |form|. |
| 121 void CheckField(const FormStructure& form, | 133 void CheckField(const FormStructure& form, |
| 122 ServerFieldType fieldType, | 134 ServerFieldType fieldType, |
| 123 const char* name) { | 135 const char* name) { |
| 124 for (const auto& field : form) { | 136 for (const auto& field : form) { |
| 125 if (field->heuristic_type() == fieldType) { | 137 if (field->heuristic_type() == fieldType) { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 credit_card.GetInfo(AutofillType(CREDIT_CARD_NAME_FULL), "en-US")); | 587 credit_card.GetInfo(AutofillType(CREDIT_CARD_NAME_FULL), "en-US")); |
| 576 EXPECT_EQ(base::UTF8ToUTF16("4000444444444444"), | 588 EXPECT_EQ(base::UTF8ToUTF16("4000444444444444"), |
| 577 credit_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), "en-US")); | 589 credit_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), "en-US")); |
| 578 EXPECT_EQ(base::UTF8ToUTF16("11"), | 590 EXPECT_EQ(base::UTF8ToUTF16("11"), |
| 579 credit_card.GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), "en-US")); | 591 credit_card.GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), "en-US")); |
| 580 EXPECT_EQ( | 592 EXPECT_EQ( |
| 581 base::UTF8ToUTF16("2999"), | 593 base::UTF8ToUTF16("2999"), |
| 582 credit_card.GetInfo(AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), "en-US")); | 594 credit_card.GetInfo(AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), "en-US")); |
| 583 }; | 595 }; |
| 584 | 596 |
| 597 // Checks that an HTTP page containing a credit card results in a navigation | |
| 598 // entry with the "credit card displayed" bit set to true. | |
| 599 TEST_F(AutofillControllerTest, HTTPCreditCard) { | |
|
Eugene But (OOO till 7-30)
2017/02/03 19:24:16
HttpCreditCard
Same for other tests
lgarron
2017/02/04 00:28:35
Mmkay. The password tests use the uppercase HTTP c
Eugene But (OOO till 7-30)
2017/02/04 01:29:17
Oh, Alright. We quite inconsistent with following
| |
| 600 LoadHtml(kCreditCardAutofocusFormHtml, GURL("http://chromium.test")); | |
| 601 | |
| 602 web::SSLStatus ssl_status = | |
| 603 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 604 EXPECT_TRUE(ssl_status.content_status & | |
| 605 web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); | |
| 606 }; | |
| 607 | |
| 608 // Checks that an HTTP page without a credit card form does not result in a | |
| 609 // navigation entry with the "credit card displayed" bit set to true. | |
| 610 TEST_F(AutofillControllerTest, HTTPNoCreditCard) { | |
| 611 LoadHtml(kNoCreditCardFormHtml, GURL("http://chromium.test")); | |
| 612 | |
| 613 web::SSLStatus ssl_status = | |
| 614 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 615 EXPECT_FALSE(ssl_status.content_status & | |
| 616 web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); | |
| 617 }; | |
| 618 | |
| 619 // Checks that an HTTPS page containing a credit card form does not result in a | |
| 620 // navigation entry with the "credit card displayed" bit set to true. | |
| 621 TEST_F(AutofillControllerTest, HTTPSCreditCard) { | |
| 622 LoadHtml(kCreditCardAutofocusFormHtml, GURL("https://chromium.test")); | |
| 623 | |
| 624 web::SSLStatus ssl_status = | |
| 625 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 626 EXPECT_FALSE(ssl_status.content_status & | |
| 627 web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); | |
| 628 }; | |
| 629 | |
| 630 // Checks that an HTTPS page without a credit card form does not result in a | |
| 631 // navigation entry with the "credit card displayed" bit set to true. | |
| 632 TEST_F(AutofillControllerTest, HTTPSNoCreditCard) { | |
| 633 LoadHtml(kNoCreditCardFormHtml, GURL("https://chromium.test")); | |
| 634 | |
| 635 web::SSLStatus ssl_status = | |
| 636 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 637 EXPECT_FALSE(ssl_status.content_status & | |
| 638 web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); | |
| 639 }; | |
| 640 | |
| 585 } // namespace | 641 } // namespace |
| 586 | 642 |
| 587 } // namespace autofill | 643 } // namespace autofill |
| OLD | NEW |