Chromium Code Reviews| Index: components/password_manager/content/browser/credential_manager_impl_unittest.cc |
| diff --git a/components/password_manager/content/browser/credential_manager_impl_unittest.cc b/components/password_manager/content/browser/credential_manager_impl_unittest.cc |
| index 4c0840bd5d0529f6676c068b265dc60aa246e7f4..3e7d43ea05f7a1687509796444ba3a6e9212ef03 100644 |
| --- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc |
| +++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc |
| @@ -521,6 +521,79 @@ TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwrite) { |
| passwords[form_.signon_realm][0].password_value); |
| } |
| +TEST_F(CredentialManagerImplTest, |
| + CredentialManagerStorePSLMatchDoesNotTriggerBubble) { |
| + autofill::PasswordForm psl_form = subdomain_form_; |
| + psl_form.username_value = form_.username_value; |
| + psl_form.password_value = form_.password_value; |
| + store_->AddLogin(psl_form); |
| + |
| + // Calling 'Store' with a credential that PSL matches |form_| should update |
| + // the password without prompting the user. |
| + CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
| + EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _)) |
| + .Times(testing::Exactly(0)); |
| + EXPECT_CALL(*client_, NotifyStorePasswordCalled()); |
| + bool called = false; |
| + CallStore(info, base::Bind(&RespondCallback, &called)); |
| + |
| + // Allow the PasswordFormManager to talk to the password store, determine |
| + // that there is an existing PSL match and update the PasswordStore. |
| + RunAllPendingTasks(); |
| + |
| + EXPECT_TRUE(called); |
| +} |
|
vasilii
2016/12/22 13:24:59
Check that the credential was actually stored and
jdoerrie
2016/12/22 16:20:01
Done.
|
| + |
| +TEST_F(CredentialManagerImplTest, |
| + CredentialManagerStoreNonPSLMatchWithDifferentUsernameTriggersBubble) { |
|
vasilii
2016/12/22 13:24:59
should it be CredentialManagerStorePSLMatchWithDif
jdoerrie
2016/12/22 16:20:01
Done.
|
| + base::string16 delta = base::ASCIIToUTF16("_totally_different"); |
| + autofill::PasswordForm in_valid_psl_form = subdomain_form_; |
|
vasilii
2016/12/22 13:24:59
What is 'in_'?
jdoerrie
2016/12/22 16:20:01
Dropped it, meant to say invalid, but the PSL matc
|
| + in_valid_psl_form.username_value = form_.username_value + delta; |
| + in_valid_psl_form.password_value = form_.password_value; |
| + store_->AddLogin(in_valid_psl_form); |
| + |
| + // Calling 'Store' with a credential that does not PSL match |form_| should |
| + // prompt the user for an update. |
| + CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
| + EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _)) |
| + .Times(testing::Exactly(1)); |
| + EXPECT_CALL(*client_, NotifyStorePasswordCalled()); |
| + bool called = false; |
| + CallStore(info, base::Bind(&RespondCallback, &called)); |
| + |
| + // Allow the PasswordFormManager to talk to the password store, determine |
| + // the form is not a (PSL) match for an existing form, and update the |
|
vasilii
2016/12/22 13:24:59
What kind of 'update' are you expecting? i think i
jdoerrie
2016/12/22 16:20:01
Done.
|
| + // PasswordStore. |
| + RunAllPendingTasks(); |
| + |
| + EXPECT_TRUE(called); |
|
vasilii
2016/12/22 13:24:59
Check that client_->pending_manager()->pending_cre
jdoerrie
2016/12/22 16:20:01
Done.
|
| +} |
| + |
| +TEST_F(CredentialManagerImplTest, |
| + CredentialManagerStoreNonPSLMatchWithDifferentPasswordTriggersBubble) { |
| + base::string16 delta = base::ASCIIToUTF16("_totally_different"); |
| + autofill::PasswordForm in_valid_psl_form = subdomain_form_; |
| + in_valid_psl_form.username_value = form_.username_value; |
| + in_valid_psl_form.password_value = form_.password_value + delta; |
| + store_->AddLogin(in_valid_psl_form); |
| + |
| + // Calling 'Store' with a credential that does not PSL match |form_| should |
| + // prompt the user for an update. |
| + CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
| + EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(_, _)) |
| + .Times(testing::Exactly(1)); |
| + EXPECT_CALL(*client_, NotifyStorePasswordCalled()); |
| + bool called = false; |
| + CallStore(info, base::Bind(&RespondCallback, &called)); |
| + |
| + // Allow the PasswordFormManager to talk to the password store, determine |
| + // the form is not a (PSL) match for an existing form, and update the |
| + // PasswordStore. |
| + RunAllPendingTasks(); |
| + |
| + EXPECT_TRUE(called); |
| +} |
| + |
| TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwriteZeroClick) { |
| form_.skip_zero_click = true; |
| store_->AddLogin(form_); |