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

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

Issue 11415221: Add support for autofilling radio buttons and checkboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix the nit. Created 8 years 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 93d572b0640ccf2bdf103c08c30f94d2ea9e7ca6..cc0f341a380910b96ac0c375ce2d9baba91ac100 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -212,6 +212,41 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutofilled) {
EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
}
+// We should be able to extract a radio or a checkbox field that has been
+// autofilled.
+TEST_F(FormAutofillTest, WebFormControlElementToClickableFormField) {
+ LoadHTML("<INPUT type=\"checkbox\" id=\"checkbox\" value=\"mail\"/>"
+ "<INPUT type=\"radio\" id=\"radio\" value=\"male\"/>");
+
+ WebFrame* frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ WebElement web_element = frame->document().getElementById("checkbox");
+ WebInputElement element = web_element.to<WebInputElement>();
+ element.setAutofilled(true);
+ FormFieldData result;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);
+
+ FormFieldData expected;
+ expected.name = ASCIIToUTF16("checkbox");
+ expected.value = ASCIIToUTF16("mail");
+ expected.form_control_type = "checkbox";
+ expected.is_autofilled = true;
+ expected.is_checkable = true;
+ EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
+
+ web_element = frame->document().getElementById("radio");
+ element = web_element.to<WebInputElement>();
+ element.setAutofilled(true);
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);
+ expected.name = ASCIIToUTF16("radio");
+ expected.value = ASCIIToUTF16("male");
+ expected.form_control_type = "radio";
+ expected.is_autofilled = true;
+ expected.is_checkable = true;
+ EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
+}
+
// We should be able to extract a <select> field.
TEST_F(FormAutofillTest, WebFormControlElementToFormFieldSelect) {
LoadHTML("<SELECT id=\"element\"/>"
@@ -263,8 +298,6 @@ 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=\"checkbox\" id=\"checkbox\" value=\"mail\"/>"
- " <INPUT type=\"radio\" id=\"radio\" value=\"male\"/>"
" <INPUT type=\"submit\" id=\"submit\" value=\"Send\"/>"
"</FORM>");
@@ -290,21 +323,6 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldInvalidType) {
expected.form_control_type = "password";
EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
- web_element = frame->document().getElementById("checkbox");
- element = web_element.to<WebFormControlElement>();
- WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);
- expected.name = ASCIIToUTF16("checkbox");
- expected.form_control_type = "checkbox";
- EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
-
- web_element = frame->document().getElementById("radio");
- element = web_element.to<WebFormControlElement>();
- WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);
- expected.name = ASCIIToUTF16("radio");
- expected.form_control_type = "radio";
- EXPECT_FORM_FIELD_DATA_EQUALS(expected, result);
-
-
web_element = frame->document().getElementById("submit");
element = web_element.to<WebFormControlElement>();
WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result);

Powered by Google App Engine
This is Rietveld 408576698