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

Unified Diff: chrome/browser/password_manager/password_form_manager_unittest.cc

Issue 10892011: Fix for no password save when action URL is modified (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
Index: chrome/browser/password_manager/password_form_manager_unittest.cc
===================================================================
--- chrome/browser/password_manager/password_form_manager_unittest.cc (revision 157109)
+++ chrome/browser/password_manager/password_form_manager_unittest.cc (working copy)
@@ -163,6 +163,8 @@
GetPendingCredentials(manager)->origin.spec());
EXPECT_EQ(observed_form()->signon_realm,
GetPendingCredentials(manager)->signon_realm);
+ EXPECT_EQ(observed_form()->action,
+ GetPendingCredentials(manager)->action);
EXPECT_TRUE(GetPendingCredentials(manager)->preferred);
EXPECT_EQ(saved_match()->password_value,
GetPendingCredentials(manager)->password_value);
@@ -270,6 +272,43 @@
GetPendingCredentials(manager.get())->action);
}
+TEST_F(PasswordFormManagerTest, TestUpdateAction) {
+ scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
+ profile(), NULL, NULL, *observed_form(), false));
+
+ SimulateMatchingPhase(manager.get(), true);
+ // User logs in with the autofilled username / password from saved_match.
+ PasswordForm login = *observed_form();
+ login.username_value = saved_match()->username_value;
+ login.password_value = saved_match()->password_value;
+
+ manager->ProvisionallySave(login);
+ EXPECT_FALSE(manager->IsNewLogin());
+ // The observed action URL is different from the previously saved one, and
+ // is the same as the one that would be submitted on successful login.
+ EXPECT_NE(observed_form()->action, saved_match()->action);
+ EXPECT_EQ(observed_form()->action,
+ GetPendingCredentials(manager.get())->action);
+}
+
+TEST_F(PasswordFormManagerTest, TestDynamicAction) {
+ scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
+ profile(), NULL, NULL, *observed_form(), false));
+
+ SimulateMatchingPhase(manager.get(), false);
+ PasswordForm login(*observed_form());
+ // The submitted action URL is different from the one observed on page load.
+ GURL new_action = GURL("http://www.google.com/new_action");
+ login.action = new_action;
+
+ manager->ProvisionallySave(login);
+ EXPECT_TRUE(manager->IsNewLogin());
+ // Check that the provisionally saved action URL is the same as the submitted
+ // action URL, not the one observed on page load.
+ EXPECT_EQ(new_action,
+ GetPendingCredentials(manager.get())->action);
+}
+
TEST_F(PasswordFormManagerTest, TestValidForms) {
// User submits credentials for the observed form.
PasswordForm credentials = *observed_form();
« no previous file with comments | « chrome/browser/password_manager/password_form_manager.cc ('k') | chrome/browser/password_manager/password_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698