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

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

Issue 1699993002: [Autofill] Fill fields if they contain a default value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | components/autofill/content/renderer/form_autofill_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6fc2d445e45a452847f17031cd760ede043fd74a..4a0b24c90e1875364c57452056ee344cb4e7629d 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -1057,7 +1057,10 @@ class FormAutofillTest : public ChromeRenderViewTest {
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[unowned_offset + 2]);
}
- void TestFillFormNonEmptyField(const char* html, bool unowned) {
+ void TestFillFormNonEmptyField(const char* html,
+ bool unowned,
+ const char* initial_lastname,
+ const char* initial_email) {
LoadHTML(html);
WebFrame* web_frame = GetMainFrame();
ASSERT_NE(nullptr, web_frame);
@@ -1097,12 +1100,24 @@ class FormAutofillTest : public ChromeRenderViewTest {
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]);
expected.name = ASCIIToUTF16("lastname");
- expected.value.clear();
+ if (initial_lastname) {
+ expected.label = ASCIIToUTF16(initial_lastname);
+ expected.value = ASCIIToUTF16(initial_lastname);
+ } else {
+ expected.label.clear();
+ expected.value.clear();
+ }
expected.is_autofilled = false;
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]);
expected.name = ASCIIToUTF16("email");
- expected.value.clear();
+ if (initial_email) {
+ expected.label = ASCIIToUTF16(initial_email);
+ expected.value = ASCIIToUTF16(initial_email);
+ } else {
+ expected.label.clear();
+ expected.value.clear();
+ }
expected.is_autofilled = false;
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]);
@@ -1137,16 +1152,19 @@ class FormAutofillTest : public ChromeRenderViewTest {
expected.name = ASCIIToUTF16("firstname");
expected.value = ASCIIToUTF16("Wyatt");
+ expected.label.clear();
expected.is_autofilled = true;
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]);
expected.name = ASCIIToUTF16("lastname");
expected.value = ASCIIToUTF16("Earp");
+ expected.label.clear();
expected.is_autofilled = true;
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]);
expected.name = ASCIIToUTF16("email");
expected.value = ASCIIToUTF16("wyatt@example.com");
+ expected.label.clear();
expected.is_autofilled = true;
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]);
@@ -3959,7 +3977,18 @@ TEST_F(FormAutofillTest, FillFormNonEmptyField) {
" <INPUT type='text' id='email'/>"
" <INPUT type='submit' value='Send'/>"
"</FORM>",
- false);
+ false, nullptr, nullptr);
+}
+
+TEST_F(FormAutofillTest, FillFormNonEmptyFieldsWithDefaultValues) {
+ TestFillFormNonEmptyField(
+ "<FORM name='TestForm' action='http://buh.com' method='post'>"
vabr (Chromium) 2016/02/16 18:12:32 Bösen & Heinke? :)
Mathieu 2016/02/16 20:03:45 wasn't sure if that was a serious comment, so I ch
vabr (Chromium) 2016/02/17 09:21:38 I was merely curious, what made you chose Bösen &
+ " <INPUT type='text' id='firstname' value='Enter first name'/>"
+ " <INPUT type='text' id='lastname' value='Enter last name'/>"
+ " <INPUT type='text' id='email' value='Enter email'/>"
+ " <INPUT type='submit' value='Send'/>"
+ "</FORM>",
+ false, "Enter last name", "Enter email");
}
TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) {
@@ -3969,7 +3998,7 @@ TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) {
"<INPUT type='text' id='lastname'/>"
"<INPUT type='text' id='email'/>"
"<INPUT type='submit' value='Send'/>",
- true);
+ true, nullptr, nullptr);
}
TEST_F(FormAutofillTest, ClearFormWithNode) {
« no previous file with comments | « no previous file | components/autofill/content/renderer/form_autofill_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698