Chromium Code Reviews| 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 |