| 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
|
|
|