Commit 088743f4 authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Password page analyzer fix.

This CL fixes typo password_inputs->explicit_password_inputs. Which in some rare situations
leads to crash.

Bug: 805892
Change-Id: Ibe76806154e7172a4d433d51ec92fb20ba0d900c
Reviewed-on: https://chromium-review.googlesource.com/893298Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: Maxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532870}
parent 27a19b82
...@@ -99,6 +99,13 @@ const char kInferredUsernameAutocompleteAttributes[] = ...@@ -99,6 +99,13 @@ const char kInferredUsernameAutocompleteAttributes[] =
" <input type='password' autocomplete='new-password'>" " <input type='password' autocomplete='new-password'>"
"</form>"; "</form>";
const char kPasswordFieldsWithAndWithoutAutocomplete[] =
"<form>"
" <input type='password'>"
" <input type='text'>"
" <input type='password' autocomplete='current-password'>"
"</form>";
const std::string AutocompleteSuggestionString(const std::string& suggestion) { const std::string AutocompleteSuggestionString(const std::string& suggestion) {
return "Input elements should have autocomplete " return "Input elements should have autocomplete "
"attributes (suggested: \"" + "attributes (suggested: \"" +
...@@ -254,4 +261,14 @@ TEST_F(PagePasswordsAnalyserTest, InferredUsernameAutocompleteAttributes) { ...@@ -254,4 +261,14 @@ TEST_F(PagePasswordsAnalyserTest, InferredUsernameAutocompleteAttributes) {
RunTestCase(); RunTestCase();
} }
TEST_F(PagePasswordsAnalyserTest, PasswordFieldWithAndWithoutAutocomplete) {
LoadTestCase(kPasswordFieldsWithAndWithoutAutocomplete);
Expect(
"Multiple forms should be contained in their own "
"form elements; break up complex forms into ones that represent a "
"single action:",
PageFormAnalyserLogger::kVerbose, {0});
RunTestCase();
}
} // namespace autofill } // namespace autofill
...@@ -371,8 +371,9 @@ void AnalyseForm(const FormInputCollection& form_input_collection, ...@@ -371,8 +371,9 @@ void AnalyseForm(const FormInputCollection& form_input_collection,
} else { } else {
// By default (if the other heuristics fail), the first text field // By default (if the other heuristics fail), the first text field
// preceding a password field will be considered the username field. // preceding a password field will be considered the username field.
for (username_field_guess = password_inputs[0] - 1;; for (username_field_guess = explicit_password_inputs[0] - 1;;
--username_field_guess) { --username_field_guess) {
DCHECK(username_field_guess < signature.size());
if (signature[username_field_guess] == kTextFieldSignature) if (signature[username_field_guess] == kTextFieldSignature)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment