diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-27 02:19:15 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-27 02:19:15 +0000 |
commit | 8ea2025aafbad247dd50cd19a81a364c14fc5796 (patch) | |
tree | eefb409eea12f709a4a20055b3ba5dcaa74407a0 /chrome | |
parent | d58b6b41902228daeacacd1c42ce15469c18d4be (diff) | |
download | chromium_src-8ea2025aafbad247dd50cd19a81a364c14fc5796.zip chromium_src-8ea2025aafbad247dd50cd19a81a364c14fc5796.tar.gz chromium_src-8ea2025aafbad247dd50cd19a81a364c14fc5796.tar.bz2 |
AutoFill: Handle filling select controls.
BUG=38222
TEST=none
Review URL: http://codereview.chromium.org/1309003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42891 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete_history_manager.cc | 8 | ||||
-rw-r--r-- | chrome/browser/autofill/address_field_unittest.cc | 42 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure.cc | 11 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure_unittest.cc | 130 | ||||
-rw-r--r-- | chrome/browser/autofill/phone_field_unittest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/webdata/web_data_service_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/webdata/web_database_unittest.cc | 78 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 7 | ||||
-rw-r--r-- | chrome/renderer/form_manager.cc | 96 | ||||
-rw-r--r-- | chrome/renderer/form_manager.h | 23 | ||||
-rw-r--r-- | chrome/renderer/form_manager_unittest.cc | 116 |
11 files changed, 232 insertions, 306 deletions
diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc index 1643636..280ea85 100644 --- a/chrome/browser/autocomplete_history_manager.cc +++ b/chrome/browser/autocomplete_history_manager.cc @@ -109,18 +109,16 @@ void AutocompleteHistoryManager::StoreFormEntriesInWebDatabase( return; // We put the following restriction on stored FormFields: - // - input_type() == WebInputElement::Text // - non-empty name // - non-empty value - // - non-empty form_control_type() + // - text field std::vector<webkit_glue::FormField> values; for (std::vector<webkit_glue::FormField>::const_iterator iter = form.elements.begin(); iter != form.elements.end(); ++iter) { - if (iter->input_type() == WebKit::WebInputElement::Text && - !iter->value().empty() && + if (!iter->value().empty() && !iter->name().empty() && - !iter->form_control_type().empty()) + iter->form_control_type() == ASCIIToUTF16("text")) values.push_back(*iter); } diff --git a/chrome/browser/autofill/address_field_unittest.cc b/chrome/browser/autofill/address_field_unittest.cc index ea41876..bbcbcf2 100644 --- a/chrome/browser/autofill/address_field_unittest.cc +++ b/chrome/browser/autofill/address_field_unittest.cc @@ -45,8 +45,7 @@ TEST_F(AddressFieldTest, ParseOneLineAddress) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"), ASCIIToUTF16("address"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("addr1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -65,8 +64,7 @@ TEST_F(AddressFieldTest, ParseOneLineAddressEcml) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"), kEcmlShipToAddress1, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("addr1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -85,15 +83,13 @@ TEST_F(AddressFieldTest, ParseTwoLineAddress) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"), ASCIIToUTF16("address"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("addr1"))); list_.push_back( new AutoFillField(webkit_glue::FormField(string16(), string16(), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("addr2"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -115,15 +111,13 @@ TEST_F(AddressFieldTest, ParseTwoLineAddressEcml) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"), kEcmlShipToAddress1, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("addr1"))); list_.push_back( new AutoFillField(webkit_glue::FormField(string16(), kEcmlShipToAddress2, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("addr2"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -145,8 +139,7 @@ TEST_F(AddressFieldTest, ParseCity) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("City"), ASCIIToUTF16("city"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("city1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -165,8 +158,7 @@ TEST_F(AddressFieldTest, ParseCityEcml) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("City"), kEcmlShipToCity, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("city1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -185,8 +177,7 @@ TEST_F(AddressFieldTest, ParseState) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("State"), ASCIIToUTF16("state"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("state1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -205,8 +196,7 @@ TEST_F(AddressFieldTest, ParseStateEcml) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("State"), kEcmlShipToStateProv, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("state1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -225,8 +215,7 @@ TEST_F(AddressFieldTest, ParseZip) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Zip"), ASCIIToUTF16("zip"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("zip1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -245,8 +234,7 @@ TEST_F(AddressFieldTest, ParseZipEcml) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Zip"), kEcmlShipToPostalCode, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("zip1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -265,8 +253,7 @@ TEST_F(AddressFieldTest, ParseCountry) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Country"), ASCIIToUTF16("country"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("country1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -285,8 +272,7 @@ TEST_F(AddressFieldTest, ParseCountryEcml) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Country"), kEcmlShipToCountry, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("country1"))); list_.push_back(NULL); iter_ = list_.begin(); diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc index dd9cfaa..8628036 100644 --- a/chrome/browser/autofill/form_structure.cc +++ b/chrome/browser/autofill/form_structure.cc @@ -34,7 +34,8 @@ const char* const kXMLElementForm = "form"; const char* const kXMLElementField = "field"; const char* const kAttributeAutoFillType = "autofilltype"; -// The only form control type we handle currently. +// The list of form control types we handle. +const char* const kControlTypeSelect = "select-one"; const char* const kControlTypeText = "text"; // The number of fillable fields necessary for a form to be fillable. @@ -66,9 +67,11 @@ FormStructure::FormStructure(const FormFieldValues& values) std::vector<webkit_glue::FormField>::const_iterator field; for (field = values.elements.begin(); field != values.elements.end(); field++) { - // We currently only handle text fields. This prevents us from thinking we - // can autofill other types of controls, e.g., select, password, hidden. - if (!LowerCaseEqualsASCII(field->form_control_type(), kControlTypeText)) + // We currently only handle text and seleect fields. This prevents us from + // thinking we can autofill other types of controls, e.g., password, hidden, + // submit. + if (!LowerCaseEqualsASCII(field->form_control_type(), kControlTypeText) && + !LowerCaseEqualsASCII(field->form_control_type(), kControlTypeSelect)) continue; // Generate a unique name for this field by appending a counter to the name. diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc index a8283a5..5b310b4 100644 --- a/chrome/browser/autofill/form_structure_unittest.cc +++ b/chrome/browser/autofill/form_structure_unittest.cc @@ -20,19 +20,15 @@ TEST(FormStructureTest, FieldCount) { values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), ASCIIToUTF16("username"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), ASCIIToUTF16("password"), string16(), - ASCIIToUTF16("password"), - WebInputElement::Password)); + ASCIIToUTF16("password"))); values.elements.push_back(webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), string16(), - ASCIIToUTF16("submit"), - WebInputElement::Submit)); - + ASCIIToUTF16("submit"))); FormStructure form_structure(values); // Only text fields are counted. @@ -48,18 +44,15 @@ TEST(FormStructureTest, IsAutoFillable) { values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), ASCIIToUTF16("username"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), ASCIIToUTF16("password"), string16(), - ASCIIToUTF16("password"), - WebInputElement::Password)); + ASCIIToUTF16("password"))); values.elements.push_back(webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), string16(), - ASCIIToUTF16("submit"), - WebInputElement::Submit)); + ASCIIToUTF16("submit"))); form_structure.reset(new FormStructure(values)); EXPECT_FALSE(form_structure->IsAutoFillable()); @@ -67,13 +60,11 @@ TEST(FormStructureTest, IsAutoFillable) { values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), ASCIIToUTF16("firstname"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), ASCIIToUTF16("lastname"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); form_structure.reset(new FormStructure(values)); EXPECT_TRUE(form_structure->IsAutoFillable()); @@ -102,48 +93,39 @@ TEST(FormStructureTest, Heuristics) { values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), ASCIIToUTF16("firstname"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), ASCIIToUTF16("lastname"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), ASCIIToUTF16("email"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), ASCIIToUTF16("phone"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), ASCIIToUTF16("fax"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), ASCIIToUTF16("address"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("City"), ASCIIToUTF16("city"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), ASCIIToUTF16("zipcode"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), string16(), - ASCIIToUTF16("submit"), - WebInputElement::Submit)); + ASCIIToUTF16("submit"))); form_structure.reset(new FormStructure(values)); EXPECT_TRUE(form_structure->IsAutoFillable()); @@ -198,62 +180,52 @@ TEST(FormStructureTest, HeuristicsSample8) { webkit_glue::FormField(ASCIIToUTF16("Your First Name:"), ASCIIToUTF16("bill.first"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Your Last Name:"), ASCIIToUTF16("bill.last"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Street Address Line 1:"), ASCIIToUTF16("bill.street1"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Street Address Line 2:"), ASCIIToUTF16("bill.street2"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("City:"), ASCIIToUTF16("bill.city"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("State (U.S.):"), ASCIIToUTF16("bill.state"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Zip/Postal Code:"), ASCIIToUTF16("BillTo.PostalCode"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Country:"), ASCIIToUTF16("bill.country"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Phone Number:"), ASCIIToUTF16("BillTo.Phone"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), string16(), - ASCIIToUTF16("submit"), - WebInputElement::Submit)); + ASCIIToUTF16("submit"))); form_structure.reset(new FormStructure(values)); EXPECT_TRUE(form_structure->IsAutoFillable()); @@ -307,46 +279,39 @@ TEST(FormStructureTest, HeuristicsSample6) { webkit_glue::FormField(ASCIIToUTF16("E-mail address"), ASCIIToUTF16("email"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Full name"), ASCIIToUTF16("name"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Company"), ASCIIToUTF16("company"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Address"), ASCIIToUTF16("address"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("City"), ASCIIToUTF16("city"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); // TODO(jhawkins): Add state select control. values.elements.push_back( webkit_glue::FormField(ASCIIToUTF16("Zip Code"), ASCIIToUTF16("Home.PostalCode"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); // TODO(jhawkins): Phone number. values.elements.push_back( webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), ASCIIToUTF16("continue"), - ASCIIToUTF16("submit"), - WebInputElement::Submit)); + ASCIIToUTF16("submit"))); form_structure.reset(new FormStructure(values)); EXPECT_TRUE(form_structure->IsAutoFillable()); @@ -395,48 +360,39 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) { values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), string16(), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text)); + ASCIIToUTF16("text"))); values.elements.push_back(webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), string16(), - ASCIIToUTF16("submit"), - WebInputElement::Submit)); + ASCIIToUTF16("submit"))); form_structure.reset(new FormStructure(values)); EXPECT_TRUE(form_structure->IsAutoFillable()); diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc index cef9bb4..e12e894 100644 --- a/chrome/browser/autofill/phone_field_unittest.cc +++ b/chrome/browser/autofill/phone_field_unittest.cc @@ -45,8 +45,7 @@ TEST_F(PhoneFieldTest, ParseOneLinePhone) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"), ASCIIToUTF16("phone"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("phone1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -63,8 +62,7 @@ TEST_F(PhoneFieldTest, ParseOneLinePhoneEcml) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"), kEcmlShipToPhone, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("phone1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -81,15 +79,13 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhone) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"), ASCIIToUTF16("area code"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("areacode1"))); list_.push_back( new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"), ASCIIToUTF16("phone"), string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("phone1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -109,15 +105,13 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlShipTo) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"), kEcmlShipToPostalCode, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("areacode1"))); list_.push_back( new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"), kEcmlShipToPhone, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("phone1"))); list_.push_back(NULL); iter_ = list_.begin(); @@ -137,15 +131,13 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlBillTo) { new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"), kEcmlBillToPostalCode, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("areacode1"))); list_.push_back( new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"), kEcmlBillToPhone, string16(), - ASCIIToUTF16("text"), - WebKit::WebInputElement::Text), + ASCIIToUTF16("text")), ASCIIToUTF16("phone1"))); list_.push_back(NULL); iter_ = list_.begin(); diff --git a/chrome/browser/webdata/web_data_service_unittest.cc b/chrome/browser/webdata/web_data_service_unittest.cc index 1797138..d615902 100644 --- a/chrome/browser/webdata/web_data_service_unittest.cc +++ b/chrome/browser/webdata/web_data_service_unittest.cc @@ -192,8 +192,7 @@ class WebDataServiceAutofillTest : public WebDataServiceTest { webkit_glue::FormField(string16(), name, value, - string16(), - WebKit::WebInputElement::Text)); + string16())); } string16 name1_; diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index 1482f84..e1b58c5 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -479,8 +479,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); std::vector<string16> v; for (int i = 0; i < 5; i++) { @@ -488,8 +487,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); } for (int i = 0; i < 3; i++) { @@ -497,8 +495,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Sutter"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); } for (int i = 0; i < 2; i++) { @@ -506,8 +503,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Favorite Color"), ASCIIToUTF16("Green"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); } @@ -520,8 +516,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent"), - string16(), - WebKit::WebInputElement::Text), + string16()), &pair_id, &count)); EXPECT_EQ(5, count); EXPECT_NE(0, pair_id); @@ -532,8 +527,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("clark kent"), - string16(), - WebKit::WebInputElement::Text), + string16()), &pair_id, &count)); EXPECT_EQ(0, count); @@ -541,8 +535,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Favorite Color"), ASCIIToUTF16("Green"), - string16(), - WebKit::WebInputElement::Text), + string16()), &pair_id, &count)); EXPECT_EQ(2, count); @@ -606,8 +599,7 @@ TEST_F(WebDatabaseTest, Autofill) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent"), - string16(), - WebKit::WebInputElement::Text), + string16()), &pair_id, &count)); EXPECT_EQ(0, count); @@ -620,26 +612,22 @@ TEST_F(WebDatabaseTest, Autofill) { EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(), ASCIIToUTF16("blank"), string16(), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(), ASCIIToUTF16("blank"), ASCIIToUTF16(" "), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(), ASCIIToUTF16("blank"), ASCIIToUTF16(" "), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(), ASCIIToUTF16("blank"), kValue, - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); // They should be stored normally as the DB layer does not check for empty @@ -673,16 +661,14 @@ TEST_F(WebDatabaseTest, Autofill_RemoveBetweenChanges) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, t1)); EXPECT_TRUE(db.AddFormFieldValueTime( FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, t2)); @@ -716,8 +702,7 @@ TEST_F(WebDatabaseTest, Autofill_AddChanges) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, t1)); ASSERT_EQ(1U, changes.size()); @@ -731,8 +716,7 @@ TEST_F(WebDatabaseTest, Autofill_AddChanges) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, t2)); ASSERT_EQ(1U, changes.size()); @@ -754,8 +738,7 @@ TEST_F(WebDatabaseTest, Autofill_UpdateOneWithOneTimestamp) { FormField field(string16(), ASCIIToUTF16("foo"), ASCIIToUTF16("bar"), - string16(), - WebKit::WebInputElement::Text); + string16()); int64 pair_id; int count; ASSERT_TRUE(db.GetIDAndCountOfFormElement(field, &pair_id, &count)); @@ -780,8 +763,7 @@ TEST_F(WebDatabaseTest, Autofill_UpdateOneWithTwoTimestamps) { FormField field(string16(), ASCIIToUTF16("foo"), ASCIIToUTF16("bar"), - string16(), - WebKit::WebInputElement::Text); + string16()); int64 pair_id; int count; ASSERT_TRUE(db.GetIDAndCountOfFormElement(field, &pair_id, &count)); @@ -826,8 +808,7 @@ TEST_F(WebDatabaseTest, Autofill_UpdateTwo) { FormField field0(string16(), ASCIIToUTF16("foo"), ASCIIToUTF16("bar0"), - string16(), - WebKit::WebInputElement::Text); + string16()); int64 pair_id; int count; ASSERT_TRUE(db.GetIDAndCountOfFormElement(field0, &pair_id, &count)); @@ -837,8 +818,7 @@ TEST_F(WebDatabaseTest, Autofill_UpdateTwo) { FormField field1(string16(), ASCIIToUTF16("foo"), ASCIIToUTF16("bar1"), - string16(), - WebKit::WebInputElement::Text); + string16()); ASSERT_TRUE(db.GetIDAndCountOfFormElement(field1, &pair_id, &count)); EXPECT_LE(0, pair_id); EXPECT_EQ(2, count); @@ -854,8 +834,7 @@ TEST_F(WebDatabaseTest, Autofill_UpdateReplace) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes)); AutofillEntry entry(MakeAutofillEntry("Name", "Superman", 1, 2)); @@ -883,8 +862,7 @@ TEST_F(WebDatabaseTest, Autofill_UpdateDontReplace) { FormField(string16(), existing.key().name(), existing.key().value(), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, t)); AutofillEntry entry(MakeAutofillEntry("Name", "Clark Kent", 1, 2)); @@ -1253,8 +1231,7 @@ TEST_F(WebDatabaseTest, Autofill_GetAllAutofillEntries_OneResult) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, Time::FromTimeT(start))); timestamps1.push_back(Time::FromTimeT(start)); @@ -1297,8 +1274,7 @@ TEST_F(WebDatabaseTest, Autofill_GetAllAutofillEntries_TwoDistinct) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, Time::FromTimeT(start))); timestamps1.push_back(Time::FromTimeT(start)); @@ -1312,8 +1288,7 @@ TEST_F(WebDatabaseTest, Autofill_GetAllAutofillEntries_TwoDistinct) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, Time::FromTimeT(start))); timestamps2.push_back(Time::FromTimeT(start)); @@ -1360,8 +1335,7 @@ TEST_F(WebDatabaseTest, Autofill_GetAllAutofillEntries_TwoSame) { FormField(string16(), ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"), - string16(), - WebKit::WebInputElement::Text), + string16()), &changes, Time::FromTimeT(start))); timestamps.push_back(Time::FromTimeT(start)); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index f795336..8274846 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -949,27 +949,20 @@ struct ParamTraits<webkit_glue::FormField> { WriteParam(m, p.name()); WriteParam(m, p.value()); WriteParam(m, p.form_control_type()); - WriteParam(m, static_cast<int>(p.input_type())); } static bool Read(const Message* m, void** iter, param_type* p) { string16 label, name, value, form_control_type; - int type; bool result = ReadParam(m, iter, &label); result = result && ReadParam(m, iter, &name); result = result && ReadParam(m, iter, &value); result = result && ReadParam(m, iter, &form_control_type); - result = result && ReadParam(m, iter, &type); if (!result) return false; - WebKit::WebInputElement::InputType input_type = - static_cast<WebKit::WebInputElement::InputType>(type); - p->set_label(label); p->set_name(name); p->set_value(value); p->set_form_control_type(form_control_type); - p->set_input_type(input_type); return true; } static void Log(const param_type& p, std::wstring* l) { diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc index 2752dcb..8206d29 100644 --- a/chrome/renderer/form_manager.cc +++ b/chrome/renderer/form_manager.cc @@ -10,20 +10,24 @@ #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebLabelElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSelectElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" using WebKit::WebDocument; using WebKit::WebElement; +using WebKit::WebFormControlElement; using WebKit::WebFormElement; using WebKit::WebFrame; using WebKit::WebInputElement; using WebKit::WebLabelElement; using WebKit::WebNode; using WebKit::WebNodeList; +using WebKit::WebSelectElement; using WebKit::WebString; using WebKit::WebVector; using webkit_glue::FormData; @@ -49,13 +53,13 @@ void FormManager::ExtractForms(WebFrame* frame) { form_elements->form_element = web_forms[i]; // Form elements loop. - WebVector<WebInputElement> input_elements; - form_elements->form_element.getInputElements(input_elements); - for (size_t j = 0; j < input_elements.size(); ++j) { - WebInputElement element = input_elements[j]; + WebVector<WebFormControlElement> control_elements; + form_elements->form_element.getFormControlElements(control_elements); + for (size_t j = 0; j < control_elements.size(); ++j) { + WebFormControlElement element = control_elements[j]; // TODO(jhawkins): Remove this check when we have labels. if (!element.nameForAutofill().isEmpty()) - form_elements->input_elements[element.nameForAutofill()] = element; + form_elements->control_elements[element.nameForAutofill()] = element; } form_elements_map_[frame].push_back(form_elements); @@ -85,7 +89,7 @@ void FormManager::GetForms(std::vector<FormData>* forms, } } -bool FormManager::FindForm(const WebInputElement& element, +bool FormManager::FindForm(const WebFormControlElement& element, FormData* form) { // Frame loop. for (WebFrameFormElementMap::iterator iter = form_elements_map_.begin(); @@ -97,8 +101,8 @@ bool FormManager::FindForm(const WebInputElement& element, form_iter != iter->second.end(); ++form_iter) { FormElement* form_element = *form_iter; - if (form_element->input_elements.find(element.nameForAutofill()) != - form_element->input_elements.end()) { + if (form_element->control_elements.find(element.nameForAutofill()) != + form_element->control_elements.end()) { FormElementToFormData(frame, form_element, REQUIRE_NONE, form); return true; } @@ -125,7 +129,7 @@ bool FormManager::FillForm(const FormData& form) { // evaluate to |true| for some reason TBD, so forcing to string16. string16 element_name((*form_iter)->form_element.name()); if (element_name == form.name && - (*form_iter)->input_elements.size() == form.fields.size()) { + (*form_iter)->control_elements.size() == form.fields.size()) { form_element = *form_iter; break; } @@ -135,18 +139,26 @@ bool FormManager::FillForm(const FormData& form) { if (!form_element) return false; - DCHECK(form_element->input_elements.size() == form.fields.size()); + DCHECK(form_element->control_elements.size() == form.fields.size()); size_t i = 0; - for (FormInputElementMap::iterator iter = - form_element->input_elements.begin(); - iter != form_element->input_elements.end(); ++iter, ++i) { + for (FormControlElementMap::iterator iter = + form_element->control_elements.begin(); + iter != form_element->control_elements.end(); ++iter, ++i) { DCHECK_EQ(form.fields[i].name(), iter->second.nameForAutofill()); if (!form.fields[i].value().empty() && - iter->second.inputType() != WebInputElement::Submit) { - iter->second.setValue(form.fields[i].value()); - iter->second.setAutofilled(true); + iter->second.formControlType() != ASCIIToUTF16("submit")) { + if (iter->second.formControlType() == ASCIIToUTF16("text")) { + WebInputElement input_element = + iter->second.toElement<WebInputElement>(); + input_element.setValue(form.fields[i].value()); + input_element.setAutofilled(true); + } else if (iter->second.formControlType() == ASCIIToUTF16("select-one")) { + WebSelectElement select_element = + iter->second.toElement<WebSelectElement>(); + select_element.setValue(form.fields[i].value()); + } } } @@ -183,35 +195,44 @@ void FormManager::FormElementToFormData(WebFrame* frame, form->action = GURL(form_element->form_element.action()); // Form elements loop. - for (FormInputElementMap::const_iterator element_iter = - form_element->input_elements.begin(); - element_iter != form_element->input_elements.end(); ++element_iter) { - const WebInputElement& input_element = element_iter->second; + for (FormControlElementMap::const_iterator element_iter = + form_element->control_elements.begin(); + element_iter != form_element->control_elements.end(); ++element_iter) { + WebFormControlElement control_element = element_iter->second; if (requirements & REQUIRE_AUTOCOMPLETE && - !input_element.autoComplete()) - continue; + control_element.formControlType() == ASCIIToUTF16("text")) { + const WebInputElement& input_element = + control_element.toConstElement<WebInputElement>(); + if (!input_element.autoComplete()) + continue; + } - if (requirements & REQUIRE_ELEMENTS_ENABLED && - !input_element.isEnabledFormControl()) + if (requirements & REQUIRE_ELEMENTS_ENABLED && !control_element.isEnabled()) continue; - string16 label = LabelForElement(input_element); - string16 name = input_element.nameForAutofill(); - string16 value = input_element.value(); - string16 form_control_type = input_element.formControlType(); - WebInputElement::InputType input_type = input_element.inputType(); - FormField field = FormField(label, - name, - value, - form_control_type, - input_type); - form->fields.push_back(field); + string16 label = LabelForElement(control_element); + string16 name = control_element.nameForAutofill(); + + string16 value; + if (control_element.formControlType() == ASCIIToUTF16("text")) { + const WebInputElement& input_element = + control_element.toConstElement<WebInputElement>(); + value = input_element.value(); + } else if (control_element.formControlType() == + ASCIIToUTF16("select-one")) { + WebSelectElement select_element = + control_element.toElement<WebSelectElement>(); + value = select_element.value(); + } + + string16 form_control_type = control_element.formControlType(); + form->fields.push_back(FormField(label, name, value, form_control_type)); } } // static -string16 FormManager::LabelForElement(const WebInputElement& element) { +string16 FormManager::LabelForElement(const WebFormControlElement& element) { WebNodeList labels = element.document().getElementsByTagName("label"); for (unsigned i = 0; i < labels.length(); ++i) { WebElement e = labels.item(i).toElement<WebElement>(); @@ -227,7 +248,8 @@ string16 FormManager::LabelForElement(const WebInputElement& element) { } // static -string16 FormManager::InferLabelForElement(const WebInputElement& element) { +string16 FormManager::InferLabelForElement( + const WebFormControlElement& element) { string16 inferred_label; WebNode previous = element.previousSibling(); if (!previous.isNull()) { diff --git a/chrome/renderer/form_manager.h b/chrome/renderer/form_manager.h index 4928838..5445a4f 100644 --- a/chrome/renderer/form_manager.h +++ b/chrome/renderer/form_manager.h @@ -9,8 +9,8 @@ #include <vector> #include "base/string16.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" -#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" #include "webkit/glue/form_data.h" namespace WebKit { @@ -37,9 +37,9 @@ class FormManager { void GetForms(std::vector<webkit_glue::FormData>* forms, RequirementsMask requirements); - // Finds the form that contains |input_element| and returns it in |form|. - // Returns false if the form is not found. - bool FindForm(const WebKit::WebInputElement& input_element, + // Finds the form that contains |element| and returns it in |form|. Returns + // false if the form is not found. + bool FindForm(const WebKit::WebFormControlElement& element, webkit_glue::FormData* form); // Fills the form represented by |form|. |form| should have the name set to @@ -53,13 +53,15 @@ class FormManager { void Reset(); private: - // A map of WebInputElements keyed by each element's name. - typedef std::map<string16, WebKit::WebInputElement> FormInputElementMap; + // A map of WebFormControlElements keyed by each element's name. + typedef std::map<string16, WebKit::WebFormControlElement> + FormControlElementMap; - // Stores the WebFormElement and the map of input elements for each form. + // Stores the WebFormElement and the map of form control elements for each + // form. struct FormElement { WebKit::WebFormElement form_element; - FormInputElementMap input_elements; + FormControlElementMap control_elements; }; // A map of vectors of FormElements keyed by the WebFrame containing each @@ -78,12 +80,13 @@ class FormManager { webkit_glue::FormData* form); // Returns the corresponding label for |element|. - static string16 LabelForElement(const WebKit::WebInputElement& element); + static string16 LabelForElement(const WebKit::WebFormControlElement& element); // Infers corresponding label for |element| from surrounding context in the // DOM. Contents of preceeding <p> tag or preceeding text element found in // the form. - static string16 InferLabelForElement(const WebKit::WebInputElement& element); + static string16 InferLabelForElement( + const WebKit::WebFormControlElement& element); // The map of form elements. WebFrameFormElementMap form_elements_map_; diff --git a/chrome/renderer/form_manager_unittest.cc b/chrome/renderer/form_manager_unittest.cc index c288d19..3b57d98 100644 --- a/chrome/renderer/form_manager_unittest.cc +++ b/chrome/renderer/form_manager_unittest.cc @@ -50,18 +50,18 @@ TEST_F(FormManagerTest, ExtractForms) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("firstname"), ASCIIToUTF16("John"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[1]); + ASCIIToUTF16("text")), + fields[1]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[2]); + ASCIIToUTF16("submit")), + fields[2]); } TEST_F(FormManagerTest, ExtractMultipleForms) { @@ -95,13 +95,13 @@ TEST_F(FormManagerTest, ExtractMultipleForms) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("firstname"), ASCIIToUTF16("John"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[1]); + ASCIIToUTF16("submit")), + fields[1]); // Second form. const FormData& form2 = forms[1]; @@ -114,13 +114,13 @@ TEST_F(FormManagerTest, ExtractMultipleForms) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields2[0]); + ASCIIToUTF16("text")), + fields2[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("second"), ASCIIToUTF16("Submit"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields2[1]); + ASCIIToUTF16("submit")), + fields2[1]); } TEST_F(FormManagerTest, GetFormsAutocomplete) { @@ -175,13 +175,13 @@ TEST_F(FormManagerTest, GetFormsAutocomplete) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[1]); + ASCIIToUTF16("submit")), + fields[1]); } TEST_F(FormManagerTest, GetFormsElementsEnabled) { @@ -212,13 +212,13 @@ TEST_F(FormManagerTest, GetFormsElementsEnabled) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("submit"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[1]); + ASCIIToUTF16("submit")), + fields[1]); } TEST_F(FormManagerTest, FindForm) { @@ -256,18 +256,18 @@ TEST_F(FormManagerTest, FindForm) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("firstname"), ASCIIToUTF16("John"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[1]); + ASCIIToUTF16("text")), + fields[1]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[2]); + ASCIIToUTF16("submit")), + fields[2]); } TEST_F(FormManagerTest, FillForm) { @@ -305,18 +305,18 @@ TEST_F(FormManagerTest, FillForm) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("firstname"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("lastname"), string16(), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[1]); + ASCIIToUTF16("text")), + fields[1]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[2]); + ASCIIToUTF16("submit")), + fields[2]); // Fill the form. form.fields[0].set_value(ASCIIToUTF16("Wyatt")); @@ -335,18 +335,18 @@ TEST_F(FormManagerTest, FillForm) { EXPECT_EQ(FormField(string16(), ASCIIToUTF16("firstname"), ASCIIToUTF16("Wyatt"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields2[0]); + ASCIIToUTF16("text")), + fields2[0]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("lastname"), ASCIIToUTF16("Earp"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields2[1]); + ASCIIToUTF16("text")), + fields2[1]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields2[2]); + ASCIIToUTF16("submit")), + fields2[2]); } TEST_F(FormManagerTest, Reset) { @@ -403,18 +403,18 @@ TEST_F(FormManagerTest, Labels) { EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), ASCIIToUTF16("firstname"), ASCIIToUTF16("John"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[1]); + ASCIIToUTF16("text")), + fields[1]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[2]); + ASCIIToUTF16("submit")), + fields[2]); } TEST_F(FormManagerTest, LabelsFromInferredText) { @@ -446,18 +446,18 @@ TEST_F(FormManagerTest, LabelsFromInferredText) { EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), ASCIIToUTF16("firstname"), ASCIIToUTF16("John"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[1]); + ASCIIToUTF16("text")), + fields[1]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[2]); + ASCIIToUTF16("submit")), + fields[2]); } TEST_F(FormManagerTest, LabelsFromInferredParagraph) { @@ -489,18 +489,18 @@ TEST_F(FormManagerTest, LabelsFromInferredParagraph) { EXPECT_EQ(FormField(ASCIIToUTF16("First name:"), ASCIIToUTF16("firstname"), ASCIIToUTF16("John"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[0]); + ASCIIToUTF16("text")), + fields[0]); EXPECT_EQ(FormField(ASCIIToUTF16("Last name:"), ASCIIToUTF16("lastname"), ASCIIToUTF16("Smith"), - ASCIIToUTF16("text"), - WebInputElement::Text), fields[1]); + ASCIIToUTF16("text")), + fields[1]); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("reply-send"), ASCIIToUTF16("Send"), - ASCIIToUTF16("submit"), - WebInputElement::Submit), fields[2]); + ASCIIToUTF16("submit")), + fields[2]); } } // namespace |