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

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

Issue 12721004: Autofill:Autocomplete: Enable autocheckout of input elements of type password. This will support fi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
Index: chrome/renderer/autofill/form_autofill_browsertest.cc
diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc
index 17c91eb022df5b68f5cafdecfec1667c47f18bc6..550da53ab138c181fd3ab4ec61db2f9639a5241c 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -302,7 +302,6 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldSelect) {
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldInvalidType) {
LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
" <INPUT type=\"hidden\" id=\"hidden\" value=\"apple\"/>"
- " <INPUT type=\"password\" id=\"password\" value=\"secret\"/>"
" <INPUT type=\"submit\" id=\"submit\" value=\"Send\"/>"
"</FORM>");
@@ -321,13 +320,6 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldInvalidType) {
expected.form_control_type = "hidden";
EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
- web_element = frame->document().getElementById("password");
- element = web_element.to<WebFormControlElement>();
- WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);
- expected.name = ASCIIToUTF16("password");
- expected.form_control_type = "password";
- EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
-
web_element = frame->document().getElementById("submit");
element = web_element.to<WebFormControlElement>();
WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);
@@ -336,6 +328,29 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldInvalidType) {
EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
}
+// We should be able to extract password fields.
+TEST_F(FormAutofillTest, WebFormControlElementToPasswordFormField) {
+ LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
+ " <INPUT type=\"password\" id=\"password\" value=\"secret\"/>"
+ "</FORM>");
+
+ WebFrame* frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ WebElement web_element = frame->document().getElementById("password");
+ WebFormControlElement element = web_element.to<WebFormControlElement>();
+ FormFieldData result;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);
+
+ FormFieldData expected;
+ expected.max_length = WebInputElement::defaultMaxLength();
+ expected.name = ASCIIToUTF16("password");
+ expected.form_control_type = "password";
+ expected.value = ASCIIToUTF16("secret");
+ expected.is_password_field = true;
+ EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
+}
+
// We should be able to extract the autocompletetype attribute.
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) {
std::string html =
@@ -419,12 +434,12 @@ TEST_F(FormAutofillTest, WebFormElementToFormData) {
" <OPTION value=\"CA\">California</OPTION>"
" <OPTION value=\"TX\">Texas</OPTION>"
" </SELECT>"
- // The below inputs should be ignored
- " <LABEL for=\"notvisible\">Hidden:</LABEL>"
- " <INPUT type=\"hidden\" id=\"notvisible\" value=\"apple\"/>"
" <LABEL for=\"password\">Password:</LABEL>"
" <INPUT type=\"password\" id=\"password\" value=\"secret\"/>"
" <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>"
+ // The below inputs should be ignored
+ " <LABEL for=\"notvisible\">Hidden:</LABEL>"
+ " <INPUT type=\"hidden\" id=\"notvisible\" value=\"apple\"/>"
"</FORM>");
WebFrame* frame = GetMainFrame();
@@ -450,7 +465,7 @@ TEST_F(FormAutofillTest, WebFormElementToFormData) {
EXPECT_EQ(GURL("http://cnn.com"), form.action);
const std::vector<FormFieldData>& fields = form.fields;
- ASSERT_EQ(3U, fields.size());
+ ASSERT_EQ(4U, fields.size());
FormFieldData expected;
expected.name = ASCIIToUTF16("firstname");
@@ -473,6 +488,14 @@ TEST_F(FormAutofillTest, WebFormElementToFormData) {
expected.form_control_type = "select-one";
expected.max_length = 0;
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]);
+
+ expected.name = ASCIIToUTF16("password");
+ expected.value = ASCIIToUTF16("secret");
+ expected.label = ASCIIToUTF16("Password:");
+ expected.form_control_type = "password";
+ expected.is_password_field = true;
+ expected.max_length = WebInputElement::defaultMaxLength();
+ EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]);
}
// We should not be able to serialize a form with too many fillable fields.
« no previous file with comments | « no previous file | components/autofill/browser/form_structure.cc » ('j') | components/autofill/browser/form_structure.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698