summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-25 19:28:06 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-25 19:28:06 +0000
commit573c1c27417914a7f212bb502c479d1cf315b6d3 (patch)
tree1eebe88cc2ac16cc6cc405bd869dc7156cba67b7 /chrome/renderer
parent8a1f331497a81bb929ab75a3cfc8b1b835e21bcd (diff)
downloadchromium_src-573c1c27417914a7f212bb502c479d1cf315b6d3.zip
chromium_src-573c1c27417914a7f212bb502c479d1cf315b6d3.tar.gz
chromium_src-573c1c27417914a7f212bb502c479d1cf315b6d3.tar.bz2
AutoFill sending forms should include elements with autoComplete="off" attributes.
On these pages we were hitting the DCHECK_EQ in autofill_manager.cc:237 when filling these forms. This was due to the lack of <input> elements with autoComplete="off" attributes set when originally sending the form data with the RenderView::SendForms() call. This changes the renderer to add these elements when originally sent and processed by the AutoFillManager::FormsSeen() call. BUG=40700, 41702 TEST=Manual tests of pages in bug reports. Review URL: http://codereview.chromium.org/2135012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48174 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc6
-rw-r--r--chrome/renderer/render_view_unittest.cc93
2 files changed, 94 insertions, 5 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index e9bd104..ac7d9b5 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -4722,12 +4722,8 @@ void RenderView::SendForms(WebFrame* frame) {
const WebFormElement& web_form = web_forms[i];
FormData form;
- FormManager::RequirementsMask requirements =
- static_cast<FormManager::RequirementsMask>(
- FormManager::REQUIRE_AUTOCOMPLETE |
- FormManager::REQUIRE_ELEMENTS_ENABLED);
if (FormManager::WebFormElementToFormData(
- web_form, requirements, false, &form))
+ web_form, FormManager::REQUIRE_NONE, false, &form))
forms.push_back(form);
}
diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc
index 4420f70..92521e4 100644
--- a/chrome/renderer/render_view_unittest.cc
+++ b/chrome/renderer/render_view_unittest.cc
@@ -17,14 +17,22 @@
#include "printing/image.h"
#include "printing/native_metafile.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h"
+#include "webkit/glue/form_data.h"
+#include "webkit/glue/form_field.h"
using WebKit::WebCompositionCommand;
+using WebKit::WebDocument;
using WebKit::WebFrame;
+using WebKit::WebInputElement;
using WebKit::WebString;
using WebKit::WebTextDirection;
using WebKit::WebURLError;
+using webkit_glue::FormData;
+using webkit_glue::FormField;
static WebCompositionCommand ToCompositionCommand(int string_type) {
switch (string_type) {
@@ -937,3 +945,88 @@ TEST_F(RenderViewTest, UpdateTargetURLWithInvalidURL) {
view_->setMouseOverURL(WebKit::WebURL(invalid_gurl));
EXPECT_EQ(invalid_gurl, view_->target_url_);
}
+
+TEST_F(RenderViewTest, SendForms) {
+ // Don't want any delay for form state sync changes. This will still post a
+ // message so updates will get coalesced, but as soon as we spin the message
+ // loop, it will generate an update.
+ view_->set_send_content_state_immediately(true);
+
+ LoadHTML("\
+ <html>\
+ <body>\
+ <form method=\"POST\">\
+ <input type=\"text\" id=\"firstname\" name=\"First Name\"/>\
+ <input type=\"text\" name=\"Middle Name\" autoComplete=\"off\"/>\
+ <input type=\"hidden\" name=\"Last Name\"/>\
+ </form>\
+ </body>\
+ </html>\
+ ");
+
+ // Verify that "FormsSeen" sends the expected number of fields.
+ ProcessPendingMessages();
+ const IPC::Message* message = render_thread_.sink().GetUniqueMessageMatching(
+ ViewHostMsg_FormsSeen::ID);
+ ASSERT_NE(static_cast<IPC::Message*>(NULL), message);
+ ViewHostMsg_FormsSeen::Param params;
+ ViewHostMsg_FormsSeen::Read(message, &params);
+ const std::vector<FormData>& forms = params.a;
+ ASSERT_EQ(1UL, forms.size());
+ ASSERT_EQ(3UL, forms[0].fields.size());
+ EXPECT_TRUE(forms[0].fields[0].StrictlyEqualsHack(
+ FormField(string16(),
+ ASCIIToUTF16("First Name"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 20))) << forms[0].fields[0];
+ EXPECT_TRUE(forms[0].fields[1].StrictlyEqualsHack(
+ FormField(string16(),
+ ASCIIToUTF16("Middle Name"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 20))) << forms[0].fields[1];
+ EXPECT_TRUE(forms[0].fields[2].StrictlyEqualsHack(
+ FormField(string16(),
+ ASCIIToUTF16("Last Name"),
+ string16(),
+ ASCIIToUTF16("hidden"),
+ 0))) << forms[0].fields[2];
+
+ // Verify that |didAcceptAutoFillSuggestion()| sends the expected number of
+ // fields.
+ WebFrame* web_frame = GetMainFrame();
+ WebDocument document = web_frame->document();
+ WebInputElement firstname =
+ document.getElementById("firstname").to<WebInputElement>();
+ view_->didAcceptAutoFillSuggestion(firstname,
+ WebKit::WebString(),
+ WebKit::WebString());
+
+ ProcessPendingMessages();
+ const IPC::Message* message2 = render_thread_.sink().GetUniqueMessageMatching(
+ ViewHostMsg_FillAutoFillFormData::ID);
+ ASSERT_NE(static_cast<IPC::Message*>(NULL), message2);
+ ViewHostMsg_FillAutoFillFormData::Param params2;
+ ViewHostMsg_FillAutoFillFormData::Read(message2, &params2);
+ const FormData& form2 = params2.b;
+ ASSERT_EQ(3UL, form2.fields.size());
+ EXPECT_TRUE(form2.fields[0].StrictlyEqualsHack(
+ FormField(string16(),
+ ASCIIToUTF16("First Name"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 20))) << form2.fields[0];
+ EXPECT_TRUE(form2.fields[1].StrictlyEqualsHack(
+ FormField(string16(),
+ ASCIIToUTF16("Middle Name"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 20))) << form2.fields[1];
+ EXPECT_TRUE(form2.fields[2].StrictlyEqualsHack(
+ FormField(string16(),
+ ASCIIToUTF16("Last Name"),
+ string16(),
+ ASCIIToUTF16("hidden"),
+ 0))) << form2.fields[2];
+}