From feb7cfba67c122cd39ae15e3bac5a2be5a2014e5 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Wed, 11 Feb 2009 17:22:43 +0000 Subject: This CL ensures we don't store empty values in the autofill form DB. Also it applies a clean-up to remove any empty values previously stored in the DB. BUG=6111 TEST=Submit a form and leave some fields empty. Come back to that form, click on a field that was empty. No autofill popup should show up (or if one show up, it should not contains empty values). Review URL: http://codereview.chromium.org/21217 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9570 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/webdata/web_database_unittest.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'chrome/browser/webdata/web_database_unittest.cc') diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index 8842e40..d56edbd 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -464,6 +464,31 @@ TEST_F(WebDatabaseTest, Autofill) { 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, -- cgit v1.1