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

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

Issue 10540069: Refactor detection of account creation forms and fix two minor issues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 6 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 | « chrome/renderer/autofill/password_generation_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/password_generation_manager_browsertest.cc
diff --git a/chrome/renderer/autofill/password_generation_manager_browsertest.cc b/chrome/renderer/autofill/password_generation_manager_browsertest.cc
index d51e8c237dc76b6b4e30fe446bf282a0becb3526..d0d924d1ecf34307f2f4cef3b4867146b90ddcf2 100644
--- a/chrome/renderer/autofill/password_generation_manager_browsertest.cc
+++ b/chrome/renderer/autofill/password_generation_manager_browsertest.cc
@@ -94,6 +94,22 @@ const char kSigninFormHTML[] =
const char kAccountCreationFormHTML[] =
"<FORM name = 'blah' action = 'http://www.random.com/'> "
" <INPUT type = 'text' id = 'username'/> "
+ " <INPUT type = 'password' id = 'first_password' size=5/> "
+ " <INPUT type = 'password' id = 'second_password' size=5/> "
+ " <INPUT type = 'submit' value = 'LOGIN' />"
+ "</FORM>";
+
+const char kHiddenPasswordAccountCreationFormHTML[] =
+ "<FORM name = 'blah' action = 'http://www.random.com/'> "
+ " <INPUT type = 'text' id = 'username'/> "
+ " <INPUT type = 'password' id = 'first_password'/> "
+ " <INPUT type = 'password' id = 'second_password' style='display:none'/> "
+ " <INPUT type = 'submit' value = 'LOGIN' />"
+ "</FORM>";
+
+const char kInvalidActionAccountCreationFormHTML[] =
+ "<FORM name = 'blah' action = 'invalid'> "
+ " <INPUT type = 'text' id = 'username'/> "
" <INPUT type = 'password' id = 'first_password'/> "
" <INPUT type = 'password' id = 'second_password'/> "
" <INPUT type = 'submit' value = 'LOGIN' />"
@@ -116,9 +132,6 @@ TEST_F(PasswordGenerationManagerTest, DetectionTest) {
element = document.getElementById(WebString::fromUTF8("first_password"));
ASSERT_FALSE(element.isNull());
WebInputElement first_password_element = element.to<WebInputElement>();
- element = document.getElementById(WebString::fromUTF8("second_password"));
- ASSERT_FALSE(element.isNull());
- WebInputElement second_password_element = element.to<WebInputElement>();
EXPECT_FALSE(DecorationIsVisible(&first_password_element));
// Pretend like password generation was enabled.
@@ -132,14 +145,27 @@ TEST_F(PasswordGenerationManagerTest, DetectionTest) {
element = document.getElementById(WebString::fromUTF8("first_password"));
ASSERT_FALSE(element.isNull());
first_password_element = element.to<WebInputElement>();
- element = document.getElementById(WebString::fromUTF8("second_password"));
- ASSERT_FALSE(element.isNull());
- second_password_element = element.to<WebInputElement>();
EXPECT_TRUE(DecorationIsVisible(&first_password_element));
SimulateClickOnDecoration(&first_password_element);
EXPECT_EQ(1u, generation_manager_->messages().size());
EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID,
generation_manager_->messages()[0]->type());
+
+ // This doesn't trigger because hidden password fields are ignored.
+ LoadHTML(kHiddenPasswordAccountCreationFormHTML);
+ document = GetMainFrame()->document();
+ element = document.getElementById(WebString::fromUTF8("first_password"));
+ ASSERT_FALSE(element.isNull());
+ first_password_element = element.to<WebInputElement>();
+ EXPECT_FALSE(DecorationIsVisible(&first_password_element));
+
+ // This doesn't trigger because the form action is invalid.
+ LoadHTML(kInvalidActionAccountCreationFormHTML);
+ document = GetMainFrame()->document();
+ element = document.getElementById(WebString::fromUTF8("first_password"));
+ ASSERT_FALSE(element.isNull());
+ first_password_element = element.to<WebInputElement>();
+ EXPECT_FALSE(DecorationIsVisible(&first_password_element));
}
TEST_F(PasswordGenerationManagerTest, FillTest) {
« no previous file with comments | « chrome/renderer/autofill/password_generation_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698