Commit 6ea22f56 authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

Removed unused methods in |PasswordAutofillAgent|.

TBR=mkwst@chromium.org

Bug: 875768
Change-Id: I5158a8144d87584a844071aee35ce44b9119369b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824475
Commit-Queue: Matthias Körber <koerber@google.com>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700166}
parent 4923e7e1
...@@ -177,9 +177,6 @@ class FakePasswordAutofillAgent ...@@ -177,9 +177,6 @@ class FakePasswordAutofillAgent
logging_state_active_ = active; logging_state_active_ = active;
} }
void AutofillUsernameAndPasswordDataReceived(
const autofill::FormsPredictionsMap& predictions) override {}
// Records whether SetLoggingState() gets called. // Records whether SetLoggingState() gets called.
bool called_set_logging_state_; bool called_set_logging_state_;
// Records data received via SetLoggingState() call. // Records data received via SetLoggingState() call.
......
...@@ -70,10 +70,6 @@ namespace { ...@@ -70,10 +70,6 @@ namespace {
// The name of the username/password element in the form. // The name of the username/password element in the form.
const char kUsernameName[] = "username"; const char kUsernameName[] = "username";
const char kPasswordName[] = "password"; const char kPasswordName[] = "password";
const char kDisplayName[] = "display-name";
const char kCreditCardOwnerName[] = "creditcardowner";
const char kCreditCardNumberName[] = "creditcardnumber";
const char kCreditCardVerificationName[] = "cvc";
const char kSearchField[] = "search"; const char kSearchField[] = "search";
const char kSocialMediaTextArea[] = "new_chirp"; const char kSocialMediaTextArea[] = "new_chirp";
...@@ -219,15 +215,6 @@ const char kJavaScriptClick[] = ...@@ -219,15 +215,6 @@ const char kJavaScriptClick[] =
"form.dispatchEvent(event);" "form.dispatchEvent(event);"
"console.log('clicked!');"; "console.log('clicked!');";
const char kFormHTMLWithTwoTextFields[] =
"<FORM name='LoginTestForm' id='LoginTestForm' "
"action='http://www.bidule.com'>"
" <INPUT type='text' id='display-name'/>"
" <INPUT type='text' id='username'/>"
" <INPUT type='password' id='password'/>"
" <INPUT type='submit' value='Login'/>"
"</FORM>";
const char kPasswordChangeFormHTML[] = const char kPasswordChangeFormHTML[] =
"<FORM name='ChangeWithUsernameForm' action='http://www.bidule.com'>" "<FORM name='ChangeWithUsernameForm' action='http://www.bidule.com'>"
" <INPUT type='text' id='username'/>" " <INPUT type='text' id='username'/>"
...@@ -2314,68 +2301,6 @@ TEST_F(PasswordAutofillAgentTest, ...@@ -2314,68 +2301,6 @@ TEST_F(PasswordAutofillAgentTest,
std::string(), false); std::string(), false);
} }
// Test that the last plain text field before a password field is chosen as a
// username, in a form with 2 plain text fields without username predictions.
TEST_F(PasswordAutofillAgentTest, FindingUsernameWithoutAutofillPredictions) {
LoadHTML(kFormHTMLWithTwoTextFields);
UpdateUsernameAndPasswordElements();
WebInputElement display_name_element = GetInputElementByID(kDisplayName);
SimulateUsernameTyping("temp");
SimulateUserInputChangeForElement(&display_name_element, "User123");
SimulatePasswordTyping("random");
SaveAndSubmitForm();
// Observe that the PasswordAutofillAgent identifies the second field as
// username.
ExpectFormSubmittedWithUsernameAndPasswords("temp", "random", "");
}
// Tests that field predictions are followed when identifying the username
// and password in a password form with two plain text fields.
TEST_F(PasswordAutofillAgentTest, FindingFieldsWithAutofillPredictions) {
LoadHTML(kFormHTMLWithTwoTextFields);
UpdateUsernameAndPasswordElements();
WebInputElement display_name_element = GetInputElementByID(kDisplayName);
SimulateUsernameTyping("temp");
SimulateUserInputChangeForElement(&display_name_element, "User123");
SimulatePasswordTyping("random");
// Find FormData for visible password form.
WebFormElement form_element = username_element_.Form();
FormData form_data;
ASSERT_TRUE(WebFormElementToFormData(
form_element, blink::WebFormControlElement(), nullptr,
form_util::EXTRACT_NONE, &form_data, nullptr));
// Simulate Autofill predictions: the first field is username, the third
// one is password.
autofill::FormsPredictionsMap predictions;
predictions[form_data][form_data.fields[0]] =
PasswordFormFieldPredictionType::kUsername;
predictions[form_data][form_data.fields[2]] =
PasswordFormFieldPredictionType::kNewPassword;
password_autofill_agent_->AutofillUsernameAndPasswordDataReceived(
predictions);
// The predictions should still match even if the form changes, as long
// as the particular elements don't change.
std::string add_field_to_form =
"var form = document.getElementById('LoginTestForm');"
"var new_input = document.createElement('input');"
"new_input.setAttribute('type', 'text');"
"new_input.setAttribute('id', 'other_field');"
"form.appendChild(new_input);";
ExecuteJavaScriptForTests(add_field_to_form.c_str());
SaveAndSubmitForm();
// Observe that the PasswordAutofillAgent identifies the first field as
// username.
// TODO(msramek): We should also test that adding another password field
// won't override the password field prediction either. However, the password
// field predictions are not taken into account yet.
ExpectFormSubmittedWithUsernameAndPasswords("User123", "random", "");
}
// The user types in a username and a password. Then JavaScript changes password // The user types in a username and a password. Then JavaScript changes password
// field to readonly state before submit. PasswordAutofillAgent can correctly // field to readonly state before submit. PasswordAutofillAgent can correctly
// process readonly password field. This test models behaviour of gmail.com. // process readonly password field. This test models behaviour of gmail.com.
...@@ -2569,39 +2494,6 @@ TEST_F(PasswordAutofillAgentTest, ...@@ -2569,39 +2494,6 @@ TEST_F(PasswordAutofillAgentTest,
CheckSuggestions("", false); CheckSuggestions("", false);
} }
// Tests that NOT_PASSWORD field predictions are followed so that no password
// form is submitted.
TEST_F(PasswordAutofillAgentTest, IgnoreNotPasswordFields) {
LoadHTML(kCreditCardFormHTML);
WebInputElement credit_card_owner_element =
GetInputElementByID(kCreditCardOwnerName);
WebInputElement credit_card_number_element =
GetInputElementByID(kCreditCardNumberName);
WebInputElement credit_card_verification_element =
GetInputElementByID(kCreditCardVerificationName);
SimulateUserInputChangeForElement(&credit_card_owner_element, "JohnSmith");
SimulateUserInputChangeForElement(&credit_card_number_element,
"1234123412341234");
SimulateUserInputChangeForElement(&credit_card_verification_element, "123");
// Find FormData for visible form.
WebFormElement form_element = credit_card_number_element.Form();
FormData form_data;
ASSERT_TRUE(WebFormElementToFormData(
form_element, blink::WebFormControlElement(), nullptr,
form_util::EXTRACT_NONE, &form_data, nullptr));
// Simulate Autofill predictions: the third field is not a password.
autofill::FormsPredictionsMap predictions;
predictions[form_data][form_data.fields[2]] =
PasswordFormFieldPredictionType::kNotPassword;
password_autofill_agent_->AutofillUsernameAndPasswordDataReceived(
predictions);
SaveAndSubmitForm(form_element);
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(fake_driver_.called_password_form_submitted_only_for_fallback());
}
// Tests that only the password field is autocompleted when the browser sends // Tests that only the password field is autocompleted when the browser sends
// back data with only one credentials and empty username. // back data with only one credentials and empty username.
TEST_F(PasswordAutofillAgentTest, NotAutofillNoUsername) { TEST_F(PasswordAutofillAgentTest, NotAutofillNoUsername) {
......
...@@ -92,10 +92,6 @@ interface PasswordAutofillAgent { ...@@ -92,10 +92,6 @@ interface PasswordAutofillAgent {
// logging the decisions made about saving the password. // logging the decisions made about saving the password.
SetLoggingState(bool active); SetLoggingState(bool active);
// Sent when Autofill manager gets the query response from the Autofill server
// which contains information about username and password for some forms.
// |predictions| maps forms to their username fields.
AutofillUsernameAndPasswordDataReceived(FormsPredictionsMap predictions);
}; };
// There is one instance of this interface per render frame in the render // There is one instance of this interface per render frame in the render
......
...@@ -1320,11 +1320,6 @@ void PasswordAutofillAgent::SetLoggingState(bool active) { ...@@ -1320,11 +1320,6 @@ void PasswordAutofillAgent::SetLoggingState(bool active) {
logging_state_active_ = active; logging_state_active_ = active;
} }
void PasswordAutofillAgent::AutofillUsernameAndPasswordDataReceived(
const FormsPredictionsMap& predictions) {
form_predictions_.insert(predictions.begin(), predictions.end());
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// PasswordAutofillAgent, private: // PasswordAutofillAgent, private:
......
...@@ -131,8 +131,6 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, ...@@ -131,8 +131,6 @@ class PasswordAutofillAgent : public content::RenderFrameObserver,
void FillIntoFocusedField(bool is_password, void FillIntoFocusedField(bool is_password,
const base::string16& credential) override; const base::string16& credential) override;
void SetLoggingState(bool active) override; void SetLoggingState(bool active) override;
void AutofillUsernameAndPasswordDataReceived(
const FormsPredictionsMap& predictions) override;
// FormTracker::Observer // FormTracker::Observer
void OnProvisionallySaveForm(const blink::WebFormElement& form, void OnProvisionallySaveForm(const blink::WebFormElement& form,
......
...@@ -93,9 +93,6 @@ class FakePasswordAutofillAgent ...@@ -93,9 +93,6 @@ class FakePasswordAutofillAgent
logging_state_active_ = active; logging_state_active_ = active;
} }
void AutofillUsernameAndPasswordDataReceived(
const autofill::FormsPredictionsMap& predictions) override {}
// Records whether SetLoggingState() gets called. // Records whether SetLoggingState() gets called.
bool called_set_logging_state_; bool called_set_logging_state_;
// Records data received via SetLoggingState() call. // Records data received via SetLoggingState() call.
......
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