Index: components/password_manager/core/browser/login_database_unittest.cc |
diff --git a/components/password_manager/core/browser/login_database_unittest.cc b/components/password_manager/core/browser/login_database_unittest.cc |
index e9e1c33a814a06441fc4a148811062487daa3399..e3bf3bbbadbc5da9bc336fc50080789f1a9c5381 100644 |
--- a/components/password_manager/core/browser/login_database_unittest.cc |
+++ b/components/password_manager/core/browser/login_database_unittest.cc |
@@ -245,6 +245,46 @@ TEST_F(LoginDatabaseTest, TestPublicSuffixDomainMatching) { |
result.clear(); |
} |
+TEST_F(LoginDatabaseTest, TestPublicSuffixDisabledForNonHTMLForms) { |
vabr (Chromium)
2014/05/09 09:19:58
Could you please also expand this test for other s
Garrett Casto
2014/05/09 18:32:13
Whoops, fixed.
|
+ PSLMatchingHelper::EnablePublicSuffixDomainMatchingForTesting(); |
+ std::vector<PasswordForm*> result; |
+ |
+ // Example basic auth form. |
+ PasswordForm basic_form; |
+ basic_form.origin = GURL("http://example.com"); |
+ basic_form.username_value = ASCIIToUTF16("test@gmail.com"); |
+ basic_form.password_value = ASCIIToUTF16("test"); |
+ basic_form.signon_realm = "http://example.com/Realm"; |
+ basic_form.scheme = PasswordForm::SCHEME_BASIC; |
+ |
+ // Example password form. |
+ PasswordForm html_form(basic_form); |
+ html_form.action = GURL("http://example.com/login"); |
+ html_form.username_element = ASCIIToUTF16("username"); |
+ html_form.username_value = ASCIIToUTF16("test2@gmail.com"); |
+ html_form.password_element = ASCIIToUTF16("password"); |
+ html_form.submit_element = ASCIIToUTF16(""); |
+ html_form.signon_realm = "http://example.com/"; |
+ html_form.scheme = PasswordForm::SCHEME_HTML; |
+ |
+ // Add them and make sure it is there. |
+ EXPECT_TRUE(db_.AddLogin(basic_form)); |
+ EXPECT_TRUE(db_.AddLogin(html_form)); |
+ EXPECT_TRUE(db_.GetAutofillableLogins(&result)); |
+ EXPECT_EQ(2U, result.size()); |
+ delete result[0]; |
+ delete result[1]; |
+ result.clear(); |
+ |
+ PasswordForm second_basic_auth(basic_form); |
+ second_basic_auth.origin = GURL("http://second.example.com"); |
+ second_basic_auth.signon_realm = "http://second.example.com/Realm"; |
+ |
+ // This shouldn't match anything. |
+ EXPECT_TRUE(db_.GetLogins(second_basic_auth, &result)); |
+ EXPECT_EQ(0U, result.size()); |
+} |
+ |
TEST_F(LoginDatabaseTest, TestPublicSuffixDomainMatchingShouldMatchingApply) { |
PSLMatchingHelper::EnablePublicSuffixDomainMatchingForTesting(); |
std::vector<PasswordForm*> result; |