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

Unified Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 2772793002: Skip checking non-emptiness of username on In-Page Navigation. (Closed)
Patch Set: Created 3 years, 9 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/renderer/autofill/password_autofill_agent_browsertest.cc
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
index 90b781f23f36ed7cf5417f91ca08b3f2cbadbd01..b5491808fe0ed521a073b11546e240425503b597 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -2578,4 +2578,29 @@ TEST_F(PasswordAutofillAgentTest, SuggestWhenJavaScriptUpdatesFieldNames) {
CheckSuggestions("", false);
}
+// Checks that an in-page navigation form submission could have an empty
+// username.
+TEST_F(PasswordAutofillAgentTest, InPageNavigationSubmissionUsernameIsEmpty) {
+ username_element_.setValue(WebString());
+ SimulatePasswordChange("random");
+
+ // Simulate that JavaScript removes the submitted form from DOM. That means
+ // that a submission was successful.
+ std::string remove_form =
+ "var form = document.getElementById('LoginTestForm');"
+ "form.parentNode.removeChild(form);";
+ ExecuteJavaScriptForTests(remove_form.c_str());
+
+ static_cast<content::RenderFrameObserver*>(password_autofill_agent_)
+ ->DidCommitProvisionalLoad(false, true);
+ base::RunLoop().RunUntilIdle();
+
+ // Chect that the form was submitted with in-page navigation.
+ EXPECT_TRUE(fake_driver_.called_inpage_navigation());
+ EXPECT_EQ(base::string16(),
+ fake_driver_.password_form_inpage_navigation()->username_value);
+ EXPECT_EQ(ASCIIToUTF16("random"),
+ fake_driver_.password_form_inpage_navigation()->password_value);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698