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

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

Issue 680413004: [Password Generation] Send onchange event when password is filled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/password_generation_agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_generation_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698