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 f793a2f5eb5e0b2cea4ec5a874909f2ad354cf9a..17343d9cece1966095724bfc0ed9559dd6bbe346 100644 |
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc |
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc |
@@ -2385,6 +2385,36 @@ TEST_F(FormAutofillTest, WebFormElementToFormData_CssClasses) { |
EXPECT_EQ(base::string16(), form.fields[2].css_classes); |
} |
+// Tests id attributes are set. |
+TEST_F(FormAutofillTest, WebFormElementToFormData_IdAttributes) { |
+ LoadHTML( |
+ "<FORM name='TestForm' id='form' action='http://cnn.com' method='post' " |
+ "autocomplete='off'>" |
+ " <INPUT type='text' name='name1' id='firstname' />" |
+ " <INPUT type='text' name='name2' id='lastname' />" |
+ " <INPUT type='text' name='same' id='same' />" |
+ " <INPUT type='text' id='addressline1' />" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(nullptr, frame); |
+ |
+ WebFormElement web_form = |
+ frame->document().getElementById("form").to<WebFormElement>(); |
+ ASSERT_FALSE(web_form.isNull()); |
+ |
+ FormData form; |
+ EXPECT_TRUE(WebFormElementToFormData(web_form, WebFormControlElement(), |
+ nullptr, EXTRACT_NONE, &form, nullptr)); |
+ |
+ EXPECT_EQ(4U, form.fields.size()); |
+ EXPECT_EQ(ASCIIToUTF16("firstname"), form.fields[0].id); |
+ EXPECT_EQ(ASCIIToUTF16("lastname"), form.fields[1].id); |
+ EXPECT_TRUE(form.fields[2].id.empty()); |
sebsg
2017/01/18 19:22:49
Can you add a quick comment to explain why the id
kolos1
2017/01/19 11:09:16
Done.
|
+ EXPECT_TRUE(form.fields[3].id.empty()); |
+ EXPECT_EQ(base::string16(), form.fields[2].css_classes); |
+} |
+ |
TEST_F(FormAutofillTest, ExtractForms) { |
ExpectJohnSmithLabels( |
"<FORM name='TestForm' action='http://cnn.com' method='post'>" |