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

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

Issue 316853006: Autofill's "Clear Form" should clear only autofilled fields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test case Created 6 years, 6 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/content/renderer/form_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a92c51d4d8c62897ead44b33009472f72f058452..ad3feebd6b239f12cd00ab03764ce5e48e515058 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -3502,4 +3502,57 @@ TEST_F(FormAutofillTest, SelectOneAsText) {
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]);
}
+// Autofill's "Clear Form" should clear only autofilled fields
+TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) {
+ // Load the form.
+ LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">"
+ " <INPUT type=\"text\" id=\"firstname\" value=\"Wyatt\"/>"
+ " <INPUT type=\"text\" id=\"lastname\" value=\"Earp\"/>"
+ " <INPUT type=\"email\" id=\"email\" value=\"wyatt@earp.com\"/>"
+ " <INPUT type=\"tel\" id=\"phone\" value=\"650-777-9999\"/>"
+ " <INPUT type=\"submit\" value=\"Send\"/>"
+ "</FORM>");
+
+ WebFrame* web_frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame);
+
+ FormCache form_cache;
+ std::vector<FormData> forms;
+ form_cache.ExtractNewForms(*web_frame, &forms);
+ ASSERT_EQ(1U, forms.size());
+
+ // Set the autofilled attribute.
+ WebInputElement firstname =
+ web_frame->document().getElementById("firstname").to<WebInputElement>();
+ firstname.setAutofilled(false);
+ WebInputElement lastname =
+ web_frame->document().getElementById("lastname").to<WebInputElement>();
+ lastname.setAutofilled(true);
+ WebInputElement email =
+ web_frame->document().getElementById("email").to<WebInputElement>();
+ email.setAutofilled(true);
+ WebInputElement phone =
+ web_frame->document().getElementById("phone").to<WebInputElement>();
+ phone.setAutofilled(true);
+
+ // Clear the fields.
+ EXPECT_TRUE(form_cache.ClearFormWithElement(firstname));
+ EXPECT_TRUE(form_cache.ClearFormWithElement(lastname));
+ EXPECT_TRUE(form_cache.ClearFormWithElement(email));
+ EXPECT_TRUE(form_cache.ClearFormWithElement(phone));
Ilya Sherman 2014/06/13 20:55:29 Hmm, ClearFormWithElement clears the entire form,
Nikhil 2014/06/16 13:54:28 Done.
+
+ // Verify only autofilled fields are cleared.
+ EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.value());
+ EXPECT_TRUE(firstname.suggestedValue().isEmpty());
+ EXPECT_FALSE(firstname.isAutofilled());
+ EXPECT_TRUE(lastname.value().isEmpty());
+ EXPECT_TRUE(lastname.suggestedValue().isEmpty());
+ EXPECT_FALSE(lastname.isAutofilled());
+ EXPECT_TRUE(email.value().isEmpty());
+ EXPECT_TRUE(email.suggestedValue().isEmpty());
+ EXPECT_FALSE(email.isAutofilled());
+ EXPECT_TRUE(phone.value().isEmpty());
+ EXPECT_TRUE(phone.suggestedValue().isEmpty());
+ EXPECT_FALSE(phone.isAutofilled());
+}
Ilya Sherman 2014/06/13 20:55:29 Please move this so that it is adjacent to the oth
Nikhil 2014/06/16 13:54:28 Done.
} // namespace autofill
« no previous file with comments | « no previous file | components/autofill/content/renderer/form_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698