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

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: Addressed comments 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 227e24493d734192b91ea09ece58aba7532a0dc9..27f58e2e242ef90c927d2160e4972d1ca8ca6ca6 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -4129,5 +4129,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

Powered by Google App Engine
This is Rietveld 408576698