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

Unified Diff: components/autofill/core/browser/autofill_field_unittest.cc

Issue 1473733008: [Autofill] Respect the autocomplete=off attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 1 month 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: components/autofill/core/browser/autofill_field_unittest.cc
diff --git a/components/autofill/core/browser/autofill_field_unittest.cc b/components/autofill/core/browser/autofill_field_unittest.cc
index c65daaa811105800646e3a308bb148d27436580f..2a96e85aeebce423380ee9d86fca1a51181d4829 100644
--- a/components/autofill/core/browser/autofill_field_unittest.cc
+++ b/components/autofill/core/browser/autofill_field_unittest.cc
@@ -9,6 +9,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
+#include "components/autofill/core/common/autofill_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::ASCIIToUTF16;
@@ -129,11 +130,44 @@ TEST(AutofillFieldTest, IsFieldFillable) {
field.set_server_type(NAME_LAST);
EXPECT_TRUE(field.IsFieldFillable());
- // Field has autocomplete="off" set. Chrome ignores the attribute.
+ // Field has autocomplete="off" set. It is still fillable.
vabr (Chromium) 2015/11/30 16:26:09 nit: Perhaps mention the reason. I expect this is
sebsg 2015/12/01 16:37:00 Done.
field.should_autocomplete = false;
EXPECT_TRUE(field.IsFieldFillable());
}
+// Verify that non credit card related fields with the autocomplete attribute
+// set to off don't get filled on desktop.
+TEST(AutofillFieldTest, FillFormField_AutocompleteOff_AddressField) {
+ AutofillField field;
+ field.should_autocomplete = false;
+
+ // Non credit card related field.
+ AutofillField::FillFormField(field, ASCIIToUTF16("Test"), "en-US", "en-US",
+ &field);
+
+ // Verifiy that the field is filled on mobile but not on desktop.
+ if (IsDesktopPlatform()) {
+ EXPECT_EQ(base::string16(), field.value);
+ } else {
+ EXPECT_EQ(ASCIIToUTF16("Test"), field.value);
+ }
+}
+
+// Verify that credit card related fields with the autocomplete attribute
+// set to off get filled.
+TEST(AutofillFieldTest, FillFormField_AutocompleteOff_CreditCardField) {
+ AutofillField field;
+ field.should_autocomplete = false;
+
+ // Credit card related field.
+ field.set_heuristic_type(CREDIT_CARD_NUMBER);
+ AutofillField::FillFormField(field, ASCIIToUTF16("4111111111111111"), "en-US",
+ "en-US", &field);
+
+ // Verify that the field is filled.
+ EXPECT_EQ(ASCIIToUTF16("4111111111111111"), field.value);
+}
+
TEST(AutofillFieldTest, FillPhoneNumber) {
AutofillField field;
field.SetHtmlType(HTML_TYPE_TEL_LOCAL_PREFIX, HtmlFieldMode());

Powered by Google App Engine
This is Rietveld 408576698