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 76dba7bbba239d7e59bdb14762e704dc99a63a55..7dda2788f7e242d280f18ffdbfab4f0bb5567832 100644 |
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc |
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc |
@@ -1019,7 +1019,7 @@ class FormAutofillTest : public ChromeRenderViewTest { |
lastname.setAutofilled(true); |
WebInputElement month = GetInputElementById("month"); |
month.setAutofilled(true); |
- WebInputElement textarea = GetInputElementById("textarea"); |
+ WebFormControlElement textarea = GetFormControlElementById("textarea"); |
textarea.setAutofilled(true); |
// Set the value of the disabled text input element. |
@@ -2003,6 +2003,30 @@ TEST_F(FormAutofillTest, WebFormElementToFormData) { |
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[5]); |
} |
+TEST_F(FormAutofillTest, WebFormElementConsiderNonControlLabelableElements) { |
+ LoadHTML("<form id=form>" |
+ " <label for='progress'>Progress:</label>" |
+ " <progress id='progress'></progress>" |
+ " <label for='firstname'>First name:</label>" |
+ " <input type='text' id='firstname' value='John'>" |
+ "</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(), |
+ EXTRACT_NONE, &form, nullptr)); |
+ |
+ const std::vector<FormFieldData>& fields = form.fields; |
+ ASSERT_EQ(1U, fields.size()); |
+ EXPECT_EQ(ASCIIToUTF16("firstname"), fields[0].name); |
+} |
+ |
// We should not be able to serialize a form with too many fillable fields. |
TEST_F(FormAutofillTest, WebFormElementToFormDataTooManyFields) { |
std::string html = |