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

Unified Diff: components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc

Issue 249153002: Rewrite functions from WebPasswordFormData and WebPasswordFormUtils in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update code as per review comments. Created 6 years, 8 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 | « components/autofill/content/renderer/password_form_conversion_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc
diff --git a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc
index d0f55062698ae5f167936e63741a7ef9f0be96d4..b2e656490b7b5696783ea22f4c6a1f31d7d7a249 100644
--- a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc
+++ b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc
@@ -12,11 +12,9 @@
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFormElement.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
-#include "third_party/WebKit/public/web/WebPasswordFormData.h"
using blink::WebFormElement;
using blink::WebFrame;
-using blink::WebPasswordFormData;
using blink::WebVector;
namespace autofill {
@@ -48,8 +46,6 @@ TEST_F(PasswordFormConversionUtilsTest, ValidWebFormElementToPasswordForm) {
WebVector<WebFormElement> forms;
frame->document().forms(forms);
ASSERT_EQ(1U, forms.size());
- WebPasswordFormData web_password_form(forms[0]);
- ASSERT_TRUE(web_password_form.isValid());
scoped_ptr<PasswordForm> password_form = CreatePasswordForm(forms[0]);
ASSERT_NE(static_cast<PasswordForm*>(NULL), password_form.get());
@@ -82,11 +78,82 @@ TEST_F(PasswordFormConversionUtilsTest, InvalidWebFormElementToPasswordForm) {
WebVector<WebFormElement> forms;
frame->document().forms(forms);
ASSERT_EQ(1U, forms.size());
- WebPasswordFormData web_password_form(forms[0]);
- ASSERT_FALSE(web_password_form.isValid());
scoped_ptr<PasswordForm> password_form = CreatePasswordForm(forms[0]);
EXPECT_EQ(static_cast<PasswordForm*>(NULL), password_form.get());
}
+TEST_F(PasswordFormConversionUtilsTest,
+ WebFormWithMultipleUseNameAndPassWordFieldsToPasswordForm) {
+ LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
+ " <INPUT type=\"text\" name=\"username1\" "
+ " id=\"username1\" value=\"John\"/>"
+ " <INPUT type=\"password\" name=\"password1\" id=\"password1\" "
+ " value=\"encrypted\"/>"
+ " <INPUT type=\"text\" name=\"username2\" "
+ " id=\"username2\" value=\"Smith\"/>"
+ " <INPUT type=\"password\" name=\"password2\" id=\"password2\" "
+ " value=\"secret\"/>"
+ " <INPUT type=\"text\" name=\"username3\" "
+ " id=\"username3\" value=\"JohnSmith\"/>"
+ " <INPUT type=\"password\" name=\"password3\" id=\"password3\" "
+ " value=\"secret\"/>"
+ " <INPUT type=\"submit\" name=\"submit\" value=\"Submit\"/>"
+ "</FORM>");
+
+ WebFrame* frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ WebVector<WebFormElement> forms;
+ frame->document().forms(forms);
+ ASSERT_EQ(1U, forms.size());
+
+ scoped_ptr<PasswordForm> password_form = CreatePasswordForm(forms[0]);
+ ASSERT_NE(static_cast<PasswordForm*>(NULL), password_form.get());
+
+ EXPECT_EQ("data:", password_form->signon_realm);
+ EXPECT_EQ(GURL("http://cnn.com"), password_form->action);
+ EXPECT_EQ(base::UTF8ToUTF16("username1"), password_form->username_element);
+ EXPECT_EQ(base::UTF8ToUTF16("John"), password_form->username_value);
+ EXPECT_EQ(base::UTF8ToUTF16("password2"), password_form->password_element);
+ EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value);
+ EXPECT_EQ(base::UTF8ToUTF16("password1"),
+ password_form->old_password_element);
+ EXPECT_EQ(base::UTF8ToUTF16("encrypted"), password_form->old_password_value);
+ EXPECT_EQ(base::UTF8ToUTF16("Smith"),
+ password_form->other_possible_usernames[0]);
+ EXPECT_EQ(base::UTF8ToUTF16("JohnSmith"),
+ password_form->other_possible_usernames[1]);
+ EXPECT_EQ(PasswordForm::SCHEME_HTML, password_form->scheme);
+ EXPECT_FALSE(password_form->ssl_valid);
+ EXPECT_FALSE(password_form->preferred);
+ EXPECT_FALSE(password_form->blacklisted_by_user);
+ EXPECT_EQ(PasswordForm::TYPE_MANUAL, password_form->type);
+}
+
+TEST_F(PasswordFormConversionUtilsTest,
+ WebFormwithThreeDifferentPasswordsToPasswordForm) {
+ LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
+ " <INPUT type=\"text\" name=\"username\" "
+ " id=\"username\" value=\"John\"/>"
+ " <INPUT type=\"password\" name=\"password1\" id=\"password1\" "
+ " value=\"secret\"/>"
+ " <INPUT type=\"password\" name=\"password2\" id=\"password2\" "
+ " value=\"encrypted\"/>"
+ " <INPUT type=\"password\" name=\"password3\" id=\"password3\" "
+ " value=\"key\"/>"
+ " <INPUT type=\"submit\" name=\"submit\" value=\"Submit\"/>"
+ "</FORM>");
+
+ WebFrame* frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ WebVector<WebFormElement> forms;
+ frame->document().forms(forms);
+ ASSERT_EQ(1U, forms.size());
+
+ scoped_ptr<PasswordForm> password_form = CreatePasswordForm(forms[0]);
+ ASSERT_EQ(static_cast<PasswordForm*>(NULL), password_form.get());
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/content/renderer/password_form_conversion_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698