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

Unified Diff: chrome/renderer/autofill/form_autocomplete_browsertest.cc

Issue 407083002: [Autofill] Include fields with autocomplete="off" in server upload requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update test expectations Created 6 years, 5 months 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | components/autofill/content/renderer/autofill_agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/form_autocomplete_browsertest.cc
diff --git a/chrome/renderer/autofill/form_autocomplete_browsertest.cc b/chrome/renderer/autofill/form_autocomplete_browsertest.cc
index 44a146a571c116731a1c70458b6f2a2bee6874fc..5f49d9d868e3967b07d60bd6aa6c89a4d1368997 100644
--- a/chrome/renderer/autofill/form_autocomplete_browsertest.cc
+++ b/chrome/renderer/autofill/form_autocomplete_browsertest.cc
@@ -49,7 +49,7 @@ TEST_F(FormAutocompleteTest, NormalFormSubmit) {
EXPECT_EQ(WebString("Deckard"), form_field.value);
}
-// Tests that submitting a form that has autocomplete="off" does not generate a
+// Tests that submitting a form that has autocomplete="off" generates a
// FormSubmitted message.
TEST_F(FormAutocompleteTest, AutoCompleteOffFormSubmit) {
// Load a form.
@@ -62,12 +62,25 @@ TEST_F(FormAutocompleteTest, AutoCompleteOffFormSubmit) {
ExecuteJavaScript("document.getElementById('myForm').submit();");
ProcessPendingMessages();
- // No FormSubmitted message should have been sent.
- EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
- AutofillHostMsg_FormSubmitted::ID));
+ const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
+ AutofillHostMsg_FormSubmitted::ID);
+ ASSERT_TRUE(message != NULL);
+
+ // The tuple also includes a timestamp, which is ignored.
+ Tuple2<FormData, base::TimeTicks> forms;
+ AutofillHostMsg_FormSubmitted::Read(message, &forms);
+ ASSERT_EQ(2U, forms.a.fields.size());
+
+ FormFieldData& form_field = forms.a.fields[0];
+ EXPECT_EQ(WebString("fname"), form_field.name);
+ EXPECT_EQ(WebString("Rick"), form_field.value);
+
+ form_field = forms.a.fields[1];
+ EXPECT_EQ(WebString("lname"), form_field.name);
+ EXPECT_EQ(WebString("Deckard"), form_field.value);
}
-// Tests that fields with autocomplete off are not submitted.
+// Tests that fields with autocomplete off are submitted.
TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) {
// Load a form.
LoadHTML("<html><form id='myForm'>"
@@ -79,7 +92,6 @@ TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) {
ExecuteJavaScript("document.getElementById('myForm').submit();");
ProcessPendingMessages();
- // No FormSubmitted message should have been sent.
const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_FormSubmitted::ID);
ASSERT_TRUE(message != NULL);
@@ -87,16 +99,20 @@ TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) {
// The tuple also includes a timestamp, which is ignored.
Tuple2<FormData, base::TimeTicks> forms;
AutofillHostMsg_FormSubmitted::Read(message, &forms);
- ASSERT_EQ(1U, forms.a.fields.size());
+ ASSERT_EQ(2U, forms.a.fields.size());
FormFieldData& form_field = forms.a.fields[0];
EXPECT_EQ(WebString("fname"), form_field.name);
EXPECT_EQ(WebString("Rick"), form_field.value);
+
+ form_field = forms.a.fields[1];
+ EXPECT_EQ(WebString("lname"), form_field.name);
+ EXPECT_EQ(WebString("Deckard"), form_field.value);
}
// Tests that submitting a form that has been dynamically set as autocomplete
-// off does not generate a FormSubmitted message.
-// http://crbug.com/36520
+// off generates a FormSubmitted message.
+// Note: We previously did the opposite, for bug http://crbug.com/36520
TEST_F(FormAutocompleteTest, DynamicAutoCompleteOffFormSubmit) {
Evan Stade 2014/07/23 23:14:50 I question whether this test has any value any mor
LoadHTML("<html><form id='myForm'><input name='fname' value='Rick'/>"
"<input name='lname' value='Deckard'/></form></html>");
@@ -117,9 +133,22 @@ TEST_F(FormAutocompleteTest, DynamicAutoCompleteOffFormSubmit) {
ExecuteJavaScript("document.getElementById('myForm').submit();");
ProcessPendingMessages();
- // No FormSubmitted message should have been sent.
- EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
- AutofillHostMsg_FormSubmitted::ID));
+ const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
+ AutofillHostMsg_FormSubmitted::ID);
+ ASSERT_TRUE(message != NULL);
+
+ // The tuple also includes a timestamp, which is ignored.
+ Tuple2<FormData, base::TimeTicks> forms;
+ AutofillHostMsg_FormSubmitted::Read(message, &forms);
+ ASSERT_EQ(2U, forms.a.fields.size());
+
+ FormFieldData& form_field = forms.a.fields[0];
+ EXPECT_EQ(WebString("fname"), form_field.name);
+ EXPECT_EQ(WebString("Rick"), form_field.value);
+
+ form_field = forms.a.fields[1];
+ EXPECT_EQ(WebString("lname"), form_field.name);
+ EXPECT_EQ(WebString("Deckard"), form_field.value);
}
} // namespace autofill
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | components/autofill/content/renderer/autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698