| Index: chrome/renderer/autofill/password_generation_agent_browsertest.cc
|
| diff --git a/chrome/renderer/autofill/password_generation_agent_browsertest.cc b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
|
| index 52d8100dd2ecb806a0f9ee2f9ae1b655837a0430..311c1ef9305e97b967ea8bce9163fdd9036c1cc1 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.
|
|
|