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

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

Issue 2746033004: Add password form search using blink::WebNode reference comparison. (Closed)
Patch Set: Rename ProvisionallySavedForm to ProvisionallySavedPasswordForm. 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
« no previous file with comments | « no previous file | components/autofill/content/renderer/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b598bccc4fcb37a6a5a88c990ed3e5e10b49855d..fbdc312d3bfbb4cdde3a9f41be60d7197598fb8f 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -2175,6 +2175,65 @@ TEST_F(PasswordAutofillAgentTest,
ASSERT_FALSE(fake_driver_.called_password_form_submitted());
}
+// Tests that no save promt is shown when an unowned form is changed and AJAX
+// completed but the form is still visible.
+TEST_F(PasswordAutofillAgentTest,
+ NoForm_NoPromptForAJAXSubmitWithoutNavigationAndNewElementAppeared) {
+ const char kNoFormHTMLWithHiddenField[] =
+ "<INPUT type='text' id='username'/>"
+ "<INPUT type='password' id='password'/>"
+ "<INPUT type='text' id='captcha' style='display:none'/>";
+ LoadHTML(kNoFormHTMLWithHiddenField);
+
+ UpdateUsernameAndPasswordElements();
+ WebElement captcha_element =
+ GetMainFrame()->document().getElementById(WebString::fromUTF8("captcha"));
+ ASSERT_FALSE(captcha_element.isNull());
+
+ SimulateUsernameChange("Bob");
+ SimulatePasswordChange("mypassword");
+
+ // Simulate captcha element show up right before AJAX completed.
+ captcha_element.setAttribute("style", "display:inline;");
+ password_autofill_agent_->AJAXSucceeded();
+
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(fake_driver_.called_inpage_navigation());
+ EXPECT_FALSE(fake_driver_.called_password_form_submitted());
+}
+
+// Tests that no save promt is shown when a form with empty action URL is
+// changed and AJAX completed but the form is still visible.
+TEST_F(PasswordAutofillAgentTest,
+ NoAction_NoPromptForAJAXSubmitWithoutNavigationAndNewElementAppeared) {
+ // Form without an action URL.
+ const char kHTMLWithHiddenField[] =
+ "<FORM name='LoginTestForm'>"
+ " <INPUT type='text' id='username'/>"
+ " <INPUT type='password' id='password'/>"
+ " <INPUT type='text' id='captcha' style='display:none'/>"
+ " <INPUT type='submit' value='Login'/>"
+ "</FORM>";
+ // Set the valid URL so the form action URL can be generated properly.
+ LoadHTMLWithUrlOverride(kHTMLWithHiddenField, "https://www.example.com");
+
+ UpdateUsernameAndPasswordElements();
+ WebElement captcha_element =
+ GetMainFrame()->document().getElementById(WebString::fromUTF8("captcha"));
+ ASSERT_FALSE(captcha_element.isNull());
+
+ SimulateUsernameChange("Bob");
+ SimulatePasswordChange("mypassword");
+
+ // Simulate captcha element show up right before AJAX completed.
+ captcha_element.setAttribute("style", "display:inline;");
+ password_autofill_agent_->AJAXSucceeded();
+
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(fake_driver_.called_inpage_navigation());
+ EXPECT_FALSE(fake_driver_.called_password_form_submitted());
+}
+
// Tests that credential suggestions are autofilled on a password (and change
// password) forms having either ambiguous or empty name.
TEST_F(PasswordAutofillAgentTest,
« no previous file with comments | « no previous file | components/autofill/content/renderer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698