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

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

Issue 1411363003: [Autofill] Always show available data when encountering autocomplete attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed bug Created 5 years, 1 month 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 dc2f1d104b3a800f81285306983cc746b57e8770..76873331b0c1b96fc9e7839f30b022b84ea648c1 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -4128,5 +4128,48 @@ TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) {
&form, nullptr));
}
+TEST_F(FormAutofillTest, FormCache_ExtractNewForms) {
+ struct {
+ const char* html;
+ const size_t expected_forms;
+ } test_cases[] = {
+ // An empty form should not be extracted
+ {"<FORM name='TestForm' action='http://buh.com' method='post'>"
+ "</FORM>",
+ 0},
+ // A form with less than three fields with no autocomplete type(s) should
+ // not be extracted.
+ {"<FORM name='TestForm' action='http://buh.com' method='post'>"
+ " <INPUT type='name' id='firstname'/>"
+ "</FORM>",
+ 0},
+ // A form with less than three fields with at least one autocomplete type
+ // should be extracted.
+ {"<FORM name='TestForm' action='http://buh.com' method='post'>"
+ " <INPUT type='name' id='firstname' autocomplete='given-name'/>"
+ "</FORM>",
+ 1},
+ // A form with three or more fields should be extracted.
+ {"<FORM name='TestForm' action='http://buh.com' method='post'>"
+ " <INPUT type='text' id='firstname'/>"
+ " <INPUT type='text' id='lastname'/>"
+ " <INPUT type='text' id='email'/>"
+ " <INPUT type='submit' value='Send'/>"
+ "</FORM>",
+ 1},
+ };
+
+ for (auto test_case : test_cases) {
+ LoadHTML(test_case.html);
+
+ WebFrame* web_frame = GetMainFrame();
+ ASSERT_NE(nullptr, web_frame);
+
+ FormCache form_cache(*web_frame);
+ std::vector<FormData> forms = form_cache.ExtractNewForms();
+ EXPECT_EQ(test_case.expected_forms, forms.size());
+ }
+}
+
} // namespace form_util
} // namespace autofill
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | components/autofill/content/renderer/form_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698