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

Unified Diff: chrome/browser/webdata/web_database_unittest.cc

Issue 21217: Don't store empty values for autofill (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « chrome/browser/webdata/web_database.cc ('k') | webkit/glue/autofill_form.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_database_unittest.cc
===================================================================
--- chrome/browser/webdata/web_database_unittest.cc (revision 9373)
+++ chrome/browser/webdata/web_database_unittest.cc (working copy)
@@ -464,6 +464,31 @@
EXPECT_TRUE(db.GetFormValuesForElementName(L"Name", L"", &v, 6));
EXPECT_EQ(0U, v.size());
+
+ // Now add some values with empty strings.
+ const std::wstring kValue = L" toto ";
+ EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank", L"")));
+ EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank",
+ L" ")));
+ EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank",
+ L" ")));
+ EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank",
+ kValue)));
+
+ // They should be stored normally as the DB layer does not check for empty
+ // values.
+ v.clear();
+ EXPECT_TRUE(db.GetFormValuesForElementName(L"blank", L"", &v, 10));
+ EXPECT_EQ(4U, v.size());
+
+ // Now we'll check that ClearAutofillEmptyValueElements() works as expected.
+ db.ClearAutofillEmptyValueElements();
+
+ v.clear();
+ EXPECT_TRUE(db.GetFormValuesForElementName(L"blank", L"", &v, 10));
+ ASSERT_EQ(1U, v.size());
+
+ EXPECT_EQ(kValue, v[0]);
}
static bool AddTimestampedLogin(WebDatabase* db, std::string url,
« no previous file with comments | « chrome/browser/webdata/web_database.cc ('k') | webkit/glue/autofill_form.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698