Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fallback to infer text behind <input>s for assigned labels.
A developer can associate a <label> to an input in two ways: 1) Using the for-attribute: <label for=fieldID> 2) By making the <input> a child of the <label>. This CL addresses the second case. Right now, FindChildText() is used to extract the content of the label. However, FindChildText() stops at autofillable elements, which causes us to miss the label in cases like this: <label> <input> text </label> This causes problems e.g. on citilink.ru (see https://chromium-review.googlesource.com/c/chromium/src/+/4079457/comment/de5c03ad_a1d9971a/). Generally, this behaviour of FindChildText() seems reasonable, since text behind an input is oftentimes only relevant for error handling etc. However, in case the input is explicitly associated with the label, it might make sense to be more lenient. This CL adds a fallback mechanism: If extracting a label using FindChildText() for an associated label of the second kind fails, we instead look at the text after the input. Change-Id: I20a69ede53f65ce3f255a2fd7450f4a0e8365d26 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4106611 Reviewed-by: Dominic Battré <battre@chromium.org> Commit-Queue: Florian Leimgruber <fleimgruber@google.com> Cr-Commit-Position: refs/heads/main@{#1084877}
- Loading branch information
1 parent
1615725
commit 86bff38
Showing
5 changed files
with
56 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
components/test/data/autofill/heuristics/output/111_checkout_virgin_america.com.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
UNKNOWN_TYPE | creditCard | American Express Discover | | creditCard_1 | ||
CREDIT_CARD_NAME_FULL | cardholderName | Cardholder's name | | cardholderName_2 | ||
CREDIT_CARD_EXP_MONTH | expireMonth | Expiration Date | | cardholderName_2 | ||
CREDIT_CARD_EXP_4_DIGIT_YEAR | expireYear | Expiration Date | | cardholderName_2 | ||
CREDIT_CARD_VERIFICATION_CODE | securityNumber | CVV Number 3 or 4 digit number | | cardholderName_2 | ||
UNKNOWN_TYPE | nickname | Card's nickname e.g. My Visa, Corporate card, etc | | creditCard_1 | ||
UNKNOWN_TYPE | useAddress | Use stored address | use-stored-address | creditCard_1 | ||
UNKNOWN_TYPE | stored-address | | ? | creditCard_1 | ||
UNKNOWN_TYPE | useAddress | Add new address | add-new-address | creditCard_1 | ||
UNKNOWN_TYPE | shouldSave | Save credit card info | on | creditCard_1 | ||
CREDIT_CARD_NUMBER | creditCard | Invalid card # | | creditCard_1 | ||
CREDIT_CARD_NAME_FULL | cardholderName | Cardholder's name | | creditCard_1 | ||
CREDIT_CARD_EXP_MONTH | expireMonth | Expiration Date | | creditCard_1 | ||
CREDIT_CARD_EXP_4_DIGIT_YEAR | expireYear | Expiration Date | | creditCard_1 | ||
CREDIT_CARD_VERIFICATION_CODE | securityNumber | CVV Number 3 or 4 digit number | | creditCard_1 | ||
UNKNOWN_TYPE | nickname | Card's nickname e.g. My Visa, Corporate card, etc | | nickname_2 | ||
UNKNOWN_TYPE | useAddress | Use stored address | use-stored-address | nickname_2 | ||
UNKNOWN_TYPE | stored-address | | ? | nickname_2 | ||
UNKNOWN_TYPE | useAddress | Add new address | add-new-address | nickname_2 | ||
UNKNOWN_TYPE | shouldSave | Save credit card info | on | nickname_2 |