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

Unified Diff: ios/chrome/browser/autofill/autofill_controller_unittest.mm

Issue 2669123003: iOS: Mark HTTP pages with credit card fields with an omnibox icon. (Closed)
Patch Set: Update comments. Created 3 years, 10 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
Index: ios/chrome/browser/autofill/autofill_controller_unittest.mm
diff --git a/ios/chrome/browser/autofill/autofill_controller_unittest.mm b/ios/chrome/browser/autofill/autofill_controller_unittest.mm
index 67c5a7a17c15b16af2f0125c907c5b55ae6f5c3c..90fe3151018535ff7541321e805a9480881b2aba 100644
--- a/ios/chrome/browser/autofill/autofill_controller_unittest.mm
+++ b/ios/chrome/browser/autofill/autofill_controller_unittest.mm
@@ -29,7 +29,10 @@
#import "ios/chrome/browser/ui/autofill/autofill_client_ios.h"
#import "ios/chrome/browser/web/chrome_web_test.h"
#include "ios/chrome/browser/web_data_service_factory.h"
+#import "ios/web/public/navigation_item.h"
+#import "ios/web/public/navigation_manager.h"
#import "ios/web/public/web_state/web_state.h"
+#include "ios/web/public/ssl_status.h"
#import "testing/gtest_mac.h"
#include "ui/base/test/ios/ui_view_test_utils.h"
@@ -113,6 +116,15 @@ NSString* const kCreditCardFormHtml =
"<input type='submit' id='submit' value='Submit'>"
"</form>";
+// An HTML page without a card-type form.
+static NSString* kNoCreditCardFormHtml =
+ @"<h2>The rain in Spain stays <i>mainly</i> in the plain.</h2>";
+
+// A credit card-type form with the autofocus attribute (which is detected at
+// page load).
+NSString* const kCreditCardAutofocusFormHtml =
+ @"<form><input type=\"text\" autofocus autocomplete=\"cc-number\"></form>";
+
// Experiment preference key.
NSString* const kAutofillVisible = @"AutofillVisible";
@@ -582,6 +594,50 @@ TEST_F(AutofillControllerTest, CreditCardImport) {
credit_card.GetInfo(AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), "en-US"));
};
+// Checks that an HTTP page containing a credit card results in a navigation
+// entry with the "credit card displayed" bit set to true.
+TEST_F(AutofillControllerTest, HttpCreditCard) {
+ LoadHtml(kCreditCardAutofocusFormHtml, GURL("http://chromium.test"));
+
+ web::SSLStatus ssl_status =
+ web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL();
+ EXPECT_TRUE(ssl_status.content_status &
+ web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
+};
+
+// Checks that an HTTP page without a credit card form does not result in a
+// navigation entry with the "credit card displayed" bit set to true.
+TEST_F(AutofillControllerTest, HttpNoCreditCard) {
+ LoadHtml(kNoCreditCardFormHtml, GURL("http://chromium.test"));
+
+ web::SSLStatus ssl_status =
+ web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL();
+ EXPECT_FALSE(ssl_status.content_status &
+ web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
+};
+
+// Checks that an HTTPS page containing a credit card form does not result in a
+// navigation entry with the "credit card displayed" bit set to true.
+TEST_F(AutofillControllerTest, HttpsCreditCard) {
+ LoadHtml(kCreditCardAutofocusFormHtml, GURL("https://chromium.test"));
+
+ web::SSLStatus ssl_status =
+ web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL();
+ EXPECT_FALSE(ssl_status.content_status &
+ web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
+};
+
+// Checks that an HTTPS page without a credit card form does not result in a
+// navigation entry with the "credit card displayed" bit set to true.
+TEST_F(AutofillControllerTest, HttpsNoCreditCard) {
+ LoadHtml(kNoCreditCardFormHtml, GURL("https://chromium.test"));
+
+ web::SSLStatus ssl_status =
+ web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL();
+ EXPECT_FALSE(ssl_status.content_status &
+ web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
+};
+
} // namespace
} // namespace autofill
« no previous file with comments | « components/autofill/ios/browser/autofill_driver_ios.mm ('k') | ios/chrome/browser/ssl/ios_security_state_tab_helper.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698