summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-29 22:27:16 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-29 22:27:16 +0000
commit3bb80e49ebd2f095b829e27135962a0aa4591e87 (patch)
treecce992fadfc3f39a776154372e0d8cf38bdd416e /chrome/browser/autofill
parentc8965289996843e686084e86036db4cfe5b1713f (diff)
downloadchromium_src-3bb80e49ebd2f095b829e27135962a0aa4591e87.zip
chromium_src-3bb80e49ebd2f095b829e27135962a0aa4591e87.tar.gz
chromium_src-3bb80e49ebd2f095b829e27135962a0aa4591e87.tar.bz2
Once a form has been partially autofilled, autofill should only update fields one at a time.
BUG=63437, 62638 TEST=unit_tests --gtest_filter=AutoFillManagerTest.* Review URL: http://codereview.chromium.org/5334005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/address_field_unittest.cc75
-rw-r--r--chrome/browser/autofill/autofill_common_test.cc3
-rw-r--r--chrome/browser/autofill/autofill_download_unittest.cc33
-rw-r--r--chrome/browser/autofill/autofill_manager.cc262
-rw-r--r--chrome/browser/autofill/autofill_manager.h19
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc1508
-rw-r--r--chrome/browser/autofill/credit_card_field_unittest.cc81
-rw-r--r--chrome/browser/autofill/fax_field_unittest.cc3
-rw-r--r--chrome/browser/autofill/form_structure_unittest.cc471
-rw-r--r--chrome/browser/autofill/name_field_unittest.cc96
-rw-r--r--chrome/browser/autofill/phone_field_unittest.cc45
11 files changed, 1408 insertions, 1188 deletions
diff --git a/chrome/browser/autofill/address_field_unittest.cc b/chrome/browser/autofill/address_field_unittest.cc
index 51509f7..d6a42db 100644
--- a/chrome/browser/autofill/address_field_unittest.cc
+++ b/chrome/browser/autofill/address_field_unittest.cc
@@ -46,7 +46,8 @@ TEST_F(AddressFieldTest, ParseOneLineAddress) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -66,7 +67,8 @@ TEST_F(AddressFieldTest, ParseOneLineAddressBilling) {
ASCIIToUTF16("billingAddress"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -86,7 +88,8 @@ TEST_F(AddressFieldTest, ParseOneLineAddressShipping) {
ASCIIToUTF16("shippingAddress"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -107,7 +110,8 @@ TEST_F(AddressFieldTest, ParseOneLineAddressEcml) {
ASCIIToUTF16(kEcmlShipToAddress1),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -127,14 +131,16 @@ TEST_F(AddressFieldTest, ParseTwoLineAddress) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -157,21 +163,24 @@ TEST_F(AddressFieldTest, ParseThreeLineAddress) {
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address Line3"),
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -197,7 +206,8 @@ TEST_F(AddressFieldTest, ParseTwoLineAddressEcml) {
ASCIIToUTF16(kEcmlShipToAddress1),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(
@@ -205,7 +215,8 @@ TEST_F(AddressFieldTest, ParseTwoLineAddressEcml) {
ASCIIToUTF16(kEcmlShipToAddress2),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -228,7 +239,8 @@ TEST_F(AddressFieldTest, ParseCity) {
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("city1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -248,7 +260,8 @@ TEST_F(AddressFieldTest, ParseCityEcml) {
ASCIIToUTF16(kEcmlShipToCity),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("city1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -268,7 +281,8 @@ TEST_F(AddressFieldTest, ParseState) {
ASCIIToUTF16("state"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("state1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -289,7 +303,8 @@ TEST_F(AddressFieldTest, ParseStateEcml) {
ASCIIToUTF16(kEcmlShipToStateProv),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("state1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -309,7 +324,8 @@ TEST_F(AddressFieldTest, ParseZip) {
ASCIIToUTF16("zip"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("zip1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -330,7 +346,8 @@ TEST_F(AddressFieldTest, ParseZipEcml) {
ASCIIToUTF16(kEcmlShipToPostalCode),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("zip1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -352,7 +369,8 @@ TEST_F(AddressFieldTest, ParseStateAndZipOneLabel) {
ASCIIToUTF16("state"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("state")));
list_.push_back(
new AutoFillField(
@@ -361,7 +379,8 @@ TEST_F(AddressFieldTest, ParseStateAndZipOneLabel) {
ASCIIToUTF16("zip"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("zip")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -384,7 +403,8 @@ TEST_F(AddressFieldTest, ParseCountry) {
ASCIIToUTF16("country"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("country1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -404,7 +424,8 @@ TEST_F(AddressFieldTest, ParseCountryEcml) {
ASCIIToUTF16(kEcmlShipToCountry),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("country1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -424,14 +445,16 @@ TEST_F(AddressFieldTest, ParseTwoLineAddressMissingLabel) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("bogus"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("addr2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -454,7 +477,8 @@ TEST_F(AddressFieldTest, ParseCompany) {
ASCIIToUTF16("company"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("company1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -475,7 +499,8 @@ TEST_F(AddressFieldTest, ParseCompanyEcml) {
ASCIIToUTF16(kEcmlShipToCompanyName),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("company1")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/autofill_common_test.cc b/chrome/browser/autofill/autofill_common_test.cc
index c4c8482..32041cc 100644
--- a/chrome/browser/autofill/autofill_common_test.cc
+++ b/chrome/browser/autofill/autofill_common_test.cc
@@ -21,7 +21,8 @@ void CreateTestFormField(const char* label,
const char* type,
webkit_glue::FormField* field) {
*field = webkit_glue::FormField(ASCIIToUTF16(label), ASCIIToUTF16(name),
- ASCIIToUTF16(value), ASCIIToUTF16(type), 0);
+ ASCIIToUTF16(value), ASCIIToUTF16(type), 0,
+ false);
}
inline void check_and_set(
diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc
index deb9b49..68173c6 100644
--- a/chrome/browser/autofill/autofill_download_unittest.cc
+++ b/chrome/browser/autofill/autofill_download_unittest.cc
@@ -101,37 +101,44 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
ASCIIToUTF16("username"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"),
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"),
ASCIIToUTF16("email2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
ASCIIToUTF16("password"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
FormStructure *form_structure = new FormStructure(form);
ScopedVector<FormStructure> form_structures;
@@ -142,22 +149,26 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address2"),
ASCIIToUTF16("address2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("city"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure = new FormStructure(form);
form_structures.push_back(form_structure);
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 42051f7..e04fe1f 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -72,6 +72,51 @@ void RemoveDuplicateElements(
unique_ids->assign(unique_ids_copy.begin(), unique_ids_copy.end());
}
+// Precondition: |form_structure| and |form| should correspond to the same
+// logical form. Returns true if the relevant portion of |form| is auto-filled.
+// If |is_filling_credit_card|, the relevant portion is the credit card portion;
+// otherwise it is the address and contact info portion.
+bool FormIsAutoFilled(const FormStructure* form_structure,
+ const webkit_glue::FormData& form,
+ bool is_filling_credit_card) {
+ // TODO(isherman): It would be nice to share most of this code with the loop
+ // in |FillAutoFillFormData()|, but I don't see a particularly clean way to do
+ // that.
+
+ // The list of fields in |form_structure| and |form.fields| often match
+ // directly and we can fill these corresponding fields; however, when the
+ // |form_structure| and |form.fields| do not match directly we search
+ // ahead in the |form_structure| for the matching field.
+ for (size_t i = 0, j = 0;
+ i < form_structure->field_count() && j < form.fields.size();
+ j++) {
+ size_t k = i;
+
+ // Search forward in the |form_structure| for a corresponding field.
+ while (k < form_structure->field_count() &&
+ *form_structure->field(k) != form.fields[j]) {
+ k++;
+ }
+
+ // If we didn't find a match, continue on to the next |form| field.
+ if (k >= form_structure->field_count())
+ continue;
+
+ AutoFillType autofill_type(form_structure->field(k)->type());
+ bool is_credit_card_field =
+ autofill_type.group() == AutoFillType::CREDIT_CARD;
+ if (is_filling_credit_card == is_credit_card_field &&
+ form.fields[j].is_autofilled())
+ return true;
+
+ // We found a matching field in the |form_structure| so we
+ // proceed to the next |form| field, and the next |form_structure|.
+ ++i;
+ }
+
+ return false;
+}
+
bool FormIsHTTPS(FormStructure* form) {
return form->source_url().SchemeIs(chrome::kHttpsScheme);
}
@@ -145,61 +190,38 @@ void AutoFillManager::FormsSeen(const std::vector<FormData>& forms) {
ParseForms(forms);
}
-bool AutoFillManager::GetAutoFillSuggestions(bool field_autofilled,
+bool AutoFillManager::GetAutoFillSuggestions(const FormData& form,
const FormField& field) {
- if (!IsAutoFillEnabled())
- return false;
-
- RenderViewHost* host = tab_contents_->render_view_host();
- if (!host)
- return false;
-
- if (personal_data_->profiles().empty() &&
- personal_data_->credit_cards().empty())
- return false;
-
- // Loops through the cached FormStructures looking for the FormStructure that
- // contains |field| and the associated AutoFillFieldType.
- FormStructure* form = NULL;
+ RenderViewHost* host = NULL;
+ FormStructure* form_structure = NULL;
AutoFillField* autofill_field = NULL;
- for (std::vector<FormStructure*>::iterator form_iter =
- form_structures_.begin();
- form_iter != form_structures_.end() && !autofill_field; ++form_iter) {
- form = *form_iter;
-
- // Don't send suggestions for forms that aren't auto-fillable.
- if (!form->IsAutoFillable(false))
- continue;
+ if (!GetHost(personal_data_->profiles(),
+ personal_data_->credit_cards(),
+ &host) ||
+ !FindCachedFormAndField(form, field, &form_structure, &autofill_field))
+ return false;
- for (std::vector<AutoFillField*>::const_iterator iter = form->begin();
- iter != form->end(); ++iter) {
- // The field list is terminated with a NULL AutoFillField, so don't try to
- // dereference it.
- if (!*iter)
- break;
+ DCHECK(host);
+ DCHECK(form_structure);
+ DCHECK(autofill_field);
- if ((**iter) == field) {
- autofill_field = *iter;
- break;
- }
- }
- }
-
- if (!autofill_field)
+ // Don't send suggestions for forms that aren't auto-fillable.
+ if (!form_structure->IsAutoFillable(false))
return false;
std::vector<string16> values;
std::vector<string16> labels;
std::vector<string16> icons;
std::vector<int> unique_ids;
- AutoFillType type(autofill_field->type());
- if (type.group() == AutoFillType::CREDIT_CARD) {
+ AutoFillType type(autofill_field->type());
+ bool is_filling_credit_card = (type.group() == AutoFillType::CREDIT_CARD);
+ if (is_filling_credit_card) {
GetCreditCardSuggestions(
- form, field, type, &values, &labels, &icons, &unique_ids);
+ form_structure, field, type, &values, &labels, &icons, &unique_ids);
} else {
GetProfileSuggestions(
- form, field, type, &values, &labels, &icons, &unique_ids);
+ form_structure, field, type, &values, &labels, &icons, &unique_ids);
}
DCHECK_EQ(values.size(), labels.size());
@@ -210,23 +232,16 @@ bool AutoFillManager::GetAutoFillSuggestions(bool field_autofilled,
if (values.empty())
return false;
- // Don't provide AutoFill suggestions when AutoFill is disabled, but provide a
- // warning to the user.
- if (!form->IsAutoFillable(true)) {
- values.assign(
- 1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED));
- labels.assign(1, string16());
- icons.assign(1, string16());
- unique_ids.assign(1, -1);
- host->AutoFillSuggestionsReturned(values, labels, icons, unique_ids);
- return true;
- }
-
- // Don't provide credit card suggestions for non-HTTPS pages, but provide a
- // warning to the user.
- if (!FormIsHTTPS(form) && type.group() == AutoFillType::CREDIT_CARD) {
- values.assign(
- 1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION));
+ // Don't provide AutoFill suggestions when AutoFill is disabled, and don't
+ // provide credit card suggestions for non-HTTPS pages. However, provide a
+ // warning to the user in these cases.
+ int warning = 0;
+ if (!form_structure->IsAutoFillable(true))
+ warning = IDS_AUTOFILL_WARNING_FORM_DISABLED;
+ else if (is_filling_credit_card && !FormIsHTTPS(form_structure))
+ warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION;
+ if (warning) {
+ values.assign(1, l10n_util::GetStringUTF16(warning));
labels.assign(1, string16());
icons.assign(1, string16());
unique_ids.assign(1, -1);
@@ -235,10 +250,10 @@ bool AutoFillManager::GetAutoFillSuggestions(bool field_autofilled,
}
// If the form is auto-filled and the renderer is querying for suggestions,
- // then the user is editing the value of a field. In this case, mimick
- // autocomplete. In particular, don't display labels, as that information is
+ // then the user is editing the value of a field. In this case, mimick
+ // autocomplete. In particular, don't display labels, as that information is
// redundant. In addition, remove duplicate values.
- if (field_autofilled) {
+ if (FormIsAutoFilled(form_structure, form, is_filling_credit_card)) {
RemoveDuplicateElements(&values, &unique_ids);
labels.assign(values.size(), string16());
icons.assign(values.size(), string16());
@@ -250,39 +265,20 @@ bool AutoFillManager::GetAutoFillSuggestions(bool field_autofilled,
bool AutoFillManager::FillAutoFillFormData(int query_id,
const FormData& form,
+ const FormField& field,
int unique_id) {
- if (!IsAutoFillEnabled())
- return false;
-
- RenderViewHost* host = tab_contents_->render_view_host();
- if (!host)
- return false;
-
const std::vector<AutoFillProfile*>& profiles = personal_data_->profiles();
const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards();
-
- // No data to return if the profiles are empty.
- if (profiles.empty() && credit_cards.empty())
- return false;
-
- // Find the FormStructure that corresponds to |form|.
- FormData result = form;
+ RenderViewHost* host = NULL;
FormStructure* form_structure = NULL;
- for (std::vector<FormStructure*>::const_iterator iter =
- form_structures_.begin();
- iter != form_structures_.end(); ++iter) {
- if (**iter == form) {
- form_structure = *iter;
- break;
- }
- }
-
- if (!form_structure)
+ AutoFillField* autofill_field = NULL;
+ if (!GetHost(profiles, credit_cards, &host) ||
+ !FindCachedFormAndField(form, field, &form_structure, &autofill_field))
return false;
- // No data to return if there are no auto-fillable fields.
- if (!form_structure->autofill_count())
- return false;
+ DCHECK(host);
+ DCHECK(form_structure);
+ DCHECK(autofill_field);
// Unpack the |unique_id| into component parts.
std::string cc_guid;
@@ -319,6 +315,30 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
if (!profile && !credit_card)
return false;
+ FormData result = form;
+
+ // If the form is auto-filled, we should fill |field| but not the rest of the
+ // form.
+ if (FormIsAutoFilled(form_structure, form, (credit_card != NULL))) {
+ for (std::vector<FormField>::iterator iter = result.fields.begin();
+ iter != result.fields.end(); ++iter) {
+ if ((*iter) == field) {
+ AutoFillType autofill_type(autofill_field->type());
+ if (credit_card &&
+ autofill_type.group() == AutoFillType::CREDIT_CARD) {
+ FillCreditCardFormField(credit_card, autofill_type, &(*iter));
+ } else if (profile &&
+ autofill_type.group() != AutoFillType::CREDIT_CARD) {
+ FillFormField(profile, autofill_type, &(*iter));
+ }
+ break;
+ }
+ }
+
+ host->AutoFillFormDataFilled(query_id, result);
+ return true;
+ }
+
// The list of fields in |form_structure| and |result.fields| often match
// directly and we can fill these corresponding fields; however, when the
// |form_structure| and |result.fields| do not match directly we search
@@ -346,7 +366,8 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
if (credit_card &&
autofill_type.group() == AutoFillType::CREDIT_CARD) {
FillCreditCardFormField(credit_card, autofill_type, &result.fields[j]);
- } else if (profile) {
+ } else if (profile &&
+ autofill_type.group() != AutoFillType::CREDIT_CARD) {
FillFormField(profile, autofill_type, &result.fields[j]);
}
@@ -488,6 +509,67 @@ AutoFillManager::AutoFillManager(TabContents* tab_contents,
DCHECK(tab_contents);
}
+bool AutoFillManager::GetHost(const std::vector<AutoFillProfile*>& profiles,
+ const std::vector<CreditCard*>& credit_cards,
+ RenderViewHost** host) {
+ if (!IsAutoFillEnabled())
+ return false;
+
+ // No autofill data to return if the profiles are empty.
+ if (profiles.empty() && credit_cards.empty())
+ return false;
+
+ *host = tab_contents_->render_view_host();
+ if (!(*host))
+ return false;
+
+ return true;
+}
+
+bool AutoFillManager::FindCachedFormAndField(const FormData& form,
+ const FormField& field,
+ FormStructure** form_structure,
+ AutoFillField** autofill_field) {
+ // Find the FormStructure that corresponds to |form|.
+ *form_structure = NULL;
+ for (std::vector<FormStructure*>::const_iterator iter =
+ form_structures_.begin();
+ iter != form_structures_.end(); ++iter) {
+ if (**iter == form) {
+ *form_structure = *iter;
+ break;
+ }
+ }
+
+ if (!(*form_structure))
+ return false;
+
+ // No data to return if there are no auto-fillable fields.
+ if (!(*form_structure)->autofill_count())
+ return false;
+
+ // Find the AutoFillField that corresponds to |field|.
+ *autofill_field = NULL;
+ for (std::vector<AutoFillField*>::const_iterator iter =
+ (*form_structure)->begin();
+ iter != (*form_structure)->end(); ++iter) {
+ // The field list is terminated with a NULL AutoFillField, so don't try to
+ // dereference it.
+ if (!*iter)
+ break;
+
+ if ((**iter) == field) {
+ *autofill_field = *iter;
+ break;
+ }
+ }
+
+ if (!(*autofill_field))
+ return false;
+
+ return true;
+}
+
void AutoFillManager::GetProfileSuggestions(FormStructure* form,
const FormField& field,
AutoFillType type,
@@ -561,6 +643,7 @@ void AutoFillManager::FillCreditCardFormField(const CreditCard* credit_card,
AutoFillType type,
webkit_glue::FormField* field) {
DCHECK(credit_card);
+ DCHECK(type.group() == AutoFillType::CREDIT_CARD);
DCHECK(field);
if (field->form_control_type() == ASCIIToUTF16("select-one"))
@@ -573,6 +656,7 @@ void AutoFillManager::FillFormField(const AutoFillProfile* profile,
AutoFillType type,
webkit_glue::FormField* field) {
DCHECK(profile);
+ DCHECK(type.group() != AutoFillType::CREDIT_CARD);
DCHECK(field);
if (type.subgroup() == AutoFillType::PHONE_NUMBER) {
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 835f643..791d171 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -50,10 +50,11 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
// RenderViewHostDelegate::AutoFill implementation:
virtual void FormSubmitted(const webkit_glue::FormData& form);
virtual void FormsSeen(const std::vector<webkit_glue::FormData>& forms);
- virtual bool GetAutoFillSuggestions(bool field_autofilled,
+ virtual bool GetAutoFillSuggestions(const webkit_glue::FormData& form,
const webkit_glue::FormField& field);
virtual bool FillAutoFillFormData(int query_id,
const webkit_glue::FormData& form,
+ const webkit_glue::FormField& field,
int unique_id);
virtual void ShowAutoFillDialog();
@@ -106,6 +107,21 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
void UnpackGUIDs(int id, std::string* cc_guid, std::string* profile_guid);
private:
+ // Fills |host| with the RenderViewHost for this tab.
+ // Returns false if AutoFill is disabled or if the host is unavailable.
+ bool GetHost(const std::vector<AutoFillProfile*>& profiles,
+ const std::vector<CreditCard*>& credit_cards,
+ RenderViewHost** host) WARN_UNUSED_RESULT;
+
+ // Fills |form_structure| and |autofill_field| with the cached elements
+ // corresponding to |form| and |field|. Returns false if the cached elements
+ // were not found.
+ bool FindCachedFormAndField(
+ const webkit_glue::FormData& form,
+ const webkit_glue::FormField& field,
+ FormStructure** form_structure,
+ AutoFillField** autofill_field) WARN_UNUSED_RESULT;
+
// Returns a list of values from the stored profiles that match |type| and the
// value of |field| and returns the labels of the matching profiles. |labels|
// is filled with the Profile label.
@@ -190,6 +206,7 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm);
FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressForm);
FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressAndCreditCardForm);
+ FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAutoFilledForm);
FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillPhoneNumber);
FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesRemoveField);
FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesAddField);
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 228bbdb..506c7cb 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -32,6 +32,13 @@
#include "webkit/glue/form_field.h"
using webkit_glue::FormData;
+using webkit_glue::FormField;
+
+namespace {
+
+// The page ID sent to the AutoFillManager from the RenderView, used to send
+// an IPC message back to the renderer.
+const int kDefaultPageID = 137;
typedef Tuple5<int,
std::vector<string16>,
@@ -53,8 +60,17 @@ class TestPersonalDataManager : public PersonalDataManager {
AutoFillProfile* GetLabeledProfile(const char* label) {
for (std::vector<AutoFillProfile *>::iterator it = web_profiles_.begin();
it != web_profiles_.end(); ++it) {
- if (!(*it)->Label().compare(ASCIIToUTF16(label)))
- return *it;
+ if (!(*it)->Label().compare(ASCIIToUTF16(label)))
+ return *it;
+ }
+ return NULL;
+ }
+
+ CreditCard* GetLabeledCreditCard(const char* label) {
+ for (std::vector<CreditCard *>::iterator it = credit_cards_.begin();
+ it != credit_cards_.end(); ++it) {
+ if (!(*it)->Label().compare(ASCIIToUTF16(label)))
+ return *it;
}
return NULL;
}
@@ -118,62 +134,6 @@ class TestPersonalDataManager : public PersonalDataManager {
DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager);
};
-class TestAutoFillManager : public AutoFillManager {
- public:
- TestAutoFillManager(TabContents* tab_contents,
- TestPersonalDataManager* personal_manager)
- : AutoFillManager(tab_contents, NULL),
- autofill_enabled_(true) {
- test_personal_data_ = personal_manager;
- set_personal_data_manager(personal_manager);
- // Download manager requests are disabled for purposes of this unit-test.
- // These request are tested in autofill_download_unittest.cc.
- set_disable_download_manager_requests(true);
- }
-
- virtual bool IsAutoFillEnabled() const { return autofill_enabled_; }
-
- void set_autofill_enabled(bool autofill_enabled) {
- autofill_enabled_ = autofill_enabled;
- }
-
- AutoFillProfile* GetLabeledProfile(const char* label) {
- return test_personal_data_->GetLabeledProfile(label);
- }
-
- void AddProfile(AutoFillProfile* profile) {
- test_personal_data_->AddProfile(profile);
- }
-
- int GetPackedCreditCardID(int credit_card_id) {
- return PackGUIDs(IDToGUID(credit_card_id), std::string());
- }
-
- protected:
- virtual int GUIDToID(const std::string& guid) OVERRIDE {
- if (guid.empty())
- return 0;
-
- int id;
- EXPECT_TRUE(base::StringToInt(guid.substr(guid.rfind("-") + 1), &id));
- return id;
- }
-
- virtual const std::string IDToGUID(int id) OVERRIDE {
- EXPECT_TRUE(id >= 0);
- if (id <= 0)
- return std::string();
-
- return base::StringPrintf("00000000-0000-0000-0000-%012d", id);
- }
-
- private:
- TestPersonalDataManager* test_personal_data_;
- bool autofill_enabled_;
-
- DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager);
-};
-
// Populates |form| with data corresponding to a simple address form.
// Note that this actually appends fields to the form data, which can be useful
// for building up more complex test forms.
@@ -184,7 +144,7 @@ void CreateTestAddressFormData(FormData* form) {
form->action = GURL("http://myform.com/submit.html");
form->user_submitted = true;
- webkit_glue::FormField field;
+ FormField field;
autofill_test::CreateTestFormField(
"First Name", "firstname", "", "text", &field);
form->fields.push_back(field);
@@ -216,6 +176,9 @@ void CreateTestAddressFormData(FormData* form) {
"Phone Number", "phonenumber", "", "text", &field);
form->fields.push_back(field);
autofill_test::CreateTestFormField(
+ "Fax", "fax", "", "text", &field);
+ form->fields.push_back(field);
+ autofill_test::CreateTestFormField(
"Email", "email", "", "text", &field);
form->fields.push_back(field);
}
@@ -235,7 +198,7 @@ void CreateTestCreditCardFormData(FormData* form, bool is_https) {
}
form->user_submitted = true;
- webkit_glue::FormField field;
+ FormField field;
autofill_test::CreateTestFormField(
"Name on Card", "nameoncard", "", "text", &field);
form->fields.push_back(field);
@@ -250,6 +213,218 @@ void CreateTestCreditCardFormData(FormData* form, bool is_https) {
form->fields.push_back(field);
}
+void ExpectSuggestions(int page_id,
+ const std::vector<string16>& values,
+ const std::vector<string16>& labels,
+ const std::vector<string16>& icons,
+ const std::vector<int>& unique_ids,
+ int expected_page_id,
+ size_t expected_num_suggestions,
+ const string16 expected_values[],
+ const string16 expected_labels[],
+ const string16 expected_icons[],
+ const int expected_unique_ids[]) {
+ EXPECT_EQ(expected_page_id, page_id);
+ ASSERT_EQ(expected_num_suggestions, values.size());
+ ASSERT_EQ(expected_num_suggestions, labels.size());
+ ASSERT_EQ(expected_num_suggestions, icons.size());
+ ASSERT_EQ(expected_num_suggestions, unique_ids.size());
+ for (size_t i = 0; i < expected_num_suggestions; ++i) {
+ SCOPED_TRACE(StringPrintf("i: %" PRIuS, i));
+ EXPECT_EQ(expected_values[i], values[i]);
+ EXPECT_EQ(expected_labels[i], labels[i]);
+ EXPECT_EQ(expected_icons[i], icons[i]);
+ EXPECT_EQ(expected_unique_ids[i], unique_ids[i]);
+ }
+}
+
+// Verifies that the |filled_form| has been filled with the given data.
+// Verifies address fields if |has_address_fields| is true, and verifies
+// credit card fields if |has_credit_card_fields| is true. Verifies both if both
+// are true.
+void ExpectFilledForm(int page_id,
+ const FormData& filled_form,
+ int expected_page_id,
+ const char* first,
+ const char* middle,
+ const char* last,
+ const char* address1,
+ const char* address2,
+ const char* city,
+ const char* state,
+ const char* postal_code,
+ const char* country,
+ const char* phone,
+ const char* fax,
+ const char* email,
+ const char* name_on_card,
+ const char* card_number,
+ const char* expiration_month,
+ const char* expiration_year,
+ bool has_address_fields,
+ bool has_credit_card_fields) {
+ // The number of fields in the address and credit card forms created above.
+ const size_t kAddressFormSize = 12;
+ const size_t kCreditCardFormSize = 4;
+
+ EXPECT_EQ(expected_page_id, page_id);
+ EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name);
+ EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method);
+ if (has_credit_card_fields) {
+ EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin);
+ EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action);
+ } else {
+ EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin);
+ EXPECT_EQ(GURL("http://myform.com/submit.html"), filled_form.action);
+ }
+ EXPECT_TRUE(filled_form.user_submitted);
+
+ size_t form_size = 0;
+ if (has_address_fields)
+ form_size += kAddressFormSize;
+ if (has_credit_card_fields)
+ form_size += kCreditCardFormSize;
+ ASSERT_EQ(form_size, filled_form.fields.size());
+
+ FormField field;
+ if (has_address_fields) {
+ autofill_test::CreateTestFormField(
+ "First Name", "firstname", first, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[0]));
+ autofill_test::CreateTestFormField(
+ "Middle Name", "middlename", middle, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[1]));
+ autofill_test::CreateTestFormField(
+ "Last Name", "lastname", last, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[2]));
+ autofill_test::CreateTestFormField(
+ "Address Line 1", "addr1", address1, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[3]));
+ autofill_test::CreateTestFormField(
+ "Address Line 2", "addr2", address2, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[4]));
+ autofill_test::CreateTestFormField(
+ "City", "city", city, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[5]));
+ autofill_test::CreateTestFormField(
+ "State", "state", state, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[6]));
+ autofill_test::CreateTestFormField(
+ "Postal Code", "zipcode", postal_code, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[7]));
+ autofill_test::CreateTestFormField(
+ "Country", "country", country, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[8]));
+ autofill_test::CreateTestFormField(
+ "Phone Number", "phonenumber", phone, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[9]));
+ autofill_test::CreateTestFormField(
+ "Fax", "fax", fax, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[10]));
+ autofill_test::CreateTestFormField(
+ "Email", "email", email, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[11]));
+ }
+
+ if (has_credit_card_fields) {
+ size_t offset = has_address_fields? kAddressFormSize : 0;
+ autofill_test::CreateTestFormField(
+ "Name on Card", "nameoncard", name_on_card, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 0]));
+ autofill_test::CreateTestFormField(
+ "Card Number", "cardnumber", card_number, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 1]));
+ autofill_test::CreateTestFormField(
+ "Expiration Date", "ccmonth", expiration_month, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2]));
+ autofill_test::CreateTestFormField(
+ "", "ccyear", expiration_year, "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 3]));
+ }
+}
+
+void ExpectFilledAddressFormElvis(int page_id,
+ const FormData& filled_form,
+ int expected_page_id,
+ bool has_credit_card_fields) {
+ ExpectFilledForm(page_id, filled_form, expected_page_id, "Elvis", "Aaron",
+ "Presley", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis",
+ "Tennessee", "38116", "USA", "12345678901", "",
+ "theking@gmail.com", "", "", "", "", true,
+ has_credit_card_fields);
+}
+
+void ExpectFilledCreditCardFormElvis(int page_id,
+ const FormData& filled_form,
+ int expected_page_id,
+ bool has_address_fields) {
+ ExpectFilledForm(page_id, filled_form, expected_page_id,
+ "", "", "", "", "", "", "", "", "", "", "", "",
+ "Elvis Presley", "4234567890123456", "04", "2012",
+ has_address_fields, true);
+}
+
+} // namespace
+
+class TestAutoFillManager : public AutoFillManager {
+ public:
+ TestAutoFillManager(TabContents* tab_contents,
+ TestPersonalDataManager* personal_manager)
+ : AutoFillManager(tab_contents, NULL),
+ autofill_enabled_(true) {
+ test_personal_data_ = personal_manager;
+ set_personal_data_manager(personal_manager);
+ // Download manager requests are disabled for purposes of this unit test.
+ // These requests are tested in autofill_download_unittest.cc.
+ set_disable_download_manager_requests(true);
+ }
+
+ virtual bool IsAutoFillEnabled() const { return autofill_enabled_; }
+
+ void set_autofill_enabled(bool autofill_enabled) {
+ autofill_enabled_ = autofill_enabled;
+ }
+
+ AutoFillProfile* GetLabeledProfile(const char* label) {
+ return test_personal_data_->GetLabeledProfile(label);
+ }
+
+ CreditCard* GetLabeledCreditCard(const char* label) {
+ return test_personal_data_->GetLabeledCreditCard(label);
+ }
+
+ void AddProfile(AutoFillProfile* profile) {
+ test_personal_data_->AddProfile(profile);
+ }
+
+ int GetPackedCreditCardID(int credit_card_id) {
+ return PackGUIDs(IDToGUID(credit_card_id), std::string());
+ }
+
+ virtual int GUIDToID(const std::string& guid) OVERRIDE {
+ if (guid.empty())
+ return 0;
+
+ int id;
+ EXPECT_TRUE(base::StringToInt(guid.substr(guid.rfind("-") + 1), &id));
+ return id;
+ }
+
+ virtual const std::string IDToGUID(int id) OVERRIDE {
+ EXPECT_TRUE(id >= 0);
+ if (id <= 0)
+ return std::string();
+
+ return base::StringPrintf("00000000-0000-0000-0000-%012d", id);
+ }
+
+ private:
+ TestPersonalDataManager* test_personal_data_;
+ bool autofill_enabled_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager);
+};
+
class AutoFillManagerTest : public RenderViewHostTestHarness {
public:
AutoFillManagerTest() {}
@@ -321,23 +496,15 @@ class AutoFillManagerTest : public RenderViewHostTestHarness {
// Test that we return all address profile suggestions when all form fields are
// empty.
TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ const FormField& field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -351,43 +518,38 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
- ASSERT_EQ(2U, labels.size());
- // Inferred labels now include full first relevant field, which in this case
- // the address #1.
- EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(1, unique_ids[0]);
- EXPECT_EQ(2, unique_ids[1]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("Elvis"),
+ ASCIIToUTF16("Charles")
+ };
+ // Inferred labels include full first relevant field, which in this case is
+ // the address line 1.
+ string16 expected_labels[] = {
+ ASCIIToUTF16("3734 Elvis Presley Blvd."),
+ ASCIIToUTF16("123 Apple St.")
+ };
+ string16 expected_icons[] = {string16(), string16()};
+ int expected_unique_ids[] = {1, 2};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we return only matching address profile suggestions when the
// selected form field has been partially filled out.
TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "E", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ FormField field;
+ autofill_test::CreateTestFormField("First Name", "firstname", "E", "text",
+ &field);
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -401,19 +563,19 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(1U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
- ASSERT_EQ(1U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
- ASSERT_EQ(1U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- ASSERT_EQ(1U, unique_ids.size());
- EXPECT_EQ(1, unique_ids[0]);
+
+ string16 expected_values[] = {ASCIIToUTF16("Elvis")};
+ string16 expected_labels[] = {ASCIIToUTF16("3734 Elvis Presley Blvd.")};
+ string16 expected_icons[] = {string16()};
+ int expected_unique_ids[] = {1};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we return no suggestions when the form has no relevant fields.
TEST_F(AutoFillManagerTest, GetProfileSuggestionsUnknownFields) {
+ // Set up our form data.
FormData form;
form.name = ASCIIToUTF16("MyForm");
form.method = ASCIIToUTF16("POST");
@@ -421,81 +583,54 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsUnknownFields) {
form.action = GURL("http://myform.com/submit.html");
form.user_submitted = true;
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "Username", "username", "", "text", &field);
+ FormField field;
+ autofill_test::CreateTestFormField("Username", "username", "", "text",
+ &field);
form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Password", "password", "", "password", &field);
+ autofill_test::CreateTestFormField("Password", "password", "", "password",
+ &field);
form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Quest", "quest", "", "quest", &field);
+ autofill_test::CreateTestFormField("Quest", "quest", "", "quest", &field);
form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Color", "color", "", "text", &field);
+ autofill_test::CreateTestFormField("Color", "color", "", "text", &field);
form.fields.push_back(field);
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- autofill_test::CreateTestFormField(
- "Username", "username", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_FALSE(
- autofill_manager_->GetAutoFillSuggestions(false, field));
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field));
}
// Test that we return no suggestions when autofill is disabled.
TEST_F(AutoFillManagerTest, GetProfileSuggestionsAutofillDisabledByUser) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
// Disable AutoFill.
autofill_manager_->set_autofill_enabled(false);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ const FormField& field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field));
}
// Test that we return a warning explaining that autofill suggestions are
// unavailable when the form method is GET rather than POST.
TEST_F(AutoFillManagerTest, GetProfileSuggestionsMethodGet) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
form.method = ASCIIToUTF16("GET");
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ const FormField& field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -509,23 +644,23 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMethodGet) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(1U, values.size());
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED),
- values[0]);
- ASSERT_EQ(1U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- ASSERT_EQ(1U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- ASSERT_EQ(1U, unique_ids.size());
- EXPECT_EQ(-1, unique_ids[0]);
+
+ string16 expected_values[] = {
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED)
+ };
+ string16 expected_labels[] = {string16()};
+ string16 expected_icons[] = {string16()};
+ int expected_unique_ids[] = {-1};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
// Now add some Autocomplete suggestions. We should return the autocomplete
// suggestions and the warning; these will be culled by the renderer.
process()->sink().ClearMessages();
const int kPageID2 = 2;
rvh()->ResetAutoFillState(kPageID2);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
std::vector<string16> suggestions;
suggestions.push_back(ASCIIToUTF16("Jay"));
@@ -534,50 +669,36 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMethodGet) {
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID2, page_id);
- ASSERT_EQ(3U, values.size());
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED),
- values[0]);
- EXPECT_EQ(ASCIIToUTF16("Jay"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Jason"), values[2]);
- ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
- EXPECT_EQ(string16(), labels[2]);
- ASSERT_EQ(3U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- EXPECT_EQ(string16(), icons[2]);
- ASSERT_EQ(3U, unique_ids.size());
- EXPECT_EQ(-1, unique_ids[0]);
- EXPECT_EQ(0, unique_ids[1]);
- EXPECT_EQ(0, unique_ids[2]);
+
+ string16 expected_values2[] = {
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED),
+ ASCIIToUTF16("Jay"),
+ ASCIIToUTF16("Jason")
+ };
+ string16 expected_labels2[] = {string16(), string16(), string16()};
+ string16 expected_icons2[] = {string16(), string16(), string16()};
+ int expected_unique_ids2[] = {-1, 0, 0};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kPageID2, arraysize(expected_values2), expected_values2,
+ expected_labels2, expected_icons2, expected_unique_ids2);
// Now clear the test profiles and try again -- we shouldn't return a warning.
test_personal_data_->ClearAutoFillProfiles();
- EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field));
}
// Test that we return all credit card profile suggestions when all form fields
// are empty.
TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) {
+ // Set up our form data.
FormData form;
CreateTestCreditCardFormData(&form, true);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ FormField field = form.fields[1];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -591,41 +712,39 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("************8765"), values[1]);
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("*8765"), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
- EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(autofill_manager_->GetPackedCreditCardID(4), unique_ids[0]);
- EXPECT_EQ(autofill_manager_->GetPackedCreditCardID(5), unique_ids[1]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("************3456"),
+ ASCIIToUTF16("************8765")
+ };
+ string16 expected_labels[] = {ASCIIToUTF16("*3456"), ASCIIToUTF16("*8765")};
+ string16 expected_icons[] = {
+ ASCIIToUTF16("visaCC"),
+ ASCIIToUTF16("masterCardCC")
+ };
+ int expected_unique_ids[] = {
+ autofill_manager_->GetPackedCreditCardID(4),
+ autofill_manager_->GetPackedCreditCardID(5)
+ };
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we return only matching credit card profile suggestions when the
// selected form field has been partially filled out.
TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) {
+ // Set up our form data.
FormData form;
CreateTestCreditCardFormData(&form, true);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
+ FormField field;
autofill_test::CreateTestFormField(
"Card Number", "cardnumber", "4", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -639,37 +758,28 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(1U, values.size());
- EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]);
- ASSERT_EQ(1U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
- ASSERT_EQ(1U, icons.size());
- EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
- ASSERT_EQ(1U, unique_ids.size());
- EXPECT_EQ(autofill_manager_->GetPackedCreditCardID(4), unique_ids[0]);
+
+ string16 expected_values[] = {ASCIIToUTF16("************3456")};
+ string16 expected_labels[] = {ASCIIToUTF16("*3456")};
+ string16 expected_icons[] = {ASCIIToUTF16("visaCC")};
+ int expected_unique_ids[] = {autofill_manager_->GetPackedCreditCardID(4)};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we return credit card profile suggestions when the selected form
// field is not the credit card number field.
TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) {
+ // Set up our form data.
FormData form;
CreateTestCreditCardFormData(&form, true);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "Name on Card", "nameoncard", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ const FormField& field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -683,41 +793,37 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[1]);
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("*8765"), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
- EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(autofill_manager_->GetPackedCreditCardID(4), unique_ids[0]);
- EXPECT_EQ(autofill_manager_->GetPackedCreditCardID(5), unique_ids[1]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("Elvis Presley"),
+ ASCIIToUTF16("Buddy Holly")
+ };
+ string16 expected_labels[] = {ASCIIToUTF16("*3456"), ASCIIToUTF16("*8765")};
+ string16 expected_icons[] = {
+ ASCIIToUTF16("visaCC"),
+ ASCIIToUTF16("masterCardCC")
+ };
+ int expected_unique_ids[] = {
+ autofill_manager_->GetPackedCreditCardID(4),
+ autofill_manager_->GetPackedCreditCardID(5)
+ };
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we return a warning explaining that credit card profile suggestions
// are unavailable when the form is not https.
TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
+ // Set up our form data.
FormData form;
CreateTestCreditCardFormData(&form, false);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ const FormField& field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -731,23 +837,23 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(1U, values.size());
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
- values[0]);
- ASSERT_EQ(1U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- ASSERT_EQ(1U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- ASSERT_EQ(1U, unique_ids.size());
- EXPECT_EQ(-1, unique_ids[0]);
+
+ string16 expected_values[] = {
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)
+ };
+ string16 expected_labels[] = {string16()};
+ string16 expected_icons[] = {string16()};
+ int expected_unique_ids[] = {-1};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
// Now add some Autocomplete suggestions. We should show the autocomplete
// suggestions and the warning.
process()->sink().ClearMessages();
const int kPageID2 = 2;
rvh()->ResetAutoFillState(kPageID2);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
std::vector<string16> suggestions;
suggestions.push_back(ASCIIToUTF16("Jay"));
@@ -756,50 +862,35 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID2, page_id);
- ASSERT_EQ(3U, values.size());
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
- values[0]);
- EXPECT_EQ(ASCIIToUTF16("Jay"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Jason"), values[2]);
- ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
- EXPECT_EQ(string16(), labels[2]);
- ASSERT_EQ(3U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- EXPECT_EQ(string16(), icons[2]);
- ASSERT_EQ(3U, unique_ids.size());
- EXPECT_EQ(-1, unique_ids[0]);
- EXPECT_EQ(0, unique_ids[1]);
- EXPECT_EQ(0, unique_ids[2]);
+ string16 expected_values2[] = {
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
+ ASCIIToUTF16("Jay"),
+ ASCIIToUTF16("Jason")
+ };
+ string16 expected_labels2[] = {string16(), string16(), string16()};
+ string16 expected_icons2[] = {string16(), string16(), string16()};
+ int expected_unique_ids2[] = {-1, 0, 0};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kPageID2, arraysize(expected_values2), expected_values2,
+ expected_labels2, expected_icons2, expected_unique_ids2);
// Clear the test credit cards and try again -- we shouldn't return a warning.
test_personal_data_->ClearCreditCards();
- EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field));
}
// Test that we return profile and credit card suggestions for combined forms.
TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
CreateTestCreditCardFormData(&form, true);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ FormField field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -813,27 +904,27 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
- ASSERT_EQ(2U, labels.size());
- // Inferred labels now include full first relevant field, which in this case
- // the address #1.
- EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(1, unique_ids[0]);
- EXPECT_EQ(2, unique_ids[1]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("Elvis"),
+ ASCIIToUTF16("Charles")
+ };
+ string16 expected_labels[] = {
+ ASCIIToUTF16("3734 Elvis Presley Blvd."),
+ ASCIIToUTF16("123 Apple St.")
+ };
+ string16 expected_icons[] = {string16(), string16()};
+ int expected_unique_ids[] = {1, 2};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
process()->sink().ClearMessages();
+ const int kPageID2 = 2;
autofill_test::CreateTestFormField(
"Card Number", "cardnumber", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ rvh()->ResetAutoFillState(kPageID2);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -843,19 +934,23 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
page_id = 0;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("************8765"), values[1]);
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("*8765"), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
- EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(autofill_manager_->GetPackedCreditCardID(4), unique_ids[0]);
- EXPECT_EQ(autofill_manager_->GetPackedCreditCardID(5), unique_ids[1]);
+
+ string16 expected_values2[] = {
+ ASCIIToUTF16("************3456"),
+ ASCIIToUTF16("************8765")
+ };
+ string16 expected_labels2[] = {ASCIIToUTF16("*3456"), ASCIIToUTF16("*8765")};
+ string16 expected_icons2[] = {
+ ASCIIToUTF16("visaCC"),
+ ASCIIToUTF16("masterCardCC")
+ };
+ int expected_unique_ids2[] = {
+ autofill_manager_->GetPackedCreditCardID(4),
+ autofill_manager_->GetPackedCreditCardID(5)
+ };
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kPageID2, arraysize(expected_values2), expected_values2,
+ expected_labels2, expected_icons2, expected_unique_ids2);
}
// Test that for non-https forms with both address and credit card fields, we
@@ -863,24 +958,16 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
// should return a warning explaining that credit card profile suggestions are
// unavailable when the form is not https.
TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
CreateTestCreditCardFormData(&form, false);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ FormField field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -894,27 +981,27 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
- ASSERT_EQ(2U, labels.size());
- // Inferred labels now include full first relevant field, which in this case
- // the address #1.
- EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(1, unique_ids[0]);
- EXPECT_EQ(2, unique_ids[1]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("Elvis"),
+ ASCIIToUTF16("Charles")
+ };
+ string16 expected_labels[] = {
+ ASCIIToUTF16("3734 Elvis Presley Blvd."),
+ ASCIIToUTF16("123 Apple St.")
+ };
+ string16 expected_icons[] = {string16(), string16()};
+ int expected_unique_ids[] = {1, 2};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
process()->sink().ClearMessages();
autofill_test::CreateTestFormField(
"Card Number", "cardnumber", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ const int kPageID2 = 2;
+ rvh()->ResetAutoFillState(kPageID2);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -923,41 +1010,33 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
// Test that we sent the right message to the renderer.
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(1U, values.size());
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
- values[0]);
- ASSERT_EQ(1U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- ASSERT_EQ(1U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- ASSERT_EQ(1U, unique_ids.size());
- EXPECT_EQ(-1, unique_ids[0]);
+
+ string16 expected_values2[] = {
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION)
+ };
+ string16 expected_labels2[] = {string16()};
+ string16 expected_icons2[] = {string16()};
+ int expected_unique_ids2[] = {-1};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kPageID2, arraysize(expected_values2), expected_values2,
+ expected_labels2, expected_icons2, expected_unique_ids2);
// Clear the test credit cards and try again -- we shouldn't return a warning.
test_personal_data_->ClearCreditCards();
- EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field));
}
// Test that we correctly combine autofill and autocomplete suggestions.
TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field));
+ const FormField& field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// Add some Autocomplete suggestions.
// This triggers the combined message send.
@@ -976,49 +1055,40 @@ TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(4U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Jay"), values[2]);
- EXPECT_EQ(ASCIIToUTF16("Jason"), values[3]);
- ASSERT_EQ(4U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
- EXPECT_EQ(string16(), labels[2]);
- EXPECT_EQ(string16(), labels[3]);
- ASSERT_EQ(4U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- EXPECT_EQ(string16(), icons[2]);
- EXPECT_EQ(string16(), icons[3]);
- ASSERT_EQ(4U, unique_ids.size());
- EXPECT_EQ(1, unique_ids[0]);
- EXPECT_EQ(2, unique_ids[1]);
- EXPECT_EQ(0, unique_ids[2]);
- EXPECT_EQ(0, unique_ids[3]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("Elvis"),
+ ASCIIToUTF16("Charles"),
+ ASCIIToUTF16("Jay"),
+ ASCIIToUTF16("Jason")
+ };
+ string16 expected_labels[] = {
+ ASCIIToUTF16("3734 Elvis Presley Blvd."),
+ ASCIIToUTF16("123 Apple St."),
+ string16(),
+ string16()
+ };
+ string16 expected_icons[] = {string16(), string16(), string16(), string16()};
+ int expected_unique_ids[] = {1, 2, 0, 0};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we return autocomplete-like suggestions when trying to autofill
-// already filled fields.
-TEST_F(AutoFillManagerTest, GetFieldSuggestionsFieldIsAutoFilled) {
+// already filled forms.
+TEST_F(AutoFillManagerTest, GetFieldSuggestionsWhenFormIsAutoFilled) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(true, field));
+ // Mark one of the fields as filled.
+ form.fields[2].set_autofilled(true);
+ const FormField& field = form.fields[0];
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -1032,41 +1102,33 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsFieldIsAutoFilled) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(1, unique_ids[0]);
- EXPECT_EQ(2, unique_ids[1]);
+ string16 expected_values[] = {
+ ASCIIToUTF16("Elvis"),
+ ASCIIToUTF16("Charles")
+ };
+ string16 expected_labels[] = {string16(), string16()};
+ string16 expected_icons[] = {string16(), string16()};
+ int expected_unique_ids[] = {1, 2};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that nothing breaks when there are autocomplete suggestions but no
// autofill suggestions.
TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
- autofill_manager_->FormsSeen(forms);
-
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
+ FormField field;
autofill_test::CreateTestFormField(
"Some Field", "somefield", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(true, field));
+ form.fields.push_back(field);
+ std::vector<FormData> forms(1, form);
+ autofill_manager_->FormsSeen(forms);
+
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field));
// Add some Autocomplete suggestions.
// This triggers the combined message send.
@@ -1083,30 +1145,26 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("one"), values[0]);
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("two"), values[1]);
- EXPECT_EQ(string16(), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(0, unique_ids[0]);
- EXPECT_EQ(0, unique_ids[1]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("one"),
+ ASCIIToUTF16("two")
+ };
+ string16 expected_labels[] = {string16(), string16()};
+ string16 expected_icons[] = {string16(), string16()};
+ int expected_unique_ids[] = {0, 0};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we do not return duplicate values drawn from multiple profiles when
// filling an already filled field.
TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
// |profile| will be owned by the mock PersonalDataManager.
@@ -1116,15 +1174,10 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
profile->set_guid("00000000-0000-0000-0000-000000000101");
autofill_manager_->AddProfile(profile);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- rvh()->ResetAutoFillState(kPageID);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(true, field));
+ FormField& field = form.fields[0];
+ field.set_autofilled(true);
+ rvh()->ResetAutoFillState(kDefaultPageID);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
@@ -1138,296 +1191,173 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
std::vector<int> unique_ids;
EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &icons,
&unique_ids));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(string16(), labels[0]);
- EXPECT_EQ(string16(), labels[1]);
- ASSERT_EQ(2U, icons.size());
- EXPECT_EQ(string16(), icons[0]);
- EXPECT_EQ(string16(), icons[1]);
- ASSERT_EQ(2U, unique_ids.size());
- EXPECT_EQ(1, unique_ids[0]);
- EXPECT_EQ(2, unique_ids[1]);
+
+ string16 expected_values[] = {
+ ASCIIToUTF16("Elvis"),
+ ASCIIToUTF16("Charles")
+ };
+ string16 expected_labels[] = {string16(), string16()};
+ string16 expected_icons[] = {string16(), string16()};
+ int expected_unique_ids[] = {1, 2};
+ ExpectSuggestions(page_id, values, labels, icons, unique_ids,
+ kDefaultPageID, arraysize(expected_values), expected_values,
+ expected_labels, expected_icons, expected_unique_ids);
}
// Test that we correctly fill an address form.
TEST_F(AutoFillManagerTest, FillAddressForm) {
- // |profile| will be owned by the mock PersonalDataManager.
- AutoFillProfile* profile = new AutoFillProfile;
- autofill_test::SetProfileInfo(profile, "Home; 8765", "Joe", "", "Ely",
- "flatlander@gmail.com", "MCA",
- "916 16th St.", "Apt. 6", "Lubbock",
- "Texas", "79401", "USA",
- "12345678901", "");
- profile->set_guid("00000000-0000-0000-0000-000000000007");
- autofill_manager_->AddProfile(profile);
-
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
+ std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form, autofill_manager_->PackGUIDs(std::string(),
- profile->guid())));
+ kDefaultPageID, form, form.fields[0],
+ autofill_manager_->PackGUIDs(std::string(), guid)));
int page_id = 0;
FormData results;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
- EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
- EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("http://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("http://myform.com/submit.html"), results.action);
- ASSERT_EQ(11U, results.fields.size());
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "Joe", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "Ely", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
- autofill_test::CreateTestFormField(
- "Address Line 1", "addr1", "916 16th St.", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
- autofill_test::CreateTestFormField(
- "Address Line 2", "addr2", "Apt. 6", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4]));
- autofill_test::CreateTestFormField(
- "City", "city", "Lubbock", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[5]));
- autofill_test::CreateTestFormField(
- "State", "state", "Texas", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[6]));
- autofill_test::CreateTestFormField(
- "Postal Code", "zipcode", "79401", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[7]));
- autofill_test::CreateTestFormField(
- "Country", "country", "USA", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[8]));
- autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "12345678901", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[9]));
- autofill_test::CreateTestFormField(
- "Email", "email", "flatlander@gmail.com", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[10]));
+ ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false);
}
// Test that we correctly fill a credit card form.
TEST_F(AutoFillManagerTest, FillCreditCardForm) {
+ // Set up our form data.
FormData form;
CreateTestCreditCardFormData(&form, true);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
+ std::string guid = autofill_manager_->GetLabeledCreditCard("First")->guid();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form,
- autofill_manager_->PackGUIDs("00000000-0000-0000-0000-000000000004",
- std::string())));
+ kDefaultPageID, form, *form.fields.begin(),
+ autofill_manager_->PackGUIDs(guid, std::string())));
int page_id = 0;
FormData results;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
- EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
- EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("https://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("https://myform.com/submit.html"), results.action);
- ASSERT_EQ(4U, results.fields.size());
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "Name on Card", "nameoncard", "Elvis Presley", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
- autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "4234567890123456", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
- autofill_test::CreateTestFormField(
- "Expiration Date", "ccmonth", "04", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
- autofill_test::CreateTestFormField(
- "", "ccyear", "2012", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
+ ExpectFilledCreditCardFormElvis(page_id, results, kDefaultPageID, false);
}
// Test that we correctly fill a combined address and credit card form.
TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) {
- // |profile| will be owned by the mock PersonalDataManager.
- AutoFillProfile* profile = new AutoFillProfile;
- autofill_test::SetProfileInfo(profile, "Home; 8765", "Joe", "", "Ely",
- "flatlander@gmail.com", "MCA",
- "916 16th St.", "Apt. 6", "Lubbock",
- "Texas", "79401", "USA",
- "12345678901", "");
- profile->set_guid("00000000-0000-0000-0000-000000000008");
- autofill_manager_->AddProfile(profile);
-
+ // Set up our form data.
FormData form;
CreateTestAddressFormData(&form);
CreateTestCreditCardFormData(&form, true);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
// First fill the address data.
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
+ std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form,
- autofill_manager_->PackGUIDs(std::string(),
- "00000000-0000-0000-0000-000000000008")));
+ kDefaultPageID, form, form.fields[0],
+ autofill_manager_->PackGUIDs(std::string(), guid)));
int page_id = 0;
FormData results;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
- EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
- EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("https://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("https://myform.com/submit.html"), results.action);
- ASSERT_EQ(15U, results.fields.size());
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "Joe", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "Ely", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
- autofill_test::CreateTestFormField(
- "Address Line 1", "addr1", "916 16th St.", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
- autofill_test::CreateTestFormField(
- "Address Line 2", "addr2", "Apt. 6", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4]));
- autofill_test::CreateTestFormField(
- "City", "city", "Lubbock", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[5]));
- autofill_test::CreateTestFormField(
- "State", "state", "Texas", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[6]));
- autofill_test::CreateTestFormField(
- "Postal Code", "zipcode", "79401", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[7]));
- autofill_test::CreateTestFormField(
- "Country", "country", "USA", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[8]));
- autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "12345678901", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[9]));
- autofill_test::CreateTestFormField(
- "Email", "email", "flatlander@gmail.com", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[10]));
- autofill_test::CreateTestFormField(
- "Name on Card", "nameoncard", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[11]));
- autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[12]));
- autofill_test::CreateTestFormField(
- "Expiration Date", "ccmonth", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[13]));
- autofill_test::CreateTestFormField(
- "", "ccyear", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[14]));
+ {
+ SCOPED_TRACE("Address");
+ ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, true);
+ }
// Now fill the credit card data.
process()->sink().ClearMessages();
+ const int kPageID2 = 2;
+ guid = autofill_manager_->GetLabeledCreditCard("First")->guid();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form,
- autofill_manager_->PackGUIDs("00000000-0000-0000-0000-000000000004",
- std::string())));
+ kPageID2, form, form.fields.back(),
+ autofill_manager_->PackGUIDs(guid, std::string())));
+
+ page_id = 0;
+ EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
+ {
+ SCOPED_TRACE("Credit card");
+ ExpectFilledCreditCardFormElvis(page_id, results, kPageID2, true);
+ }
+}
+// Test that we correctly fill a previously auto-filled form.
+TEST_F(AutoFillManagerTest, FillAutoFilledForm) {
+ // Set up our form data.
+ FormData form;
+ CreateTestAddressFormData(&form);
+ // Mark one of the address fields as autofilled.
+ form.fields[4].set_autofilled(true);
+ CreateTestCreditCardFormData(&form, true);
+ std::vector<FormData> forms(1, form);
+ autofill_manager_->FormsSeen(forms);
+
+ // First fill the address data.
+ std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid();
+ EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
+ kDefaultPageID, form, *form.fields.begin(),
+ autofill_manager_->PackGUIDs(std::string(), guid)));
+
+ int page_id = 0;
+ FormData results;
+ EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
+ {
+ SCOPED_TRACE("Address");
+ ExpectFilledForm(page_id, results, kDefaultPageID,
+ "Elvis", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", true, true);
+ }
+
+ // Now fill the credit card data.
+ process()->sink().ClearMessages();
+ const int kPageID2 = 2;
+ guid = autofill_manager_->GetLabeledCreditCard("First")->guid();
+ EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
+ kPageID2, form, form.fields.back(),
+ autofill_manager_->PackGUIDs(guid, std::string())));
page_id = 0;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
- EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
- EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("https://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("https://myform.com/submit.html"), results.action);
- ASSERT_EQ(15U, results.fields.size());
+ {
+ SCOPED_TRACE("Credit card 1");
+ ExpectFilledCreditCardFormElvis(page_id, results, kPageID2, true);
+ }
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
- autofill_test::CreateTestFormField(
- "Address Line 1", "addr1", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
- autofill_test::CreateTestFormField(
- "Address Line 2", "addr2", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4]));
- autofill_test::CreateTestFormField(
- "City", "city", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[5]));
- autofill_test::CreateTestFormField(
- "State", "state", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[6]));
- autofill_test::CreateTestFormField(
- "Postal Code", "zipcode", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[7]));
- autofill_test::CreateTestFormField(
- "Country", "country", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[8]));
- autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[9]));
- autofill_test::CreateTestFormField(
- "Email", "email", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[10]));
- autofill_test::CreateTestFormField(
- "Name on Card", "nameoncard", "Elvis Presley", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[11]));
- autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "4234567890123456", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[12]));
- autofill_test::CreateTestFormField(
- "Expiration Date", "ccmonth", "04", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[13]));
- autofill_test::CreateTestFormField(
- "", "ccyear", "2012", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[14]));
+ // Now set the credit card fields to also be auto-filled, and try again to
+ // fill the credit card data
+ for (std::vector<FormField>::iterator iter = form.fields.begin();
+ iter != form.fields.end();
+ ++iter){
+ iter->set_autofilled(true);
+ }
+
+ process()->sink().ClearMessages();
+ const int kPageID3 = 3;
+ EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
+ kPageID3, form, *form.fields.rbegin(),
+ autofill_manager_->PackGUIDs(guid, std::string())));
+
+ page_id = 0;
+ EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
+ {
+ SCOPED_TRACE("Credit card 2");
+ ExpectFilledForm(page_id, results, kPageID3,
+ "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "2012", true, true);
+ }
}
// Test that we correctly fill a phone number split across multiple fields.
TEST_F(AutoFillManagerTest, FillPhoneNumber) {
+ // Set up our form data.
FormData form;
-
form.name = ASCIIToUTF16("MyPhoneForm");
form.method = ASCIIToUTF16("POST");
form.origin = GURL("http://myform.com/phone_form.html");
form.action = GURL("http://myform.com/phone_submit.html");
form.user_submitted = true;
- webkit_glue::FormField field;
-
+ FormField field;
autofill_test::CreateTestFormField(
"country code", "country code", "", "text", &field);
field.set_max_length(1);
@@ -1449,13 +1379,11 @@ TEST_F(AutoFillManagerTest, FillPhoneNumber) {
field.set_max_length(3);
form.fields.push_back(field);
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
AutoFillProfile *work_profile = autofill_manager_->GetLabeledProfile("Work");
- EXPECT_TRUE(work_profile != NULL);
+ ASSERT_TRUE(work_profile != NULL);
const AutoFillType phone_type(PHONE_HOME_NUMBER);
string16 saved_phone = work_profile->GetFieldText(phone_type);
@@ -1468,7 +1396,7 @@ TEST_F(AutoFillManagerTest, FillPhoneNumber) {
int page_id = 100 - i;
process()->sink().ClearMessages();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- page_id, form,
+ page_id, form, *form.fields.begin(),
autofill_manager_->PackGUIDs(std::string(), work_profile->guid())));
page_id = 0;
FormData results;
@@ -1489,139 +1417,61 @@ TEST_F(AutoFillManagerTest, FillPhoneNumber) {
// Test that we can still fill a form when a field has been removed from it.
TEST_F(AutoFillManagerTest, FormChangesRemoveField) {
+ // Set up our form data.
FormData form;
- form.name = ASCIIToUTF16("MyForm");
- form.method = ASCIIToUTF16("POST");
- form.origin = GURL("http://myform.com/form.html");
- form.action = GURL("http://myform.com/submit.html");
- form.user_submitted = true;
+ CreateTestAddressFormData(&form);
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "", "text", &field);
- form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "", "text", &field);
- form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "", "text", &field);
- form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Email", "email", "", "text", &field);
- form.fields.push_back(field);
+ // Add a field -- we'll remove it again later.
+ FormField field;
+ autofill_test::CreateTestFormField("Some", "field", "", "text", &field);
+ form.fields.insert(form.fields.begin() + 3, field);
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // Now, after the call to |FormsSeen| we remove the phone number field before
- // filling.
+ // Now, after the call to |FormsSeen|, we remove the field before filling.
form.fields.erase(form.fields.begin() + 3);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
+ std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form,
- autofill_manager_->PackGUIDs(std::string(),
- "00000000-0000-0000-0000-000000000001")));
+ kDefaultPageID, form, form.fields[0],
+ autofill_manager_->PackGUIDs(std::string(), guid)));
int page_id = 0;
FormData results;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
- EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
- EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("http://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("http://myform.com/submit.html"), results.action);
- EXPECT_TRUE(results.user_submitted);
- ASSERT_EQ(4U, results.fields.size());
-
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "Elvis", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "Aaron", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "Presley", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
- autofill_test::CreateTestFormField(
- "Email", "email", "theking@gmail.com", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
+ ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false);
}
// Test that we can still fill a form when a field has been added to it.
TEST_F(AutoFillManagerTest, FormChangesAddField) {
+ // The offset of the fax field in the address form.
+ const int kFaxFieldOffset = 10;
+
+ // Set up our form data.
FormData form;
- form.name = ASCIIToUTF16("MyForm");
- form.method = ASCIIToUTF16("POST");
- form.origin = GURL("http://myform.com/form.html");
- form.action = GURL("http://myform.com/submit.html");
- form.user_submitted = true;
+ CreateTestAddressFormData(&form);
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "", "text", &field);
- form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "", "text", &field);
- // Note: absent phone number. Adding this below.
- form.fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Email", "email", "", "text", &field);
- form.fields.push_back(field);
+ // Remove the fax field -- we'll add it back later.
+ std::vector<FormField>::iterator pos = form.fields.begin() + kFaxFieldOffset;
+ FormField field = *pos;
+ pos = form.fields.erase(pos);
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
+ std::vector<FormData> forms(1, form);
autofill_manager_->FormsSeen(forms);
- // Now, after the call to |FormsSeen| we add the phone number field before
- // filling.
- autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "", "text", &field);
- form.fields.insert(form.fields.begin() + 3, field);
+ // Now, after the call to |FormsSeen|, we restore the field before filling.
+ form.fields.insert(pos, field);
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
+ std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form,
- autofill_manager_->PackGUIDs(std::string(),
- "00000000-0000-0000-0000-000000000001")));
+ kDefaultPageID, form, form.fields[0],
+ autofill_manager_->PackGUIDs(std::string(), guid)));
int page_id = 0;
FormData results;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
- EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
- EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("http://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("http://myform.com/submit.html"), results.action);
- EXPECT_TRUE(results.user_submitted);
- ASSERT_EQ(5U, results.fields.size());
-
- autofill_test::CreateTestFormField(
- "First Name", "firstname", "Elvis", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "Aaron", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "Presley", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
- autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
- autofill_test::CreateTestFormField(
- "Email", "email", "theking@gmail.com", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4]));
+ ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false);
}
TEST_F(AutoFillManagerTest, HiddenFields) {
@@ -1632,7 +1482,7 @@ TEST_F(AutoFillManagerTest, HiddenFields) {
form.action = GURL("http://myform.com/submit.html");
form.user_submitted = true;
- webkit_glue::FormField field;
+ FormField field;
autofill_test::CreateTestFormField(
"E-mail", "one", "one", "hidden", &field);
form.fields.push_back(field);
@@ -1643,7 +1493,7 @@ TEST_F(AutoFillManagerTest, HiddenFields) {
"E-mail", "three", "three", "hidden", &field);
form.fields.push_back(field);
- // Set up our FormStructures.
+ // Set up our form data.
std::vector<FormData> forms;
forms.push_back(form);
autofill_manager_->FormsSeen(forms);
diff --git a/chrome/browser/autofill/credit_card_field_unittest.cc b/chrome/browser/autofill/credit_card_field_unittest.cc
index c333032..8c41b4f 100644
--- a/chrome/browser/autofill/credit_card_field_unittest.cc
+++ b/chrome/browser/autofill/credit_card_field_unittest.cc
@@ -46,14 +46,16 @@ TEST_F(CreditCardFieldTest, ParseCreditCardNoNumber) {
ASCIIToUTF16("ccmonth"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("year1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -67,7 +69,8 @@ TEST_F(CreditCardFieldTest, ParseCreditCardNoDate) {
ASCIIToUTF16("card_number"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("number1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -81,21 +84,24 @@ TEST_F(CreditCardFieldTest, ParseMiniumCreditCard) {
ASCIIToUTF16("card_number"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("year1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -120,7 +126,8 @@ TEST_F(CreditCardFieldTest, ParseMiniumCreditCardEcml) {
ASCIIToUTF16(kEcmlCardNumber),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(
@@ -128,7 +135,8 @@ TEST_F(CreditCardFieldTest, ParseMiniumCreditCardEcml) {
ASCIIToUTF16(kEcmlCardExpireMonth),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(
@@ -136,7 +144,8 @@ TEST_F(CreditCardFieldTest, ParseMiniumCreditCardEcml) {
ASCIIToUTF16(kEcmlCardExpireYear),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("year1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -161,35 +170,40 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCard) {
ASCIIToUTF16("name on card"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("year1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("cvc1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -220,14 +234,16 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCardEcml) {
ASCIIToUTF16(kEcmlCardHolder),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16(kEcmlCardNumber),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(
@@ -235,7 +251,8 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCardEcml) {
ASCIIToUTF16(kEcmlCardExpireMonth),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(
@@ -243,7 +260,8 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCardEcml) {
ASCIIToUTF16(kEcmlCardExpireYear),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("year1")));
list_.push_back(
new AutoFillField(
@@ -251,7 +269,8 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCardEcml) {
ASCIIToUTF16(kEcmlCardVerification),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("cvc1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -282,14 +301,16 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear) {
ASCIIToUTF16("Name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("Card"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("number")));
list_.push_back(
new AutoFillField(
@@ -297,7 +318,8 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear) {
ASCIIToUTF16("ExpDate"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("month")));
list_.push_back(
new AutoFillField(
@@ -305,7 +327,8 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear) {
ASCIIToUTF16("ExpDate"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("year")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -333,14 +356,16 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear2) {
ASCIIToUTF16("Name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("Card"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("number")));
list_.push_back(
new AutoFillField(
@@ -348,7 +373,8 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear2) {
ASCIIToUTF16("ExpDate"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("month")));
list_.push_back(
new AutoFillField(
@@ -356,7 +382,8 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear2) {
ASCIIToUTF16("ExpDate"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("year")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/fax_field_unittest.cc b/chrome/browser/autofill/fax_field_unittest.cc
index 0ba21c0..724456a 100644
--- a/chrome/browser/autofill/fax_field_unittest.cc
+++ b/chrome/browser/autofill/fax_field_unittest.cc
@@ -46,7 +46,8 @@ TEST_F(FaxFieldTest, ParseOneLineFax) {
ASCIIToUTF16("faxnumber"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("fax1")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc
index 4097a69..96d8fff 100644
--- a/chrome/browser/autofill/form_structure_unittest.cc
+++ b/chrome/browser/autofill/form_structure_unittest.cc
@@ -48,17 +48,20 @@ TEST(FormStructureTest, FieldCount) {
ASCIIToUTF16("username"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
ASCIIToUTF16("password"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
FormStructure form_structure(form);
// All fields are counted.
@@ -72,22 +75,26 @@ TEST(FormStructureTest, AutoFillCount) {
ASCIIToUTF16("username"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
ASCIIToUTF16("password"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
ASCIIToUTF16("select-one"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
FormStructure form_structure(form);
// Only text and select fields that are heuristically matched are counted.
@@ -113,12 +120,14 @@ TEST(FormStructureTest, HasAutoFillableValues) {
ASCIIToUTF16("Submit1"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit2"),
ASCIIToUTF16("dummy value"),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -127,12 +136,14 @@ TEST(FormStructureTest, HasAutoFillableValues) {
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
ASCIIToUTF16("select-one"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -141,12 +152,14 @@ TEST(FormStructureTest, HasAutoFillableValues) {
ASCIIToUTF16("firstname"),
ASCIIToUTF16("John"),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
ASCIIToUTF16("Dear"),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->HasAutoFillableValues());
@@ -157,12 +170,14 @@ TEST(FormStructureTest, HasAutoFillableValues) {
ASCIIToUTF16("Field1"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Field2"),
ASCIIToUTF16("dummy value"),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -172,7 +187,8 @@ TEST(FormStructureTest, HasAutoFillableValues) {
ASCIIToUTF16("fullname"),
ASCIIToUTF16("John Dear"),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->HasAutoFillableValues());
}
@@ -187,17 +203,20 @@ TEST(FormStructureTest, IsAutoFillable) {
ASCIIToUTF16("username"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
ASCIIToUTF16("password"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable(true));
@@ -206,12 +225,14 @@ TEST(FormStructureTest, IsAutoFillable) {
ASCIIToUTF16("firstname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable(true));
@@ -220,7 +241,8 @@ TEST(FormStructureTest, IsAutoFillable) {
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
@@ -252,47 +274,56 @@ TEST(FormStructureTest, HeuristicsContactInfo) {
ASCIIToUTF16("firstname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
ASCIIToUTF16("fax"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
ASCIIToUTF16("zipcode"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
@@ -330,87 +361,104 @@ TEST(FormStructureTest, HeuristicsHiddenFields) {
ASCIIToUTF16("firstname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden1"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden2"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden3"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden4"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
ASCIIToUTF16("fax"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden5"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden6"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden7"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
ASCIIToUTF16("zipcode"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("hidden8"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
@@ -449,61 +497,71 @@ TEST(FormStructureTest, HeuristicsSample8) {
ASCIIToUTF16("bill.first"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Your Last Name:"),
ASCIIToUTF16("bill.last"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 1:"),
ASCIIToUTF16("bill.street1"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 2:"),
ASCIIToUTF16("bill.street2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City:"),
ASCIIToUTF16("bill.city"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State (U.S.):"),
ASCIIToUTF16("bill.state"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip/Postal Code:"),
ASCIIToUTF16("BillTo.PostalCode"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Country:"),
ASCIIToUTF16("bill.country"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Phone Number:"),
ASCIIToUTF16("BillTo.Phone"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(10U, form_structure->field_count());
@@ -543,45 +601,52 @@ TEST(FormStructureTest, HeuristicsSample6) {
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Full name"),
ASCIIToUTF16("name"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Company"),
ASCIIToUTF16("company"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
// TODO(jhawkins): Add state select control.
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip Code"),
ASCIIToUTF16("Home.PostalCode"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
// TODO(jhawkins): Phone number.
form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
ASCIIToUTF16("continue"),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(7U, form_structure->field_count());
@@ -615,47 +680,56 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) {
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
string16(),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(9U, form_structure->field_count());
@@ -691,32 +765,38 @@ TEST(FormStructureTest, HeuristicsCreditCardInfo) {
ASCIIToUTF16("name on card"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(6U, form_structure->field_count());
@@ -746,39 +826,46 @@ TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) {
ASCIIToUTF16("name on card"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
// This is not a field we know how to process. But we should skip over it
// and process the other fields in the card block.
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Type"),
ASCIIToUTF16("card_type"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(7U, form_structure->field_count());
@@ -811,25 +898,29 @@ TEST(FormStructureTest, ThreeAddressLines) {
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line3"),
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(4U, form_structure->field_count());
@@ -857,25 +948,29 @@ TEST(FormStructureTest, BillingAndShippingAddresses) {
ASCIIToUTF16("shipping.address.addressLine1"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("shipping.address.addressLine2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
ASCIIToUTF16("billing.address.addressLine1"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("billing.address.addressLine2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(4U, form_structure->field_count());
@@ -907,25 +1002,29 @@ TEST(FormStructureTest, ThreeAddressLinesExpedia) {
ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads1"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Suite or Apt:"),
ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adap"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street address second line"),
ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City:"),
ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(4U, form_structure->field_count());
@@ -954,19 +1053,22 @@ TEST(FormStructureTest, TwoAddressLinesEbay) {
ASCIIToUTF16("address1"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Floor number, suite number, etc"),
ASCIIToUTF16("address2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(3U, form_structure->field_count());
@@ -990,19 +1092,22 @@ TEST(FormStructureTest, HeuristicsStateWithProvince) {
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State/Province/Region"),
ASCIIToUTF16("State"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(3U, form_structure->field_count());
@@ -1027,67 +1132,78 @@ TEST(FormStructureTest, HeuristicsWithBilling) {
ASCIIToUTF16("editBillingAddress$firstNameBox"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Last Name*:"),
ASCIIToUTF16("editBillingAddress$lastNameBox"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Company Name:"),
ASCIIToUTF16("editBillingAddress$companyBox"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address*:"),
ASCIIToUTF16("editBillingAddress$addressLine1Box"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Apt/Suite :"),
ASCIIToUTF16("editBillingAddress$addressLine2Box"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City*:"),
ASCIIToUTF16("editBillingAddress$cityBox"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State/Province*:"),
ASCIIToUTF16("editBillingAddress$stateDropDown"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Country*:"),
ASCIIToUTF16("editBillingAddress$countryDropDown"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Postal Code*:"),
ASCIIToUTF16("editBillingAddress$zipCodeBox"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Phone*:"),
ASCIIToUTF16("editBillingAddress$phoneBox"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Email Address*:"),
ASCIIToUTF16("email$emailBox"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(11U, form_structure->field_count());
@@ -1118,25 +1234,29 @@ TEST(FormStructureTest, ThreePartPhoneNumber) {
ASCIIToUTF16("dayphone1"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("-"),
ASCIIToUTF16("dayphone2"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("-"),
ASCIIToUTF16("dayphone3"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("ext.:"),
ASCIIToUTF16("dayphone4"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
ASSERT_EQ(4U, form_structure->field_count());
@@ -1162,52 +1282,62 @@ TEST(FormStructureTest, MatchSpecificInputTypes) {
ASCIIToUTF16("firstname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("email"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
ASCIIToUTF16("number"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Country"),
ASCIIToUTF16("country"),
string16(),
ASCIIToUTF16("select-one"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
ASCIIToUTF16("fax"),
string16(),
ASCIIToUTF16("tel"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("radio"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
ASCIIToUTF16("checkbox"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("State"),
ASCIIToUTF16("state"),
string16(),
ASCIIToUTF16("hidden"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
ASCIIToUTF16("submit"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
@@ -1246,27 +1376,32 @@ TEST(FormStructureTest, HeuristicsInfernoCC) {
ASCIIToUTF16("name_on_card"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("billing_address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Date"),
ASCIIToUTF16("expiration_month"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Year"),
ASCIIToUTF16("expiration_year"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
@@ -1295,32 +1430,38 @@ TEST(FormStructureTest, CVCCodeClash) {
ASCIIToUTF16("ccnumber"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First name"),
ASCIIToUTF16("first_name"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last name"),
ASCIIToUTF16("last_name"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration date"),
ASCIIToUTF16("ccexpiresmonth"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16(""),
ASCIIToUTF16("ccexpiresyear"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("cvc number"),
ASCIIToUTF16("csc"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable(true));
@@ -1350,27 +1491,32 @@ TEST(FormStructureTest, EncodeQueryRequest) {
ASCIIToUTF16("name_on_card"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("billing_address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Date"),
ASCIIToUTF16("expiration_month"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Year"),
ASCIIToUTF16("expiration_year"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
ScopedVector<FormStructure> forms;
forms.push_back(new FormStructure(form));
std::vector<std::string> encoded_signatures;
@@ -1404,7 +1550,8 @@ TEST(FormStructureTest, EncodeQueryRequest) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
}
forms.push_back(new FormStructure(form));
@@ -1436,7 +1583,8 @@ TEST(FormStructureTest, EncodeQueryRequest) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
}
forms.push_back(new FormStructure(form));
@@ -1466,49 +1614,56 @@ TEST(FormStructureTest, EncodeUploadRequest) {
ASCIIToUTF16("firstname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(NAME_FIRST);
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(NAME_LAST);
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
ASCIIToUTF16("email"),
string16(),
ASCIIToUTF16("email"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(EMAIL_ADDRESS);
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
ASCIIToUTF16("number"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(PHONE_HOME_WHOLE_NUMBER);
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Country"),
ASCIIToUTF16("country"),
string16(),
ASCIIToUTF16("select-one"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_COUNTRY);
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
ASCIIToUTF16("fax"),
string16(),
ASCIIToUTF16("tel"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(PHONE_FAX_WHOLE_NUMBER);
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("radio"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_LINE1);
form_structure.reset(new FormStructure(form));
@@ -1544,7 +1699,8 @@ TEST(FormStructureTest, EncodeUploadRequest) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_LINE1);
possible_field_types.back().insert(ADDRESS_HOME_LINE2);
@@ -1588,7 +1744,8 @@ TEST(FormStructureTest, EncodeUploadRequest) {
ASCIIToUTF16("address"),
string16(),
ASCIIToUTF16("text"),
- 0));
+ 0,
+ false));
possible_field_types.push_back(FieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_LINE1);
possible_field_types.back().insert(ADDRESS_HOME_LINE2);
diff --git a/chrome/browser/autofill/name_field_unittest.cc b/chrome/browser/autofill/name_field_unittest.cc
index 03cbec3..ce64c5f 100644
--- a/chrome/browser/autofill/name_field_unittest.cc
+++ b/chrome/browser/autofill/name_field_unittest.cc
@@ -32,21 +32,24 @@ TEST_F(NameFieldTest, FirstMiddleLast) {
ASCIIToUTF16("First"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Middle Name"),
ASCIIToUTF16("Middle"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("Last"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -70,21 +73,24 @@ TEST_F(NameFieldTest, FirstMiddleLast2) {
ASCIIToUTF16("firstName"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("middleName"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("lastName"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -108,14 +114,16 @@ TEST_F(NameFieldTest, FirstLast) {
ASCIIToUTF16("first_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("last_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -136,14 +144,16 @@ TEST_F(NameFieldTest, FirstLast2) {
ASCIIToUTF16("first_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Name"),
ASCIIToUTF16("last_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -164,21 +174,24 @@ TEST_F(NameFieldTest, FirstLastMiddleWithSpaces) {
ASCIIToUTF16("first name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Middle Name"),
ASCIIToUTF16("middle name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("last name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -202,14 +215,16 @@ TEST_F(NameFieldTest, FirstLastEmpty) {
ASCIIToUTF16("first_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("last_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -230,21 +245,24 @@ TEST_F(NameFieldTest, FirstMiddleLastEmpty) {
ASCIIToUTF16("first_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("middle_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("last_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -268,21 +286,24 @@ TEST_F(NameFieldTest, MiddleInitial) {
ASCIIToUTF16("first_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("MI"),
ASCIIToUTF16("middle_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("last_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -306,14 +327,16 @@ TEST_F(NameFieldTest, MiddleInitialNoLastName) {
ASCIIToUTF16("first_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("MI"),
ASCIIToUTF16("middle_name"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -329,21 +352,24 @@ TEST_F(NameFieldTest, MiddleInitialAtEnd) {
ASCIIToUTF16("XXXnameXXXfirst"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("XXXnameXXXmi"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("XXXnameXXXlast"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -367,7 +393,8 @@ TEST_F(NameFieldTest, ECMLNoName) {
ASCIIToUTF16("ecom_shipto_postal_company"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("field1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -381,14 +408,16 @@ TEST_F(NameFieldTest, ECMLMiddleInitialNoLastName) {
ASCIIToUTF16("ecom_shipto_postal_name_first"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(new AutoFillField(
webkit_glue::FormField(ASCIIToUTF16("Middle"),
ASCIIToUTF16("ecom_shipto_postal_name_middle"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -402,21 +431,24 @@ TEST_F(NameFieldTest, ECMLFirstMiddleLast) {
ASCIIToUTF16("ecom_shipto_postal_name_first"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name1")));
list_.push_back(new AutoFillField(
webkit_glue::FormField(string16(),
ASCIIToUTF16("ecom_shipto_postal_name_middle"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name2")));
list_.push_back(new AutoFillField(
webkit_glue::FormField(string16(),
ASCIIToUTF16("ecom_shipto_postal_name_last"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc
index ce0ae48..e79d64a 100644
--- a/chrome/browser/autofill/phone_field_unittest.cc
+++ b/chrome/browser/autofill/phone_field_unittest.cc
@@ -46,7 +46,8 @@ TEST_F(PhoneFieldTest, ParseOneLinePhone) {
ASCIIToUTF16("phone"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -64,7 +65,8 @@ TEST_F(PhoneFieldTest, ParseOneLinePhoneEcml) {
ASCIIToUTF16(kEcmlShipToPhone),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -82,14 +84,16 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhone) {
ASCIIToUTF16("area code"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -111,14 +115,16 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlShipTo) {
ASCIIToUTF16(kEcmlShipToPostalCode),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16(kEcmlShipToPhone),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -140,14 +146,16 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlBillTo) {
ASCIIToUTF16(kEcmlBillToPostalCode),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16(kEcmlBillToPhone),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -168,28 +176,32 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumber) {
ASCIIToUTF16("dayphone1"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("-"),
ASCIIToUTF16("dayphone2"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("prefix1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("-"),
ASCIIToUTF16("dayphone3"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("suffix1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("ext.:"),
ASCIIToUTF16("dayphone4"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("ext1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -216,21 +228,24 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix) {
ASCIIToUTF16("area"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("prefix"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("prefix1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("suffix"),
string16(),
ASCIIToUTF16("text"),
- 0),
+ 0,
+ false),
ASCIIToUTF16("suffix1")));
list_.push_back(NULL);
iter_ = list_.begin();