diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 07:55:02 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 07:55:02 +0000 |
commit | 0dcec9596dc2b9d8ec8c42254a65bc16126ed9fb (patch) | |
tree | 625ac93fa4b48c77aa9d73175616ec8764d79d89 /chrome | |
parent | da34fd0b43514c9131082744b46a11c12865f9b7 (diff) | |
download | chromium_src-0dcec9596dc2b9d8ec8c42254a65bc16126ed9fb.zip chromium_src-0dcec9596dc2b9d8ec8c42254a65bc16126ed9fb.tar.gz chromium_src-0dcec9596dc2b9d8ec8c42254a65bc16126ed9fb.tar.bz2 |
Don't autofill fields styled to be non-user visible.
Depends on https://bugs.webkit.org/show_bug.cgi?id=56809
BUG=72918
TEST=browser_tests --gtest_filter=FormManagerTest.FillForm
Review URL: http://codereview.chromium.org/6675024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79375 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/autofill/autofill_agent.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_manager.cc | 3 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_manager_browsertest.cc | 37 |
3 files changed, 37 insertions, 5 deletions
diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc index ad3615e..50e6663 100644 --- a/chrome/renderer/autofill/autofill_agent.cc +++ b/chrome/renderer/autofill/autofill_agent.cc @@ -262,7 +262,7 @@ void AutofillAgent::OnSuggestionsReturned(int query_id, // Send to WebKit for display. if (!v.empty() && !autofill_query_node_.isNull() && - autofill_query_node_.hasNonEmptyBoundingBox()) { + autofill_query_node_.isFocusable()) { web_view->applyAutoFillSuggestions( autofill_query_node_, v, l, i, ids, separator_index); } diff --git a/chrome/renderer/autofill/form_manager.cc b/chrome/renderer/autofill/form_manager.cc index 2f90780..1a47fe1 100644 --- a/chrome/renderer/autofill/form_manager.cc +++ b/chrome/renderer/autofill/form_manager.cc @@ -855,7 +855,8 @@ void FormManager::ForEachMatchingFormField(FormElement* form, continue; } - if (!element->isEnabled() || element->isReadOnly()) + if (!element->isEnabled() || element->isReadOnly() || + !element->isFocusable()) continue; callback->Run(element, &data.fields[k], is_initiating_node); diff --git a/chrome/renderer/autofill/form_manager_browsertest.cc b/chrome/renderer/autofill/form_manager_browsertest.cc index 7442033..db18d000 100644 --- a/chrome/renderer/autofill/form_manager_browsertest.cc +++ b/chrome/renderer/autofill/form_manager_browsertest.cc @@ -729,6 +729,9 @@ TEST_F(FormManagerTest, FillForm) { " <INPUT type=\"text\" autocomplete=\"off\" id=\"noautocomplete\"/>" " <INPUT type=\"text\" disabled=\"disabled\" id=\"notenabled\"/>" " <INPUT type=\"text\" readonly id=\"readonly\"/>" + " <INPUT type=\"text\" style=\"visibility: hidden\"" + " id=\"invisible\"/>" + " <INPUT type=\"text\" style=\"display: none\" id=\"displaynone\"/>" " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" "</FORM>"); @@ -756,7 +759,7 @@ TEST_F(FormManagerTest, FillForm) { EXPECT_EQ(GURL("http://buh.com"), form.action); const std::vector<FormField>& fields = form.fields; - ASSERT_EQ(6U, fields.size()); + ASSERT_EQ(8U, fields.size()); EXPECT_EQ(FormField(string16(), ASCIIToUTF16("firstname"), string16(), @@ -798,7 +801,21 @@ TEST_F(FormManagerTest, FillForm) { ASCIIToUTF16("text"), WebInputElement::defaultMaxLength(), false), - fields[5]); + fields[5]); + EXPECT_EQ(FormField(string16(), + ASCIIToUTF16("invisible"), + string16(), + ASCIIToUTF16("text"), + WebInputElement::defaultMaxLength(), + false), + fields[6]); + EXPECT_EQ(FormField(string16(), + ASCIIToUTF16("displaynone"), + string16(), + ASCIIToUTF16("text"), + WebInputElement::defaultMaxLength(), + false), + fields[7]); // Fill the form. form.fields[0].value = ASCIIToUTF16("Wyatt"); @@ -807,6 +824,8 @@ TEST_F(FormManagerTest, FillForm) { form.fields[3].value = ASCIIToUTF16("Beta"); form.fields[4].value = ASCIIToUTF16("Gamma"); form.fields[5].value = ASCIIToUTF16("Delta"); + form.fields[6].value = ASCIIToUTF16("Epsilon"); + form.fields[7].value = ASCIIToUTF16("Zeta"); EXPECT_TRUE(form_manager.FillForm(form, input_element)); // Verify the filled elements. @@ -843,9 +862,21 @@ TEST_F(FormManagerTest, FillForm) { // Read-only fields are not filled. WebInputElement readonly = - document.getElementById("readonly").to<WebInputElement>(); + document.getElementById("readonly").to<WebInputElement>(); EXPECT_FALSE(readonly.isAutofilled()); EXPECT_TRUE(readonly.value().isEmpty()); + + // |visibility:hidden| fields are not filled. + WebInputElement invisible = + document.getElementById("invisible").to<WebInputElement>(); + EXPECT_FALSE(invisible.isAutofilled()); + EXPECT_TRUE(invisible.value().isEmpty()); + + // |display:none| fields are not filled. + WebInputElement display_none = + document.getElementById("displaynone").to<WebInputElement>(); + EXPECT_FALSE(display_none.isAutofilled()); + EXPECT_TRUE(display_none.value().isEmpty()); } TEST_F(FormManagerTest, PreviewForm) { |