diff options
author | estade <estade@chromium.org> | 2015-01-08 15:51:12 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-08 23:52:01 +0000 |
commit | 36bf690f6c3a431b96b196e91d439e3052830f60 (patch) | |
tree | c70b1ab8b0c76ab9e9d4f717c3b9cefe07492049 | |
parent | a9fa25d8f08bccb70084c2db35b270386f080396 (diff) | |
download | chromium_src-36bf690f6c3a431b96b196e91d439e3052830f60.zip chromium_src-36bf690f6c3a431b96b196e91d439e3052830f60.tar.gz chromium_src-36bf690f6c3a431b96b196e91d439e3052830f60.tar.bz2 |
Autofill: improve handling of nameless, ID-less inputs.
Previously, when matching elements to label text, the code relied on the name and/or ID of the control element. This meant elements without names or IDs would likely not get label text (at least directly --- inferred labels might still work).
Most of the differences in tests are just in the control's label text, and don't affect the type prediction. The exceptions are:
- Nordstrom's is improved
- Land's End is improved (what should be addr line 3, but is incorrectly labeled as addr line 1, becomes unknown type)
BUG=428892, 426538
Review URL: https://codereview.chromium.org/820333005
Cr-Commit-Position: refs/heads/master@{#310631}
15 files changed, 79 insertions, 65 deletions
diff --git a/chrome/test/data/autofill/heuristics/output/02_checkout_ae.com.out b/chrome/test/data/autofill/heuristics/output/02_checkout_ae.com.out index 0708159f..f1dbbe5 100644 --- a/chrome/test/data/autofill/heuristics/output/02_checkout_ae.com.out +++ b/chrome/test/data/autofill/heuristics/output/02_checkout_ae.com.out @@ -10,9 +10,9 @@ ADDRESS_HOME_LINE2 | address2 | Address | | countryType_1-default ADDRESS_HOME_CITY | city | City | | countryType_1-default ADDRESS_HOME_STATE | state | State | | countryType_1-default ADDRESS_HOME_ZIP | zip | Zip | | countryType_1-default -UNKNOWN_TYPE | shippingChoice | Shipping Method CLOSEWe ship using UPS and USPS Priority Mail within the continental United States, and USPS priority mail outside of the continental United States.Learn More about our shipping methods and prices.Place this order by 1PM EST to get it by the estimated dates below: | Standard | countryType_1-default -UNKNOWN_TYPE | shippingChoice | Shipping Method CLOSEWe ship using UPS and USPS Priority Mail within the continental United States, and USPS priority mail outside of the continental United States.Learn More about our shipping methods and prices.Place this order by 1PM EST to get it by the estimated dates below: | SecondDay | countryType_1-default -UNKNOWN_TYPE | shippingChoice | Standard3 - 7 business days$7dates: Jun 08 - Jun 14 Two Day2 business days$15date: Jun 07 Overnight1 business day$20date: Jun 06 | Overnight | countryType_1-default +UNKNOWN_TYPE | shippingChoice | Standard3 - 7 business days$7dates: Jun 08 - Jun 14 | Standard | countryType_1-default +UNKNOWN_TYPE | shippingChoice | Two Day2 business days$15date: Jun 07 | SecondDay | countryType_1-default +UNKNOWN_TYPE | shippingChoice | Overnight1 business day$20date: Jun 06 | Overnight | countryType_1-default CREDIT_CARD_TYPE | ccType | Card Type: | | ccType_1-cc CREDIT_CARD_NUMBER | ccNumber | Card Number: | | ccType_1-cc CREDIT_CARD_EXP_MONTH | expMonth | Expiration: | 1 | ccType_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/04_checkout_kohls.com.out b/chrome/test/data/autofill/heuristics/output/04_checkout_kohls.com.out index 92c95f3..2585901 100644 --- a/chrome/test/data/autofill/heuristics/output/04_checkout_kohls.com.out +++ b/chrome/test/data/autofill/heuristics/output/04_checkout_kohls.com.out @@ -12,7 +12,7 @@ PHONE_HOME_WHOLE_NUMBER | bill_phone | Contact Phone: | | BILL_TO_ADDRESS<>firs EMAIL_ADDRESS | CURRENT_USER<>email | E-mail Address: | | BILL_TO_ADDRESS<>firstName_1-default UNKNOWN_TYPE | EMAIL_OPT_STATUS_ARRAY<>opt_status | Yes, sign me up for Sale Alerts. (optional) | true | BILL_TO_ADDRESS<>firstName_1-default UNKNOWN_TYPE | indShipIsBillTo | Yes | true | BILL_TO_ADDRESS<>firstName_1-default -UNKNOWN_TYPE | indShipIsBillTo | Yes No | false | BILL_TO_ADDRESS<>firstName_1-default +UNKNOWN_TYPE | indShipIsBillTo | No | false | BILL_TO_ADDRESS<>firstName_1-default NAME_FIRST | SHIP_TO_ADDRESS<>firstName | First Name: | | SHIP_TO_ADDRESS<>firstName_1-default NAME_LAST | SHIP_TO_ADDRESS<>lastName | Last Name: | | SHIP_TO_ADDRESS<>firstName_1-default ADDRESS_HOME_LINE1 | SHIP_TO_ADDRESS<>address1 | Address: | | SHIP_TO_ADDRESS<>firstName_1-default diff --git a/chrome/test/data/autofill/heuristics/output/06_checkout_petsmart.com.out b/chrome/test/data/autofill/heuristics/output/06_checkout_petsmart.com.out index 7cf1b70..f32faeb 100644 --- a/chrome/test/data/autofill/heuristics/output/06_checkout_petsmart.com.out +++ b/chrome/test/data/autofill/heuristics/output/06_checkout_petsmart.com.out @@ -9,5 +9,5 @@ UNKNOWN_TYPE | altBillState | • Other State/Province: | | billCountry_1-defau ADDRESS_HOME_ZIP | billZip | • Zip/Postal Code: | | billCountry_1-default PHONE_HOME_WHOLE_NUMBER | billPhone | • Telephone: | | billCountry_1-default EMAIL_ADDRESS | guestEmail | • Email Address: | | billCountry_1-default -UNKNOWN_TYPE | shipOptions | Enter Addresses | useShip | billCountry_1-default -UNKNOWN_TYPE | shipOptions | Ship to the above billing address Ship to a different address | provideNew | billCountry_1-default +UNKNOWN_TYPE | shipOptions | Ship to the above billing address | useShip | billCountry_1-default +UNKNOWN_TYPE | shipOptions | Ship to a different address | provideNew | billCountry_1-default diff --git a/chrome/test/data/autofill/heuristics/output/06_checkout_target.com.out b/chrome/test/data/autofill/heuristics/output/06_checkout_target.com.out index dcf5948..0912e6c 100644 --- a/chrome/test/data/autofill/heuristics/output/06_checkout_target.com.out +++ b/chrome/test/data/autofill/heuristics/output/06_checkout_target.com.out @@ -5,6 +5,6 @@ ADDRESS_HOME_CITY | city | City*: | | name_1-default ADDRESS_HOME_STATE | state | State*: | | name_1-default ADDRESS_HOME_ZIP | zip | Zip Code*: | | name_1-default PHONE_HOME_WHOLE_NUMBER | voice | Phone Number*: | | name_1-default -UNKNOWN_TYPE | order.188:217866256151.ShippingSpeed | (3-5 business days) | std-us | name_1-default -UNKNOWN_TYPE | order.188:217866256151.ShippingSpeed | (2 business days) | second | name_1-default -UNKNOWN_TYPE | order.188:217866256151.ShippingSpeed | Standard Shipping Two-Day Shipping One-Day Shipping | next | name_1-default +UNKNOWN_TYPE | order.188:217866256151.ShippingSpeed | Standard Shipping | std-us | name_1-default +UNKNOWN_TYPE | order.188:217866256151.ShippingSpeed | Two-Day Shipping | second | name_1-default +UNKNOWN_TYPE | order.188:217866256151.ShippingSpeed | One-Day Shipping | next | name_1-default diff --git a/chrome/test/data/autofill/heuristics/output/07_checkout_williams-sonoma.com.out b/chrome/test/data/autofill/heuristics/output/07_checkout_williams-sonoma.com.out index be1e09b..de0790f 100644 --- a/chrome/test/data/autofill/heuristics/output/07_checkout_williams-sonoma.com.out +++ b/chrome/test/data/autofill/heuristics/output/07_checkout_williams-sonoma.com.out @@ -9,5 +9,5 @@ PHONE_HOME_WHOLE_NUMBER | shipTos[0].address.eveningPhone | Alternate Phone | | UNKNOWN_TYPE | shipTos[0].billingAddressUpdate | Yes, use this shipping address for my billing address. | on | shipTos[0].address.fullName_1-default EMAIL_ADDRESS | shipTos[0].address.emailAddr | Email* | | shipTos[0].address.fullName_1-default EMAIL_ADDRESS | shipTos[0].confirmEmailAddr | Confirm Email* | | shipTos[0].address.fullName_1-default -UNKNOWN_TYPE | shipTos[0].shipType | | Standard | shipTos[0].address.fullName_1-default -UNKNOWN_TYPE | shipTos[0].shipType | Standard (5-7 business days) Rush (2-3 business days) | Rush | shipTos[0].address.fullName_1-default +UNKNOWN_TYPE | shipTos[0].shipType | Standard (5-7 business days) | Standard | shipTos[0].address.fullName_1-default +UNKNOWN_TYPE | shipTos[0].shipType | Rush (2-3 business days) | Rush | shipTos[0].address.fullName_1-default diff --git a/chrome/test/data/autofill/heuristics/output/08_register_amazon.com.out b/chrome/test/data/autofill/heuristics/output/08_register_amazon.com.out index aa2c888..ac5d971 100644 --- a/chrome/test/data/autofill/heuristics/output/08_register_amazon.com.out +++ b/chrome/test/data/autofill/heuristics/output/08_register_amazon.com.out @@ -1,5 +1,5 @@ -UNKNOWN_TYPE | action | | new-user | action_1-default -UNKNOWN_TYPE | action | Create a new account (Recommended for Business accounts) Use existing Amazon customer account | sign-in | action_1-default +UNKNOWN_TYPE | action | Create a new account (Recommended for Business accounts) | new-user | action_1-default +UNKNOWN_TYPE | action | Use existing Amazon customer account | sign-in | action_1-default UNKNOWN_TYPE | userName | First and Last Name: | | action_1-default EMAIL_ADDRESS | email | E-mail Address: | | action_1-default EMAIL_ADDRESS | emailCheck | Re-type E-mail Address: | | action_1-default diff --git a/chrome/test/data/autofill/heuristics/output/08_register_continental.com.out b/chrome/test/data/autofill/heuristics/output/08_register_continental.com.out index c3fc1ff..1e46a529 100644 --- a/chrome/test/data/autofill/heuristics/output/08_register_continental.com.out +++ b/chrome/test/data/autofill/heuristics/output/08_register_continental.com.out @@ -8,11 +8,11 @@ NAME_FIRST | ctl00$ContentInfo$Name$FName$txtFName | First Name: | | ctl00$Cust NAME_MIDDLE_INITIAL | ctl00$ContentInfo$Name$MName$txtMName | Middle Initial (optional): | | ctl00$CustomerHeader$ddlCountries_1-default NAME_LAST | ctl00$ContentInfo$Name$LName$txtLName | Last Name: | | ctl00$CustomerHeader$ddlCountries_1-default UNKNOWN_TYPE | ctl00$ContentInfo$Name$suffix$txtSuffix | Suffix (optional): | | ctl00$CustomerHeader$ddlCountries_1-default -UNKNOWN_TYPE | ctl00$ContentInfo$MemberAge$EnrollmentAge | | rdoAdult | ctl00$CustomerHeader$ddlCountries_1-default -UNKNOWN_TYPE | ctl00$ContentInfo$MemberAge$EnrollmentAge | This OnePass account is for an adult 18 years of age or older. This OnePass account is for a minor under the age of 18. | rdoMinor | ctl00$CustomerHeader$ddlCountries_1-default +UNKNOWN_TYPE | ctl00$ContentInfo$MemberAge$EnrollmentAge | This OnePass account is for an adult 18 years of age or older. | rdoAdult | ctl00$CustomerHeader$ddlCountries_1-default +UNKNOWN_TYPE | ctl00$ContentInfo$MemberAge$EnrollmentAge | This OnePass account is for a minor under the age of 18. | rdoMinor | ctl00$CustomerHeader$ddlCountries_1-default UNKNOWN_TYPE | ctl00$ContentInfo$BirthDate$txtDOB | Minor’s Date of Birth: | mm/dd/yyyy | ctl00$CustomerHeader$ddlCountries_1-default -UNKNOWN_TYPE | ctl00$ContentInfo$AddressType$AddressType | Address Type: | rdoAddTypeHome | ctl00$CustomerHeader$ddlCountries_1-default -UNKNOWN_TYPE | ctl00$ContentInfo$AddressType$AddressType | Home Business/Other | rdoAddTypeBusiness | ctl00$CustomerHeader$ddlCountries_1-default +UNKNOWN_TYPE | ctl00$ContentInfo$AddressType$AddressType | Home | rdoAddTypeHome | ctl00$CustomerHeader$ddlCountries_1-default +UNKNOWN_TYPE | ctl00$ContentInfo$AddressType$AddressType | Business/Other | rdoAddTypeBusiness | ctl00$CustomerHeader$ddlCountries_1-default ADDRESS_HOME_LINE1 | ctl00$ContentInfo$Address$address1$txtAddress1 | Street Address: | | ctl00$CustomerHeader$ddlCountries_1-default ADDRESS_HOME_LINE2 | ctl00$ContentInfo$Address$address2$txtAddress2 | Street Address: | | ctl00$CustomerHeader$ddlCountries_1-default ADDRESS_HOME_LINE3 | ctl00$ContentInfo$Address$address3$txtAddress2 | Street Address: | | ctl00$CustomerHeader$ddlCountries_1-default diff --git a/chrome/test/data/autofill/heuristics/output/09_register_deviantart.com.out b/chrome/test/data/autofill/heuristics/output/09_register_deviantart.com.out index 6f56fdb..be69036 100644 --- a/chrome/test/data/autofill/heuristics/output/09_register_deviantart.com.out +++ b/chrome/test/data/autofill/heuristics/output/09_register_deviantart.com.out @@ -1,5 +1,5 @@ -UNKNOWN_TYPE | existingAccount | Are you a new customer? | 0 | existingAccount_1-default -UNKNOWN_TYPE | existingAccount | Are you a new customer? Create a new Buyer Account I have an existing deviantART account (email or username) | 1 | existingAccount_1-default +UNKNOWN_TYPE | existingAccount | Create a new Buyer Account | 0 | existingAccount_1-default +UNKNOWN_TYPE | existingAccount | I have an existing deviantART account (email or username) | 1 | existingAccount_1-default EMAIL_ADDRESS | emailAddress | Email Address | | existingAccount_1-default UNKNOWN_TYPE | password | Password | | existingAccount_1-default UNKNOWN_TYPE | remember_me | Stay logged in | 1 | existingAccount_1-default diff --git a/chrome/test/data/autofill/heuristics/output/11_register_newegg.com.out b/chrome/test/data/autofill/heuristics/output/11_register_newegg.com.out index f2673e2..e072d2e 100644 --- a/chrome/test/data/autofill/heuristics/output/11_register_newegg.com.out +++ b/chrome/test/data/autofill/heuristics/output/11_register_newegg.com.out @@ -19,8 +19,8 @@ PHONE_HOME_CITY_CODE | BDayPhone_tel1 | Daytime Phone | | LoginName_1-default PHONE_HOME_NUMBER | BDayPhone_tel2 | Exchange | | LoginName_1-default PHONE_HOME_NUMBER | BDayPhone_tel3 | Last four digits | | LoginName_1-default UNKNOWN_TYPE | BDayPhone_ext1 | Ext | | LoginName_1-default -UNKNOWN_TYPE | same | Is this your shipping address?* | 1 | LoginName_1-default -UNKNOWN_TYPE | same | Yes No | 0 | LoginName_1-default +UNKNOWN_TYPE | same | Yes | 1 | LoginName_1-default +UNKNOWN_TYPE | same | No | 0 | LoginName_1-default NAME_FIRST | SFirstName | First Name* | | LoginName_1-default NAME_MIDDLE_INITIAL | SMI | MI | | LoginName_1-default NAME_LAST | SLastName | Last Name* | | LoginName_1-default diff --git a/chrome/test/data/autofill/heuristics/output/14_register_target.com.out b/chrome/test/data/autofill/heuristics/output/14_register_target.com.out index bd90100..59c601d 100644 --- a/chrome/test/data/autofill/heuristics/output/14_register_target.com.out +++ b/chrome/test/data/autofill/heuristics/output/14_register_target.com.out @@ -4,5 +4,5 @@ EMAIL_ADDRESS | emailCheck | Re-enter email address:* | | userName_1-default UNKNOWN_TYPE | password | Create a password:* | | userName_1-default UNKNOWN_TYPE | passwordCheck | Re-enter password:* | | userName_1-default UNKNOWN_TYPE | subscribeEmail | Yes, please send me e-mails about special offers, exclusives and promotions from Target. | 1 | userName_1-default -UNKNOWN_TYPE | ageCheck | | yes | userName_1-default -UNKNOWN_TYPE | ageCheck | Yes No | no | userName_1-default +UNKNOWN_TYPE | ageCheck | Yes | yes | userName_1-default +UNKNOWN_TYPE | ageCheck | No | no | userName_1-default diff --git a/chrome/test/data/autofill/heuristics/output/20_checkout_alaskaair.com.out b/chrome/test/data/autofill/heuristics/output/20_checkout_alaskaair.com.out index c32fe76..09d6620 100644 --- a/chrome/test/data/autofill/heuristics/output/20_checkout_alaskaair.com.out +++ b/chrome/test/data/autofill/heuristics/output/20_checkout_alaskaair.com.out @@ -21,8 +21,8 @@ UNKNOWN_TYPE | CreditCardInformation.BillingAddressEntry.OtherStates_Selected | ADDRESS_HOME_ZIP | CreditCardInformation.BillingAddressEntry.PostalCode | Zip/Postal Code | | MyWalletInformation.UseMyWalletFunds_1-default ADDRESS_HOME_COUNTRY | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected | Country Code | 1 | MyWalletInformation.UseMyWalletFunds_1-default PHONE_HOME_WHOLE_NUMBER | CreditCardInformation.BillingPhoneNumberEntry.Number | Phone (with area code) | | MyWalletInformation.UseMyWalletFunds_1-default -UNKNOWN_TYPE | TripInsurance.QuoteID | Reimburses non-refundable, prepaid expenses up to the cost of your ticket(s) if you cancel your tripCovers emergency medical / dental and emergency medical transportation while travelingHelps with trip interruption, lost or damaged baggage, baggage delay, and additional travel delay costs Terms, conditions and exclusions apply, learn more. | 657566350481481886 | MyWalletInformation.UseMyWalletFunds_1-default -UNKNOWN_TYPE | TripInsurance.QuoteID | Yes, add trip protection for a total of $21.00. No, I choose not to protect my purchase. | 657566350481481887 | MyWalletInformation.UseMyWalletFunds_1-default +UNKNOWN_TYPE | TripInsurance.QuoteID | Yes, add trip protection for a total of $21.00. | 657566350481481886 | MyWalletInformation.UseMyWalletFunds_1-default +UNKNOWN_TYPE | TripInsurance.QuoteID | No, I choose not to protect my purchase. | 657566350481481887 | MyWalletInformation.UseMyWalletFunds_1-default CREDIT_CARD_NUMBER | AncillaryCreditCardInformation.BillingCreditCardEntry.CardNumber | Card Number | | MyWalletInformation.UseMyWalletFunds_1-cc CREDIT_CARD_EXP_MONTH | AncillaryCreditCardInformation.BillingCreditCardEntry.ExpirationMonths_Selected | Expiration* | | MyWalletInformation.UseMyWalletFunds_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | AncillaryCreditCardInformation.BillingCreditCardEntry.ExpirationYears_Selected | Expiration* | | MyWalletInformation.UseMyWalletFunds_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/20_landsend.out b/chrome/test/data/autofill/heuristics/output/20_landsend.out index e523b01..61569d4 100644 --- a/chrome/test/data/autofill/heuristics/output/20_landsend.out +++ b/chrome/test/data/autofill/heuristics/output/20_landsend.out @@ -2,7 +2,7 @@ NAME_FIRST | fname | First Name | | fname_1-default NAME_LAST | lname | Last Name | | fname_1-default ADDRESS_HOME_LINE1 | address | Address | | fname_1-default UNKNOWN_TYPE | address | Line 2 | | fname_1-default -ADDRESS_HOME_LINE1 | address | Address Line 2 Line 3 | | fname_1-default +UNKNOWN_TYPE | address | Line 3 | | fname_1-default ADDRESS_HOME_CITY | city | City | | fname_1-default ADDRESS_HOME_STATE | main-shipping-state | State | | fname_1-default ADDRESS_HOME_STATE | main-shipping-province | Province | | fname_1-default diff --git a/chrome/test/data/autofill/heuristics/output/23_checkout_m_gap.com.out b/chrome/test/data/autofill/heuristics/output/23_checkout_m_gap.com.out index f926812..e19b954 100644 --- a/chrome/test/data/autofill/heuristics/output/23_checkout_m_gap.com.out +++ b/chrome/test/data/autofill/heuristics/output/23_checkout_m_gap.com.out @@ -36,7 +36,7 @@ ADDRESS_HOME_LINE1 | shippingAddressFieldGroup5-shippingAddressLine1 | *House Nu ADDRESS_HOME_LINE2 | shippingAddressFieldGroup5-shippingAddressLine2 | Address line 2 | | shippingAddressFieldGroup5-shippingLastName_1-default PHONE_HOME_WHOLE_NUMBER | shippingDayPhone | * Day phone (incl. area code) | | shippingAddressFieldGroup5-shippingLastName_1-default UNKNOWN_TYPE | shippingBillingSameAsShipping | Use this address for my Billing information. | on | shippingAddressFieldGroup5-shippingLastName_1-default -UNKNOWN_TYPE | shippingOptions | * Shipping method: | 7 | shippingAddressFieldGroup5-shippingLastName_1-default -UNKNOWN_TYPE | shippingOptions | * Shipping method: | 1 | shippingAddressFieldGroup5-shippingLastName_1-default -UNKNOWN_TYPE | shippingOptions | * Shipping method: | 3 | shippingAddressFieldGroup5-shippingLastName_1-default -UNKNOWN_TYPE | shippingOptions | 7-9 business days - $0.00 3-5 business days - $7.00 2 business days - $17.00 1 business day - $22.00 | 5 | shippingAddressFieldGroup5-shippingLastName_1-default +UNKNOWN_TYPE | shippingOptions | 7-9 business days - $0.00 | 7 | shippingAddressFieldGroup5-shippingLastName_1-default +UNKNOWN_TYPE | shippingOptions | 3-5 business days - $7.00 | 1 | shippingAddressFieldGroup5-shippingLastName_1-default +UNKNOWN_TYPE | shippingOptions | 2 business days - $17.00 | 3 | shippingAddressFieldGroup5-shippingLastName_1-default +UNKNOWN_TYPE | shippingOptions | 1 business day - $22.00 | 5 | shippingAddressFieldGroup5-shippingLastName_1-default diff --git a/chrome/test/data/autofill/heuristics/output/23_checkout_m_nordstroms.com.out b/chrome/test/data/autofill/heuristics/output/23_checkout_m_nordstroms.com.out index b7d59cc..e4a0043 100644 --- a/chrome/test/data/autofill/heuristics/output/23_checkout_m_nordstroms.com.out +++ b/chrome/test/data/autofill/heuristics/output/23_checkout_m_nordstroms.com.out @@ -7,8 +7,8 @@ ADDRESS_HOME_LINE2 | | Address 2 (Optional) | | _1-default ADDRESS_HOME_CITY | | City | | _1-default ADDRESS_HOME_STATE | | State | | _1-default ADDRESS_HOME_ZIP | | ZIP Code | | _1-default -UNKNOWN_TYPE | | First Name M.I. | | _1-default -UNKNOWN_TYPE | | First Name M.I. Last Name Address 1 Address 2 (Optional) City State ZIP Code Phone Information | on | _1-default +PHONE_HOME_WHOLE_NUMBER | | Phone Information | | _1-default +UNKNOWN_TYPE | | | on | _1-default UNKNOWN_TYPE | multiple-address | Shipping to more than one address? | false | _1-default UNKNOWN_TYPE | multiple-address | Shipping to more than one address? | true | _1-default UNKNOWN_TYPE | | Note Number | | _1-default @@ -21,7 +21,7 @@ UNKNOWN_TYPE | | Employee Number | | _1-default UNKNOWN_TYPE | discount | Discount | | _1-default UNKNOWN_TYPE | discount | % | | _1-default UNKNOWN_TYPE | | CREDIT CARD | | _1-default -UNKNOWN_TYPE | | CREDIT CARD | | _1-default +UNKNOWN_TYPE | | Card Number Information | | _1-default UNKNOWN_TYPE | | | | _1-default UNKNOWN_TYPE | | | | _1-default UNKNOWN_TYPE | credit-ccv | Security Code Information | | _1-default @@ -36,6 +36,6 @@ ADDRESS_HOME_CITY | | City | | _1-default ADDRESS_HOME_STATE | | State/Province | | _1-default ADDRESS_HOME_ZIP | | ZIP/Postal Code | | _1-default ADDRESS_HOME_COUNTRY | | Country | 0 | _1-default -EMAIL_ADDRESS | | We'll send any order correspondence e-mails to the address below, and give you a call if anything comes up. E-mail | | _1-default -EMAIL_ADDRESS | | We'll send any order correspondence e-mails to the address below, and give you a call if anything comes up. E-mail | | _1-default -UNKNOWN_TYPE | | Note Number Access Code Gift Card Number Access Code Please do not fill out the next field, it is a security measure to insure that this page is being visited by a human. Enter a Promotion Code Employee Number % % Card Number Information First Name M.I. Last Name Address 1 Address 2 (Optional) City State/Province ZIP/Postal Code Country E-mail Information Information Phone Information Information | on | _1-default +EMAIL_ADDRESS | | E-mail Information Information | | _1-default +PHONE_HOME_WHOLE_NUMBER | | Phone Information Information | | _1-default +UNKNOWN_TYPE | | We'll send any order correspondence e-mails to the address below, and give you a call if anything comes up. E-mail | on | _1-default diff --git a/components/autofill/content/renderer/form_autofill_util.cc b/components/autofill/content/renderer/form_autofill_util.cc index 7d40559..b06f55d 100644 --- a/components/autofill/content/renderer/form_autofill_util.cc +++ b/components/autofill/content/renderer/form_autofill_util.cc @@ -710,7 +710,7 @@ bool ExtractFieldsFromControlElements( ExtractMask extract_mask, ScopedVector<FormFieldData>* form_fields, std::vector<bool>* fields_extracted, - std::map<base::string16, FormFieldData*>* name_map) { + std::map<WebFormControlElement, FormFieldData*>* element_map) { for (size_t i = 0; i < control_elements.size(); ++i) { const WebFormControlElement& control_element = control_elements[i]; @@ -727,10 +727,7 @@ bool ExtractFieldsFromControlElements( FormFieldData* form_field = new FormFieldData; WebFormControlElementToFormField(control_element, extract_mask, form_field); form_fields->push_back(form_field); - // TODO(jhawkins): A label element is mapped to a form control element's id. - // field->name() will contain the id only if the name does not exist. Add - // an id() method to WebFormControlElement and use that here. - (*name_map)[form_field->name] = form_field; + (*element_map)[control_element] = form_field; (*fields_extracted)[i] = true; } @@ -742,11 +739,13 @@ bool ExtractFieldsFromControlElements( } // For each label element, get the corresponding form control element, use the -// form control element's name as a key into the <name, FormFieldData> map to -// find the previously created FormFieldData and set the FormFieldData's label -// to the label.firstChild().nodeValue() of the label element. -void MatchLabelsAndFields(const WebElementCollection& labels, - std::map<base::string16, FormFieldData*>* name_map) { +// form control element's name as a key into the +// <WebFormControlElement, FormFieldData> map to find the previously created +// FormFieldData and set the FormFieldData's label to the +// label.firstChild().nodeValue() of the label element. +void MatchLabelsAndFields( + const WebElementCollection& labels, + std::map<WebFormControlElement, FormFieldData*>* element_map) { CR_DEFINE_STATIC_LOCAL(WebString, kFor, ("for")); CR_DEFINE_STATIC_LOCAL(WebString, kHidden, ("hidden")); @@ -755,30 +754,48 @@ void MatchLabelsAndFields(const WebElementCollection& labels, WebLabelElement label = item.to<WebLabelElement>(); WebFormControlElement field_element = label.correspondingControl().to<WebFormControlElement>(); + FormFieldData* field_data = nullptr; - base::string16 element_name; if (field_element.isNull()) { // Sometimes site authors will incorrectly specify the corresponding // field element's name rather than its id, so we compensate here. - element_name = label.getAttribute(kFor); + base::string16 element_name = label.getAttribute(kFor); + if (element_name.empty()) + continue; + // Look through the list for elements with this name. There can actually + // be more than one. In this case, the label may not be particularly + // useful, so just discard it. + for (const auto& iter : *element_map) { + if (iter.second->name == element_name) { + if (field_data) { + field_data = nullptr; + break; + } else { + field_data = iter.second; + } + } + } } else if (!field_element.isFormControlElement() || field_element.formControlType() == kHidden) { continue; } else { - element_name = field_element.nameForAutofill(); + // Typical case: look up |field_data| in |element_map|. + auto iter = element_map->find(field_element); + if (iter == element_map->end()) + continue; + field_data = iter->second; } - auto iter = name_map->find(element_name); - if (iter == name_map->end()) + if (!field_data) continue; base::string16 label_text = FindChildText(label); // Concatenate labels because some sites might have multiple label // candidates. - if (!iter->second->label.empty() && !label_text.empty()) - iter->second->label += base::ASCIIToUTF16(" "); - iter->second->label += label_text; + if (!field_data->label.empty() && !label_text.empty()) + field_data->label += base::ASCIIToUTF16(" "); + field_data->label += label_text; } } @@ -806,22 +823,19 @@ bool FormOrFieldsetsToFormData( DCHECK(form_control_element); // A map from a FormFieldData's name to the FormFieldData itself. - std::map<base::string16, FormFieldData*> name_map; + std::map<WebFormControlElement, FormFieldData*> element_map; - // The extracted FormFields. We use pointers so we can store them in - // |name_map|. + // The extracted FormFields. We use pointers so we can store them in + // |element_map|. ScopedVector<FormFieldData> form_fields; // A vector of bools that indicate whether each field in the form meets the // requirements and thus will be in the resulting |form|. std::vector<bool> fields_extracted(control_elements.size(), false); - if (!ExtractFieldsFromControlElements(control_elements, - requirements, - extract_mask, - &form_fields, - &fields_extracted, - &name_map)) { + if (!ExtractFieldsFromControlElements(control_elements, requirements, + extract_mask, &form_fields, + &fields_extracted, &element_map)) { return false; } @@ -834,14 +848,14 @@ bool FormOrFieldsetsToFormData( WebElementCollection labels = form_element->getElementsByHTMLTagName(kLabel); DCHECK(!labels.isNull()); - MatchLabelsAndFields(labels, &name_map); + MatchLabelsAndFields(labels, &element_map); } else { // Same as the if block, but for all the labels in fieldsets. for (size_t i = 0; i < fieldsets.size(); ++i) { WebElementCollection labels = fieldsets[i].getElementsByHTMLTagName(kLabel); DCHECK(!labels.isNull()); - MatchLabelsAndFields(labels, &name_map); + MatchLabelsAndFields(labels, &element_map); } } |