diff options
author | Evan Stade <estade@chromium.org> | 2015-02-27 11:53:59 -0800 |
---|---|---|
committer | Evan Stade <estade@chromium.org> | 2015-02-27 19:56:33 +0000 |
commit | 5882757c0112fe13c290a9fcdd656eab016c4d83 (patch) | |
tree | 597f7c95a8c2d5822b00d317d6641a3a8c12fe9b | |
parent | f31ba13a0523715de4fbd3bbf8d2e396edfd232f (diff) | |
download | chromium_src-5882757c0112fe13c290a9fcdd656eab016c4d83.zip chromium_src-5882757c0112fe13c290a9fcdd656eab016c4d83.tar.gz chromium_src-5882757c0112fe13c290a9fcdd656eab016c4d83.tar.bz2 |
Autofill: Disable autofill for fields outside of forms.
BUG=462375
Review URL: https://codereview.chromium.org/964453004
Cr-Commit-Position: refs/heads/master@{#318406}
(cherry picked from commit eb9e20d80c31c2842509e5213d4864eadf84baa1)
Review URL: https://codereview.chromium.org/958393003
Cr-Commit-Position: refs/branch-heads/2272@{#388}
Cr-Branched-From: 827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4-refs/heads/master@{#310958}
5 files changed, 33 insertions, 63 deletions
diff --git a/chrome/browser/autofill/form_structure_browsertest.cc b/chrome/browser/autofill/form_structure_browsertest.cc index 9179f5b..0c59491 100644 --- a/chrome/browser/autofill/form_structure_browsertest.cc +++ b/chrome/browser/autofill/form_structure_browsertest.cc @@ -45,6 +45,16 @@ const base::FilePath& GetTestDataDir() { } const std::vector<base::FilePath> GetTestFiles() { + static const base::FilePath::CharType* const kFilesToSkip[] = { + FILE_PATH_LITERAL("bug_459132.html"), + FILE_PATH_LITERAL("bug_454366b.html"), + FILE_PATH_LITERAL("bug_454366.html"), + FILE_PATH_LITERAL("25_checkout_m_llbean.com.html"), + }; + std::set<base::FilePath> set_of_files_to_skip; + for (size_t i = 0; i < arraysize(kFilesToSkip); ++i) + set_of_files_to_skip.insert(base::FilePath(kFilesToSkip[i])); + base::FilePath dir; CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &dir)); dir = dir.AppendASCII("chrome/test/data/autofill") @@ -54,7 +64,8 @@ const std::vector<base::FilePath> GetTestFiles() { std::vector<base::FilePath> files; for (base::FilePath input_file = input_files.Next(); !input_file.empty(); input_file = input_files.Next()) { - files.push_back(input_file); + if (!ContainsKey(set_of_files_to_skip, input_file.BaseName())) + files.push_back(input_file); } #if defined(OS_MACOSX) diff --git a/chrome/renderer/autofill/autofill_renderer_browsertest.cc b/chrome/renderer/autofill/autofill_renderer_browsertest.cc index 49a8366..26840bb 100644 --- a/chrome/renderer/autofill/autofill_renderer_browsertest.cc +++ b/chrome/renderer/autofill/autofill_renderer_browsertest.cc @@ -250,7 +250,7 @@ TEST_F(AutofillRendererTest, DontCrashWhileAssociatingForms) { // Shouldn't crash. } -TEST_F(AutofillRendererTest, DynamicallyAddedUnownedFormElements) { +TEST_F(AutofillRendererTest, DISABLED_DynamicallyAddedUnownedFormElements) { std::string html_data; base::FilePath test_path = ui_test_utils::GetTestFilePath( base::FilePath(FILE_PATH_LITERAL("autofill")), diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc index 24b5f05..a447229 100644 --- a/chrome/renderer/autofill/form_autofill_browsertest.cc +++ b/chrome/renderer/autofill/form_autofill_browsertest.cc @@ -2393,7 +2393,7 @@ TEST_F(FormAutofillTest, FindFormForInputElement) { false); } -TEST_F(FormAutofillTest, FindFormForInputElementForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FindFormForInputElementForUnownedForm) { TestFindFormForInputElement( "<INPUT type='text' id='firstname' value='John'/>" "<INPUT type='text' id='lastname' value='Smith'/>" @@ -2420,7 +2420,7 @@ TEST_F(FormAutofillTest, FindFormForTextAreaElement) { false); } -TEST_F(FormAutofillTest, FindFormForTextAreaElementForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FindFormForTextAreaElementForUnownedForm) { TestFindFormForTextAreaElement( "<INPUT type='text' id='firstname' value='John'/>" "<INPUT type='text' id='lastname' value='Smith'/>" @@ -2439,7 +2439,7 @@ TEST_F(FormAutofillTest, FillForm) { TestFillForm(kFormHtml, false); } -TEST_F(FormAutofillTest, FillFormForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FillFormForUnownedForm) { TestFillForm(kUnownedFormHtml, true); } @@ -2531,7 +2531,7 @@ TEST_F(FormAutofillTest, PreviewForm) { TestPreviewForm(kFormHtml, false); } -TEST_F(FormAutofillTest, PreviewFormForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_PreviewFormForUnownedForm) { TestPreviewForm(kUnownedFormHtml, true); } @@ -3406,7 +3406,7 @@ TEST_F(FormAutofillTest, FillFormMaxLength) { false); } -TEST_F(FormAutofillTest, FillFormMaxLengthForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FillFormMaxLengthForUnownedForm) { TestFillFormMaxLength( "<INPUT type='text' id='firstname' maxlength='5'/>" "<INPUT type='text' id='lastname' maxlength='7'/>" @@ -3429,7 +3429,7 @@ TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { false); } -TEST_F(FormAutofillTest, FillFormNegativeMaxLengthForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FillFormNegativeMaxLengthForUnownedForm) { TestFillFormNegativeMaxLength( "<INPUT type='text' id='firstname' maxlength='-1'/>" "<INPUT type='text' id='lastname' maxlength='-10'/>" @@ -3449,7 +3449,7 @@ TEST_F(FormAutofillTest, FillFormEmptyName) { false); } -TEST_F(FormAutofillTest, FillFormEmptyNameForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FillFormEmptyNameForUnownedForm) { TestFillFormEmptyName( "<INPUT type='text' id='firstname'/>" "<INPUT type='text' id='lastname'/>" @@ -3475,7 +3475,7 @@ TEST_F(FormAutofillTest, FillFormEmptyFormNames) { false); } -TEST_F(FormAutofillTest, FillFormEmptyFormNamesForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FillFormEmptyFormNamesForUnownedForm) { TestFillFormEmptyFormNames( "<INPUT type='text' id='firstname'/>" "<INPUT type='text' id='middlename'/>" @@ -3631,7 +3631,7 @@ TEST_F(FormAutofillTest, FillFormNonEmptyField) { false); } -TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_FillFormNonEmptyFieldForUnownedForm) { TestFillFormNonEmptyField("<INPUT type='text' id='firstname'/>" "<INPUT type='text' id='lastname'/>" "<INPUT type='text' id='email'/>" @@ -3659,7 +3659,7 @@ TEST_F(FormAutofillTest, ClearFormWithNode) { false); } -TEST_F(FormAutofillTest, ClearFormWithNodeForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_ClearFormWithNodeForUnownedForm) { TestClearFormWithNode( " <!-- Indented on purpose //-->" " <INPUT type='text' id='firstname' value='Wyatt'/>" @@ -3694,7 +3694,8 @@ TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) { false); } -TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOneForUnownedForm) { +TEST_F(FormAutofillTest, + DISABLED_ClearFormWithNodeContainingSelectOneForUnownedForm) { TestClearFormWithNodeContainingSelectOne( "<INPUT type='text' id='firstname' value='Wyatt'/>" "<INPUT type='text' id='lastname' value='Earp'/>" @@ -3720,7 +3721,7 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) { "</FORM>"); } -TEST_F(FormAutofillTest, ClearPreviewedFormWithElementForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_ClearPreviewedFormWithElementForUnownedForm) { TestClearPreviewedFormWithElement( "<INPUT type='text' id='firstname' value='Wyatt'/>" "<INPUT type='text' id='lastname'/>" @@ -3743,7 +3744,7 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { } TEST_F(FormAutofillTest, - ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { + DISABLED_ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { TestClearPreviewedFormWithNonEmptyInitiatingNode( "<INPUT type='text' id='firstname' value='W'/>" "<INPUT type='text' id='lastname'/>" @@ -3766,7 +3767,7 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { } TEST_F(FormAutofillTest, - ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { + DISABLED_ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { TestClearPreviewedFormWithAutofilledInitiatingNode( "<INPUT type='text' id='firstname' value='W'/>" "<INPUT type='text' id='lastname'/>" @@ -3788,7 +3789,7 @@ TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) { "</FORM>"); } -TEST_F(FormAutofillTest, ClearOnlyAutofilledFieldsForUnownedForm) { +TEST_F(FormAutofillTest, DISABLED_ClearOnlyAutofilledFieldsForUnownedForm) { TestClearOnlyAutofilledFields( "<INPUT type='text' id='firstname' value='Wyatt'/>" "<INPUT type='text' id='lastname' value='Earp'/>" @@ -3947,7 +3948,7 @@ TEST_F(FormAutofillTest, SelectOneAsText) { } TEST_F(FormAutofillTest, - UnownedFormElementsAndFieldSetsToFormDataFieldsets) { + DISABLED_UnownedFormElementsAndFieldSetsToFormDataFieldsets) { std::vector<WebElement> fieldsets; std::vector<WebFormControlElement> control_elements; @@ -4009,7 +4010,7 @@ TEST_F(FormAutofillTest, } TEST_F(FormAutofillTest, - UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldset) { + DISABLED_UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldset) { std::vector<WebElement> fieldsets; std::vector<WebFormControlElement> control_elements; @@ -4068,7 +4069,8 @@ TEST_F(FormAutofillTest, EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); } -TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) { +TEST_F(FormAutofillTest, + DISABLED_UnownedFormElementsAndFieldSetsToFormDataWithForm) { std::vector<WebElement> fieldsets; std::vector<WebFormControlElement> control_elements; diff --git a/components/autofill/content/renderer/form_cache.cc b/components/autofill/content/renderer/form_cache.cc index 9bc97e2..3f27c39 100644 --- a/components/autofill/content/renderer/form_cache.cc +++ b/components/autofill/content/renderer/form_cache.cc @@ -119,41 +119,10 @@ std::vector<FormData> FormCache::ExtractNewForms() { parsed_forms_.insert(form); } } - - // Look for more parseable fields outside of forms. - std::vector<WebElement> fieldsets; - std::vector<WebFormControlElement> control_elements = - GetUnownedAutofillableFormFieldElements(document.all(), &fieldsets); - - size_t num_editable_elements = - ScanFormControlElements(control_elements, log_deprecation_messages); - - if (ShouldIgnoreForm(num_editable_elements, control_elements.size())) - return forms; - - FormData synthetic_form; - if (!UnownedFormElementsAndFieldSetsToFormData(fieldsets, control_elements, - nullptr, document.url(), - REQUIRE_NONE, extract_mask, - &synthetic_form, nullptr)) { - return forms; - } - - num_fields_seen += synthetic_form.fields.size(); - if (num_fields_seen > kMaxParseableFields) - return forms; - - if (synthetic_form.fields.size() >= kRequiredAutofillFields && - !parsed_forms_.count(synthetic_form)) { - forms.push_back(synthetic_form); - parsed_forms_.insert(synthetic_form); - synthetic_form_ = synthetic_form; - } return forms; } void FormCache::Reset() { - synthetic_form_ = FormData(); parsed_forms_.clear(); initial_select_values_.clear(); initial_checked_state_.clear(); @@ -222,15 +191,7 @@ bool FormCache::ShowPredictions(const FormDataPredictions& form) { std::vector<WebFormControlElement> control_elements; - // First check the synthetic form. bool found_synthetic_form = false; - if (form.data.SameFormAs(synthetic_form_)) { - found_synthetic_form = true; - WebDocument document = frame_.document(); - control_elements = - GetUnownedAutofillableFormFieldElements(document.all(), nullptr); - } - if (!found_synthetic_form) { // Find the real form by searching through the WebDocuments. bool found_form = false; diff --git a/components/autofill/content/renderer/form_cache.h b/components/autofill/content/renderer/form_cache.h index d0c29cd..f37a981 100644 --- a/components/autofill/content/renderer/form_cache.h +++ b/components/autofill/content/renderer/form_cache.h @@ -64,10 +64,6 @@ class FormCache { // The cached forms. Used to prevent re-extraction of forms. std::set<FormData> parsed_forms_; - // The synthetic FormData is for all the fieldsets in the document without a - // form owner. - FormData synthetic_form_; - // The cached initial values for <select> elements. std::map<const blink::WebSelectElement, base::string16> initial_select_values_; |