summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/autofill
diff options
context:
space:
mode:
authorgcasto <gcasto@chromium.org>2014-11-03 15:06:05 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-03 23:06:24 +0000
commitdfef9806fea030778404f9bea5d78ed313c31816 (patch)
tree1380bb71602a59d8444178cf924bfd2667e41344 /chrome/renderer/autofill
parentb9ebd3861a8c8aad6e91c8fd43f32d917d2e380e (diff)
downloadchromium_src-dfef9806fea030778404f9bea5d78ed313c31816.zip
chromium_src-dfef9806fea030778404f9bea5d78ed313c31816.tar.gz
chromium_src-dfef9806fea030778404f9bea5d78ed313c31816.tar.bz2
[Password Generation] Send onchange event when password is filled
Failure to do so causes UI issues on some sites, and causes form submission to fail on Yahoo. BUG=159043 Review URL: https://codereview.chromium.org/680413004 Cr-Commit-Position: refs/heads/master@{#302510}
Diffstat (limited to 'chrome/renderer/autofill')
-rw-r--r--chrome/renderer/autofill/password_generation_agent_browsertest.cc30
1 files changed, 29 insertions, 1 deletions
diff --git a/chrome/renderer/autofill/password_generation_agent_browsertest.cc b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
index d456a77..ca13450 100644
--- a/chrome/renderer/autofill/password_generation_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
@@ -110,6 +110,18 @@ const char kInvalidActionAccountCreationFormHTML[] =
" <INPUT type = 'submit' value = 'LOGIN' />"
"</FORM>";
+const char ChangeDetectionScript[] =
+ "<script>"
+ " firstOnChangeCalled = false;"
+ " secondOnChangeCalled = false;"
+ " document.getElementById('first_password').onchange = function() {"
+ " firstOnChangeCalled = true;"
+ " };"
+ " document.getElementById('second_password').onchange = function() {"
+ " secondOnChangeCalled = true;"
+ " };"
+ "</script>";
+
TEST_F(PasswordGenerationAgentTest, DetectionTest) {
// Don't shown the icon for non account creation forms.
LoadHTML(kSigninFormHTML);
@@ -143,7 +155,9 @@ TEST_F(PasswordGenerationAgentTest, DetectionTest) {
TEST_F(PasswordGenerationAgentTest, FillTest) {
// Make sure that we are enabled before loading HTML.
- LoadHTML(kAccountCreationFormHTML);
+ std::string html = std::string(kAccountCreationFormHTML) +
+ ChangeDetectionScript;
+ LoadHTML(html.c_str());
WebDocument document = GetMainFrame()->document();
WebElement element =
@@ -168,6 +182,20 @@ TEST_F(PasswordGenerationAgentTest, FillTest) {
EXPECT_TRUE(first_password_element.isAutofilled());
EXPECT_TRUE(second_password_element.isAutofilled());
+ // Make sure onchange events are called.
+ int first_onchange_called = -1;
+ int second_onchange_called = -1;
+ ASSERT_TRUE(
+ ExecuteJavaScriptAndReturnIntValue(
+ base::ASCIIToUTF16("firstOnChangeCalled ? 1 : 0"),
+ &first_onchange_called));
+ EXPECT_EQ(1, first_onchange_called);
+ ASSERT_TRUE(
+ ExecuteJavaScriptAndReturnIntValue(
+ base::ASCIIToUTF16("secondOnChangeCalled ? 1 : 0"),
+ &second_onchange_called));
+ EXPECT_EQ(1, second_onchange_called);
+
// Focus moved to the next input field.
// TODO(zysxqn): Change this back to the address element once Bug 90224
// https://bugs.webkit.org/show_bug.cgi?id=90224 has been fixed.