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

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

Issue 545433003: Don't allow the empty new password to overwrite the existing one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added comments Created 6 years, 3 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_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_manager_unittest.cc
diff --git a/components/password_manager/core/browser/password_manager_unittest.cc b/components/password_manager/core/browser/password_manager_unittest.cc
index 0a82fe7e12b73c2b0cb8e201c7dc47fba5ff2dc1..460c1925360f0499cea12c8edfc01ee73f019cae 100644
--- a/components/password_manager/core/browser/password_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_manager_unittest.cc
@@ -798,4 +798,31 @@ TEST_F(PasswordManagerTest,
observed.clear();
}
+// Create a form with a new_password_element. Submit the form with the empty
+// new password value. It shouldn't overwrite the existing password.
+TEST_F(PasswordManagerTest, DoNotUpdateWithEmptyPassword) {
+ std::vector<PasswordForm*> result; // Empty password store.
+ EXPECT_CALL(*store_.get(), GetLogins(_, _, _))
+ .WillOnce(DoAll(WithArg<2>(InvokeConsumer(result)), Return()));
+ std::vector<PasswordForm> observed;
+ PasswordForm form(MakeSimpleForm());
+ form.new_password_element = ASCIIToUTF16("new_password_element");
+ form.new_password_value.clear();
+ observed.push_back(form);
+ manager()->OnPasswordFormsParsed(observed); // The initial load.
+ manager()->OnPasswordFormsRendered(observed, true); // The initial layout.
+
+ // And the form submit contract is to call ProvisionallySavePassword.
+ OnPasswordFormSubmitted(form);
+
+ scoped_ptr<PasswordFormManager> form_to_save;
+ EXPECT_CALL(client_, PromptUserToSavePasswordPtr(_)).Times(0);
+
+ // Now the password manager waits for the login to complete successfully.
+ observed.clear();
+ manager()->OnPasswordFormsParsed(observed); // The post-navigation load.
+ manager()->OnPasswordFormsRendered(observed,
+ true); // The post-navigation layout.
+}
+
} // namespace password_manager
« no previous file with comments | « components/password_manager/core/browser/password_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698