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

Unified Diff: components/password_manager/core/browser/password_form_manager_unittest.cc

Issue 241033002: Fix for scoring password autofill candidates: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test Created 6 years, 8 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
Index: components/password_manager/core/browser/password_form_manager_unittest.cc
diff --git a/components/password_manager/core/browser/password_form_manager_unittest.cc b/components/password_manager/core/browser/password_form_manager_unittest.cc
index 2a28b66518db32b8248dddace35f882d1934558f..d721d0148bd708e158e6247da9087125d2002440 100644
--- a/components/password_manager/core/browser/password_form_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -702,4 +702,32 @@ TEST_F(PasswordFormManagerTest, TestUpdateIncompleteCredentials) {
form_manager.Save();
}
+TEST_F(PasswordFormManagerTest, TestScoringPublicSuffixMatch) {
+ base::MessageLoop message_loop;
+
+ TestPasswordManagerClient client(NULL);
+ MockPasswordManagerDriver driver;
+ EXPECT_CALL(driver, IsOffTheRecord()).WillRepeatedly(Return(false));
+ EXPECT_CALL(driver, AllowPasswordGenerationForForm(_));
+
+ TestPasswordManager password_manager(&client);
+ scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
+ &password_manager, &client, &driver, *observed_form(), false));
+
+ // Simulate having two matches for this form, one of which was from different
+ // signon realm, and latter had a different origin and action. Public suffix
+ // match should force higher score, so the second one should be preserved.
Garrett Casto 2014/04/24 22:35:29 I think the ordering of the results doesn't match
+ std::vector<PasswordForm*> results;
+ results.push_back(CreateSavedMatch(false));
+ results.push_back(CreateSavedMatch(false));
+ results[0]->origin = GURL("http://accounts.google.com/a/ServiceLoginAuth2");
+ results[0]->action = GURL("http://accounts.google.com/a/ServiceLogin2");
+ results[1]->original_signon_realm = "http://accounts2.google.com";
+ SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
+ SimulateResponseFromPasswordStore(manager.get(), results);
+ EXPECT_EQ(1u, password_manager.GetLatestBestMatches().size());
+ EXPECT_EQ("", password_manager.GetLatestBestMatches().begin()
+ ->second->original_signon_realm);
+}
+
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698