Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1222)

Unified Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 1153023004: Prepare the infrastructure for password overrides. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the test. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/autofill.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/password_autofill_agent_browsertest.cc
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
index 6e0d88cf1a463a7dd9732fbaafcc930e2ed4b9bc..e3b810e3ad6076216c43e6caaec7cff8a90cb1e0 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -14,6 +14,7 @@
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
+#include "components/autofill/core/common/password_form_field_prediction_map.h"
#include "content/public/renderer/render_frame.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebString.h"
@@ -1817,9 +1818,9 @@ TEST_F(PasswordAutofillAgentTest, FindingUsernameWithoutAutofillPredictions) {
ExpectFormSubmittedWithUsernameAndPasswords("temp@google.com", "random", "");
}
-// Tests that username predictions are followed when identifying the username
-// in a password form with two plain text fields.
-TEST_F(PasswordAutofillAgentTest, FindingUsernameWithAutofillPredictions) {
+// 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();
blink::WebInputElement email_element = GetInputElementByID(kEmailName);
@@ -1832,15 +1833,17 @@ TEST_F(PasswordAutofillAgentTest, FindingUsernameWithAutofillPredictions) {
ASSERT_TRUE(WebFormElementToFormData(form_element,
blink::WebFormControlElement(),
EXTRACT_NONE, &form_data, nullptr));
- // Simulate Autofill predictions: the first field is username.
- std::map<autofill::FormData, autofill::FormFieldData> predictions;
- predictions[form_data] = form_data.fields[0];
- AutofillMsg_AutofillUsernameDataReceived msg(0, predictions);
+ // Simulate Autofill predictions: the first field is username, the third
+ // one is password.
+ std::map<autofill::FormData, PasswordFormFieldPredictionMap> predictions;
+ predictions[form_data][PREDICTION_USERNAME] = form_data.fields[0];
+ predictions[form_data][PREDICTION_NEW_PASSWORD] = form_data.fields[2];
+ AutofillMsg_AutofillUsernameAndPasswordDataReceived msg(0, predictions);
static_cast<content::RenderFrameObserver*>(password_autofill_agent_)
->OnMessageReceived(msg);
- // The prediction should still match even if the form changes, as long
- // as the particular element doesn't change.
+ // 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');"
@@ -1856,6 +1859,9 @@ TEST_F(PasswordAutofillAgentTest, FindingUsernameWithAutofillPredictions) {
// 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("temp", "random", "");
}
« no previous file with comments | « no previous file | components/autofill.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698