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

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

Issue 208453002: Add "previewing on hover" support for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
Index: chrome/renderer/autofill/form_autofill_browsertest.cc
diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc
index 419545d58668d7f6515f5c562b9e1d987d8b25ce..391354ad72180b9fd197c5ec40188b5a7678b8b0 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -2837,6 +2837,42 @@ TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) {
EXPECT_EQ(0, firstname.selectionEnd());
}
+TEST_F(FormAutofillTest, ClearPreviewedPassword) {
+ LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">"
+ " <INPUT type=\"text\" id=\"username\" value=\"Wyatt\"/>"
+ " <INPUT type=\"password\" id=\"password\" autocomplete=\"off\"/>"
+ " <INPUT type=\"submit\" value=\"Send\"/>"
+ "</FORM>");
+
+ WebFrame* web_frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame);
+
+ // Set the auto-filled attribute.
+ WebInputElement username =
+ web_frame->document().getElementById("username").to<WebInputElement>();
+ username.setAutofilled(true);
+ WebInputElement password =
+ web_frame->document().getElementById("password").to<WebInputElement>();
+ password.setAutofilled(true);
+
+ // Set the suggested values on password.
+ password.setSuggestedValue(ASCIIToUTF16("SuggestedPassword"));
+
+ // Clear the previewed fields.
+ EXPECT_TRUE(ClearPreviewedFormWithElement(password, REQUIRE_NONE, false,
+ true));
+
+ // Fields with empty suggestions are not modified.
+ EXPECT_EQ(ASCIIToUTF16("Wyatt"), username.value());
+ EXPECT_TRUE(username.suggestedValue().isEmpty());
+ EXPECT_TRUE(username.isAutofilled());
+
+ // Verify the previewed fields are cleared.
+ EXPECT_TRUE(password.value().isEmpty());
+ EXPECT_TRUE(password.suggestedValue().isEmpty());
+ EXPECT_FALSE(password.isAutofilled());
Ilya Sherman 2014/03/21 22:35:19 Hmm, why is the password field no longer autofille
ziran.sun 2014/03/25 18:25:26 You are right. There is an error in the test code.
Ilya Sherman 2014/03/25 19:45:27 Yes, I do mean that we should test the renderer co
+}
+
TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) {
LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">"
" <INPUT type=\"text\" id=\"firstname\" value=\"Wyatt\"/>"
@@ -2879,7 +2915,8 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) {
phone.setSuggestedValue(ASCIIToUTF16("650-777-9999"));
// Clear the previewed fields.
- EXPECT_TRUE(ClearPreviewedFormWithElement(lastname, false));
+ EXPECT_TRUE(ClearPreviewedFormWithElement(lastname, REQUIRE_AUTOCOMPLETE,
+ false, false));
// Fields with empty suggestions suggestions are not modified.
EXPECT_EQ(ASCIIToUTF16("Wyatt"), firstname.value());
@@ -2949,7 +2986,8 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) {
phone.setSuggestedValue(ASCIIToUTF16("650-777-9999"));
// Clear the previewed fields.
- EXPECT_TRUE(ClearPreviewedFormWithElement(firstname, false));
+ EXPECT_TRUE(ClearPreviewedFormWithElement(firstname, REQUIRE_AUTOCOMPLETE,
+ false, false));
// Fields with non-empty values are restored.
EXPECT_EQ(ASCIIToUTF16("W"), firstname.value());
@@ -3016,7 +3054,8 @@ TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) {
phone.setSuggestedValue(ASCIIToUTF16("650-777-9999"));
// Clear the previewed fields.
- EXPECT_TRUE(ClearPreviewedFormWithElement(firstname, true));
+ EXPECT_TRUE(ClearPreviewedFormWithElement(firstname, REQUIRE_AUTOCOMPLETE,
+ true, false));
// Fields with non-empty values are restored.
EXPECT_EQ(ASCIIToUTF16("W"), firstname.value());

Powered by Google App Engine
This is Rietveld 408576698