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

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: Indexing fix 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
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b92e9f62ea9d61b154e3444a3668ea57adf16e83 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,34 @@ 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, first comes from different
+ // signon realm, but reports the same origin and action as matched form.
+ // Second candidate has the same signon realm as the form, but has a different
+ // origin and action. Public suffix match is the most important criterion so
+ // the second candidate should be selected.
+ std::vector<PasswordForm*> results;
+ results.push_back(CreateSavedMatch(false));
+ results.push_back(CreateSavedMatch(false));
+ results[0]->original_signon_realm = "http://accounts2.google.com";
+ results[1]->origin = GURL("http://accounts.google.com/a/ServiceLoginAuth2");
+ results[1]->action = GURL("http://accounts.google.com/a/ServiceLogin2");
+ 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
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698