OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 9 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
10 #include "components/autofill/core/common/password_form.h" | 10 #include "components/autofill/core/common/password_form.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 std::string ProduceHTML() const { | 98 std::string ProduceHTML() const { |
99 return html_ + "</FORM>"; | 99 return html_ + "</FORM>"; |
100 } | 100 } |
101 | 101 |
102 private: | 102 private: |
103 std::string html_; | 103 std::string html_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(PasswordFormBuilder); | 105 DISALLOW_COPY_AND_ASSIGN(PasswordFormBuilder); |
106 }; | 106 }; |
107 | 107 |
108 class PasswordFormConversionUtilsTest : public content::RenderViewTest { | 108 // RenderVIewTest-based tests crash on Android |
| 109 // http://crbug.com/187500 |
| 110 #if defined(OS_ANDROID) |
| 111 #define MAYBE_PasswordFormConversionUtilsTest \ |
| 112 DISABLED_PasswordFormConversionUtilsTest |
| 113 #else |
| 114 #define MAYBE_PasswordFormConversionUtilsTest PasswordFormConversionUtilsTest |
| 115 #endif // defined(OS_ANDROID) |
| 116 |
| 117 class MAYBE_PasswordFormConversionUtilsTest : public content::RenderViewTest { |
109 public: | 118 public: |
110 PasswordFormConversionUtilsTest() : content::RenderViewTest() {} | 119 MAYBE_PasswordFormConversionUtilsTest() : content::RenderViewTest() {} |
111 ~PasswordFormConversionUtilsTest() override {} | 120 ~MAYBE_PasswordFormConversionUtilsTest() override {} |
112 | 121 |
113 protected: | 122 protected: |
114 // Loads the given |html|, retrieves the sole WebFormElement from it, and then | 123 // Loads the given |html|, retrieves the sole WebFormElement from it, and then |
115 // calls CreatePasswordForm() to convert it into a |password_form|. Note that | 124 // calls CreatePasswordForm() to convert it into a |password_form|. Note that |
116 // ASSERT() can only be used in void functions, this is why |password_form| is | 125 // ASSERT() can only be used in void functions, this is why |password_form| is |
117 // passed in as a pointer to a scoped_ptr. | 126 // passed in as a pointer to a scoped_ptr. |
118 void LoadHTMLAndConvertForm(const std::string& html, | 127 void LoadHTMLAndConvertForm(const std::string& html, |
119 scoped_ptr<PasswordForm>* password_form) { | 128 scoped_ptr<PasswordForm>* password_form) { |
120 LoadHTML(html.c_str()); | 129 LoadHTML(html.c_str()); |
121 | 130 |
122 WebFrame* frame = GetMainFrame(); | 131 WebFrame* frame = GetMainFrame(); |
123 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | 132 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
124 | 133 |
125 WebVector<WebFormElement> forms; | 134 WebVector<WebFormElement> forms; |
126 frame->document().forms(forms); | 135 frame->document().forms(forms); |
127 ASSERT_EQ(1U, forms.size()); | 136 ASSERT_EQ(1U, forms.size()); |
128 | 137 |
129 WebVector<WebFormControlElement> control_elements; | 138 WebVector<WebFormControlElement> control_elements; |
130 forms[0].getFormControlElements(control_elements); | 139 forms[0].getFormControlElements(control_elements); |
131 for (size_t i = 0; i < control_elements.size(); ++i) { | 140 for (size_t i = 0; i < control_elements.size(); ++i) { |
132 WebInputElement* input_element = toWebInputElement(&control_elements[i]); | 141 WebInputElement* input_element = toWebInputElement(&control_elements[i]); |
133 if (input_element->hasAttribute("set-activated-submit")) | 142 if (input_element->hasAttribute("set-activated-submit")) |
134 input_element->setActivatedSubmit(true); | 143 input_element->setActivatedSubmit(true); |
135 } | 144 } |
136 | 145 |
137 *password_form = CreatePasswordForm(forms[0], nullptr, nullptr); | 146 *password_form = CreatePasswordForm(forms[0], nullptr, nullptr); |
138 } | 147 } |
139 | 148 |
140 private: | 149 private: |
141 DISALLOW_COPY_AND_ASSIGN(PasswordFormConversionUtilsTest); | 150 DISALLOW_COPY_AND_ASSIGN(MAYBE_PasswordFormConversionUtilsTest); |
142 }; | 151 }; |
143 | 152 |
144 } // namespace | 153 } // namespace |
145 | 154 |
146 TEST_F(PasswordFormConversionUtilsTest, BasicFormAttributes) { | 155 TEST_F(MAYBE_PasswordFormConversionUtilsTest, BasicFormAttributes) { |
147 PasswordFormBuilder builder(kTestFormActionURL); | 156 PasswordFormBuilder builder(kTestFormActionURL); |
148 builder.AddUsernameField("username", "johnsmith", NULL); | 157 builder.AddUsernameField("username", "johnsmith", NULL); |
149 builder.AddSubmitButton("inactive_submit", false); | 158 builder.AddSubmitButton("inactive_submit", false); |
150 builder.AddSubmitButton("active_submit", true); | 159 builder.AddSubmitButton("active_submit", true); |
151 builder.AddSubmitButton("inactive_submit2", false); | 160 builder.AddSubmitButton("inactive_submit2", false); |
152 builder.AddPasswordField("password", "secret", NULL); | 161 builder.AddPasswordField("password", "secret", NULL); |
153 std::string html = builder.ProduceHTML(); | 162 std::string html = builder.ProduceHTML(); |
154 | 163 |
155 scoped_ptr<PasswordForm> password_form; | 164 scoped_ptr<PasswordForm> password_form; |
156 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); | 165 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); |
157 ASSERT_TRUE(password_form); | 166 ASSERT_TRUE(password_form); |
158 | 167 |
159 EXPECT_EQ("data:", password_form->signon_realm); | 168 EXPECT_EQ("data:", password_form->signon_realm); |
160 EXPECT_EQ(GURL(kTestFormActionURL), password_form->action); | 169 EXPECT_EQ(GURL(kTestFormActionURL), password_form->action); |
161 EXPECT_EQ(base::UTF8ToUTF16("active_submit"), password_form->submit_element); | 170 EXPECT_EQ(base::UTF8ToUTF16("active_submit"), password_form->submit_element); |
162 EXPECT_EQ(base::UTF8ToUTF16("username"), password_form->username_element); | 171 EXPECT_EQ(base::UTF8ToUTF16("username"), password_form->username_element); |
163 EXPECT_EQ(base::UTF8ToUTF16("johnsmith"), password_form->username_value); | 172 EXPECT_EQ(base::UTF8ToUTF16("johnsmith"), password_form->username_value); |
164 EXPECT_EQ(base::UTF8ToUTF16("password"), password_form->password_element); | 173 EXPECT_EQ(base::UTF8ToUTF16("password"), password_form->password_element); |
165 EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value); | 174 EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value); |
166 EXPECT_EQ(PasswordForm::SCHEME_HTML, password_form->scheme); | 175 EXPECT_EQ(PasswordForm::SCHEME_HTML, password_form->scheme); |
167 EXPECT_FALSE(password_form->ssl_valid); | 176 EXPECT_FALSE(password_form->ssl_valid); |
168 EXPECT_FALSE(password_form->preferred); | 177 EXPECT_FALSE(password_form->preferred); |
169 EXPECT_FALSE(password_form->blacklisted_by_user); | 178 EXPECT_FALSE(password_form->blacklisted_by_user); |
170 EXPECT_EQ(PasswordForm::TYPE_MANUAL, password_form->type); | 179 EXPECT_EQ(PasswordForm::TYPE_MANUAL, password_form->type); |
171 } | 180 } |
172 | 181 |
173 TEST_F(PasswordFormConversionUtilsTest, DisabledFieldsAreIgnored) { | 182 TEST_F(MAYBE_PasswordFormConversionUtilsTest, DisabledFieldsAreIgnored) { |
174 PasswordFormBuilder builder(kTestFormActionURL); | 183 PasswordFormBuilder builder(kTestFormActionURL); |
175 builder.AddUsernameField("username", "johnsmith", NULL); | 184 builder.AddUsernameField("username", "johnsmith", NULL); |
176 builder.AddDisabledUsernameField(); | 185 builder.AddDisabledUsernameField(); |
177 builder.AddDisabledPasswordField(); | 186 builder.AddDisabledPasswordField(); |
178 builder.AddPasswordField("password", "secret", NULL); | 187 builder.AddPasswordField("password", "secret", NULL); |
179 builder.AddSubmitButton("submit", true); | 188 builder.AddSubmitButton("submit", true); |
180 std::string html = builder.ProduceHTML(); | 189 std::string html = builder.ProduceHTML(); |
181 | 190 |
182 scoped_ptr<PasswordForm> password_form; | 191 scoped_ptr<PasswordForm> password_form; |
183 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); | 192 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); |
184 ASSERT_TRUE(password_form); | 193 ASSERT_TRUE(password_form); |
185 EXPECT_EQ(base::UTF8ToUTF16("username"), password_form->username_element); | 194 EXPECT_EQ(base::UTF8ToUTF16("username"), password_form->username_element); |
186 EXPECT_EQ(base::UTF8ToUTF16("johnsmith"), password_form->username_value); | 195 EXPECT_EQ(base::UTF8ToUTF16("johnsmith"), password_form->username_value); |
187 EXPECT_EQ(base::UTF8ToUTF16("password"), password_form->password_element); | 196 EXPECT_EQ(base::UTF8ToUTF16("password"), password_form->password_element); |
188 EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value); | 197 EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value); |
189 } | 198 } |
190 | 199 |
191 TEST_F(PasswordFormConversionUtilsTest, IdentifyingUsernameFields) { | 200 TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingUsernameFields) { |
192 // Each test case consists of a set of parameters to be plugged into the | 201 // Each test case consists of a set of parameters to be plugged into the |
193 // PasswordFormBuilder below, plus the corresponding expectations. | 202 // PasswordFormBuilder below, plus the corresponding expectations. |
194 struct TestCase { | 203 struct TestCase { |
195 const char* autocomplete[3]; | 204 const char* autocomplete[3]; |
196 const char* expected_username_element; | 205 const char* expected_username_element; |
197 const char* expected_username_value; | 206 const char* expected_username_value; |
198 const char* expected_other_possible_usernames; | 207 const char* expected_other_possible_usernames; |
199 } cases[] = { | 208 } cases[] = { |
200 // When no elements are marked with autocomplete='username', the text-type | 209 // When no elements are marked with autocomplete='username', the text-type |
201 // input field before the first password element should get selected as | 210 // input field before the first password element should get selected as |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 EXPECT_TRUE(password_form->other_possible_usernames.empty()); | 275 EXPECT_TRUE(password_form->other_possible_usernames.empty()); |
267 } | 276 } |
268 | 277 |
269 // Do a basic sanity check that we are still having a password field. | 278 // Do a basic sanity check that we are still having a password field. |
270 EXPECT_EQ(base::UTF8ToUTF16("password"), password_form->password_element); | 279 EXPECT_EQ(base::UTF8ToUTF16("password"), password_form->password_element); |
271 EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value); | 280 EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value); |
272 } | 281 } |
273 } | 282 } |
274 } | 283 } |
275 | 284 |
276 TEST_F(PasswordFormConversionUtilsTest, IdentifyingTwoPasswordFields) { | 285 TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingTwoPasswordFields) { |
277 // Each test case consists of a set of parameters to be plugged into the | 286 // Each test case consists of a set of parameters to be plugged into the |
278 // PasswordFormBuilder below, plus the corresponding expectations. | 287 // PasswordFormBuilder below, plus the corresponding expectations. |
279 struct TestCase { | 288 struct TestCase { |
280 const char* password_values[2]; | 289 const char* password_values[2]; |
281 const char* expected_password_element; | 290 const char* expected_password_element; |
282 const char* expected_password_value; | 291 const char* expected_password_value; |
283 const char* expected_new_password_element; | 292 const char* expected_new_password_element; |
284 const char* expected_new_password_value; | 293 const char* expected_new_password_value; |
285 } cases[] = { | 294 } cases[] = { |
286 // Twp non-empty fields with the same value should be treated as a new | 295 // Twp non-empty fields with the same value should be treated as a new |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 password_form->new_password_value); | 330 password_form->new_password_value); |
322 | 331 |
323 // Do a basic sanity check that we are still selecting the right username. | 332 // Do a basic sanity check that we are still selecting the right username. |
324 EXPECT_EQ(base::UTF8ToUTF16("username1"), password_form->username_element); | 333 EXPECT_EQ(base::UTF8ToUTF16("username1"), password_form->username_element); |
325 EXPECT_EQ(base::UTF8ToUTF16("William"), password_form->username_value); | 334 EXPECT_EQ(base::UTF8ToUTF16("William"), password_form->username_value); |
326 EXPECT_THAT(password_form->other_possible_usernames, | 335 EXPECT_THAT(password_form->other_possible_usernames, |
327 testing::ElementsAre(base::UTF8ToUTF16("Smith"))); | 336 testing::ElementsAre(base::UTF8ToUTF16("Smith"))); |
328 } | 337 } |
329 } | 338 } |
330 | 339 |
331 TEST_F(PasswordFormConversionUtilsTest, IdentifyingThreePasswordFields) { | 340 TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingThreePasswordFields) { |
332 // Each test case consists of a set of parameters to be plugged into the | 341 // Each test case consists of a set of parameters to be plugged into the |
333 // PasswordFormBuilder below, plus the corresponding expectations. | 342 // PasswordFormBuilder below, plus the corresponding expectations. |
334 struct TestCase { | 343 struct TestCase { |
335 const char* password_values[3]; | 344 const char* password_values[3]; |
336 const char* expected_password_element; | 345 const char* expected_password_element; |
337 const char* expected_password_value; | 346 const char* expected_password_value; |
338 const char* expected_new_password_element; | 347 const char* expected_new_password_element; |
339 const char* expected_new_password_value; | 348 const char* expected_new_password_value; |
340 } cases[] = { | 349 } cases[] = { |
341 // Two fields with the same value, and one different: we should treat this | 350 // Two fields with the same value, and one different: we should treat this |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 password_form->new_password_value); | 391 password_form->new_password_value); |
383 | 392 |
384 // Do a basic sanity check that we are still selecting the right username. | 393 // Do a basic sanity check that we are still selecting the right username. |
385 EXPECT_EQ(base::UTF8ToUTF16("username1"), password_form->username_element); | 394 EXPECT_EQ(base::UTF8ToUTF16("username1"), password_form->username_element); |
386 EXPECT_EQ(base::UTF8ToUTF16("William"), password_form->username_value); | 395 EXPECT_EQ(base::UTF8ToUTF16("William"), password_form->username_value); |
387 EXPECT_THAT(password_form->other_possible_usernames, | 396 EXPECT_THAT(password_form->other_possible_usernames, |
388 testing::ElementsAre(base::UTF8ToUTF16("Smith"))); | 397 testing::ElementsAre(base::UTF8ToUTF16("Smith"))); |
389 } | 398 } |
390 } | 399 } |
391 | 400 |
392 TEST_F(PasswordFormConversionUtilsTest, | 401 TEST_F(MAYBE_PasswordFormConversionUtilsTest, |
393 IdentifyingPasswordFieldsWithAutocompleteAttributes) { | 402 IdentifyingPasswordFieldsWithAutocompleteAttributes) { |
394 // Each test case consists of a set of parameters to be plugged into the | 403 // Each test case consists of a set of parameters to be plugged into the |
395 // PasswordFormBuilder below, plus the corresponding expectations. | 404 // PasswordFormBuilder below, plus the corresponding expectations. |
396 struct TestCase { | 405 struct TestCase { |
397 const char* autocomplete[3]; | 406 const char* autocomplete[3]; |
398 const char* expected_password_element; | 407 const char* expected_password_element; |
399 const char* expected_password_value; | 408 const char* expected_password_value; |
400 const char* expected_new_password_element; | 409 const char* expected_new_password_element; |
401 const char* expected_new_password_value; | 410 const char* expected_new_password_value; |
402 bool expected_new_password_marked_by_site; | 411 bool expected_new_password_marked_by_site; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 password_form->password_value); | 529 password_form->password_value); |
521 EXPECT_EQ(base::UTF8ToUTF16(cases[i].expected_new_password_element), | 530 EXPECT_EQ(base::UTF8ToUTF16(cases[i].expected_new_password_element), |
522 password_form->new_password_element); | 531 password_form->new_password_element); |
523 EXPECT_EQ(base::UTF8ToUTF16(cases[i].expected_new_password_value), | 532 EXPECT_EQ(base::UTF8ToUTF16(cases[i].expected_new_password_value), |
524 password_form->new_password_value); | 533 password_form->new_password_value); |
525 EXPECT_EQ(cases[i].expected_new_password_marked_by_site, | 534 EXPECT_EQ(cases[i].expected_new_password_marked_by_site, |
526 password_form->new_password_marked_by_site); | 535 password_form->new_password_marked_by_site); |
527 } | 536 } |
528 } | 537 } |
529 | 538 |
530 TEST_F(PasswordFormConversionUtilsTest, InvalidFormDueToBadActionURL) { | 539 TEST_F(MAYBE_PasswordFormConversionUtilsTest, InvalidFormDueToBadActionURL) { |
531 PasswordFormBuilder builder("invalid_target"); | 540 PasswordFormBuilder builder("invalid_target"); |
532 builder.AddUsernameField("username", "JohnSmith", NULL); | 541 builder.AddUsernameField("username", "JohnSmith", NULL); |
533 builder.AddSubmitButton("submit", true); | 542 builder.AddSubmitButton("submit", true); |
534 builder.AddPasswordField("password", "secret", NULL); | 543 builder.AddPasswordField("password", "secret", NULL); |
535 std::string html = builder.ProduceHTML(); | 544 std::string html = builder.ProduceHTML(); |
536 | 545 |
537 scoped_ptr<PasswordForm> password_form; | 546 scoped_ptr<PasswordForm> password_form; |
538 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); | 547 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); |
539 EXPECT_FALSE(password_form); | 548 EXPECT_FALSE(password_form); |
540 } | 549 } |
541 | 550 |
542 TEST_F(PasswordFormConversionUtilsTest, InvalidFormDueToNoPasswordFields) { | 551 TEST_F(MAYBE_PasswordFormConversionUtilsTest, |
| 552 InvalidFormDueToNoPasswordFields) { |
543 PasswordFormBuilder builder(kTestFormActionURL); | 553 PasswordFormBuilder builder(kTestFormActionURL); |
544 builder.AddUsernameField("username1", "John", NULL); | 554 builder.AddUsernameField("username1", "John", NULL); |
545 builder.AddUsernameField("username2", "Smith", NULL); | 555 builder.AddUsernameField("username2", "Smith", NULL); |
546 builder.AddSubmitButton("submit", true); | 556 builder.AddSubmitButton("submit", true); |
547 std::string html = builder.ProduceHTML(); | 557 std::string html = builder.ProduceHTML(); |
548 | 558 |
549 scoped_ptr<PasswordForm> password_form; | 559 scoped_ptr<PasswordForm> password_form; |
550 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); | 560 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); |
551 EXPECT_FALSE(password_form); | 561 EXPECT_FALSE(password_form); |
552 } | 562 } |
553 | 563 |
554 TEST_F(PasswordFormConversionUtilsTest, | 564 TEST_F(MAYBE_PasswordFormConversionUtilsTest, |
555 InvalidFormsDueToConfusingPasswordFields) { | 565 InvalidFormsDueToConfusingPasswordFields) { |
556 // Each test case consists of a set of parameters to be plugged into the | 566 // Each test case consists of a set of parameters to be plugged into the |
557 // PasswordFormBuilder below. | 567 // PasswordFormBuilder below. |
558 const char* cases[][3] = { | 568 const char* cases[][3] = { |
559 // No autocomplete attributes to guide us, and we see: | 569 // No autocomplete attributes to guide us, and we see: |
560 // * three password values that are all different, | 570 // * three password values that are all different, |
561 // * three password values that are all the same; | 571 // * three password values that are all the same; |
562 // * three password values with the first and last matching. | 572 // * three password values with the first and last matching. |
563 // In any case, we should just give up on this form. | 573 // In any case, we should just give up on this form. |
564 {"alpha", "beta", "gamma"}, | 574 {"alpha", "beta", "gamma"}, |
(...skipping 10 matching lines...) Expand all Loading... |
575 builder.AddPasswordField("password3", cases[i][2], NULL); | 585 builder.AddPasswordField("password3", cases[i][2], NULL); |
576 builder.AddSubmitButton("submit", true); | 586 builder.AddSubmitButton("submit", true); |
577 std::string html = builder.ProduceHTML(); | 587 std::string html = builder.ProduceHTML(); |
578 | 588 |
579 scoped_ptr<PasswordForm> password_form; | 589 scoped_ptr<PasswordForm> password_form; |
580 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); | 590 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); |
581 EXPECT_FALSE(password_form); | 591 EXPECT_FALSE(password_form); |
582 } | 592 } |
583 } | 593 } |
584 | 594 |
585 TEST_F(PasswordFormConversionUtilsTest, | 595 TEST_F(MAYBE_PasswordFormConversionUtilsTest, |
586 InvalidFormDueToTooManyPasswordFieldsWithoutAutocompleteAttributes) { | 596 InvalidFormDueToTooManyPasswordFieldsWithoutAutocompleteAttributes) { |
587 PasswordFormBuilder builder(kTestFormActionURL); | 597 PasswordFormBuilder builder(kTestFormActionURL); |
588 builder.AddUsernameField("username1", "John", NULL); | 598 builder.AddUsernameField("username1", "John", NULL); |
589 builder.AddPasswordField("password1", "alpha", NULL); | 599 builder.AddPasswordField("password1", "alpha", NULL); |
590 builder.AddPasswordField("password2", "alpha", NULL); | 600 builder.AddPasswordField("password2", "alpha", NULL); |
591 builder.AddPasswordField("password3", "alpha", NULL); | 601 builder.AddPasswordField("password3", "alpha", NULL); |
592 builder.AddPasswordField("password4", "alpha", NULL); | 602 builder.AddPasswordField("password4", "alpha", NULL); |
593 builder.AddSubmitButton("submit", true); | 603 builder.AddSubmitButton("submit", true); |
594 std::string html = builder.ProduceHTML(); | 604 std::string html = builder.ProduceHTML(); |
595 | 605 |
596 scoped_ptr<PasswordForm> password_form; | 606 scoped_ptr<PasswordForm> password_form; |
597 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); | 607 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); |
598 EXPECT_FALSE(password_form); | 608 EXPECT_FALSE(password_form); |
599 } | 609 } |
600 | 610 |
601 TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLogin) { | 611 TEST_F(MAYBE_PasswordFormConversionUtilsTest, LayoutClassificationLogin) { |
602 PasswordFormBuilder builder(kTestFormActionURL); | 612 PasswordFormBuilder builder(kTestFormActionURL); |
603 builder.AddHiddenField(); | 613 builder.AddHiddenField(); |
604 builder.AddUsernameField("username", "", nullptr); | 614 builder.AddUsernameField("username", "", nullptr); |
605 builder.AddPasswordField("password", "", nullptr); | 615 builder.AddPasswordField("password", "", nullptr); |
606 builder.AddSubmitButton("submit", false); | 616 builder.AddSubmitButton("submit", false); |
607 std::string login_html = builder.ProduceHTML(); | 617 std::string login_html = builder.ProduceHTML(); |
608 | 618 |
609 scoped_ptr<PasswordForm> login_form; | 619 scoped_ptr<PasswordForm> login_form; |
610 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(login_html, &login_form)); | 620 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(login_html, &login_form)); |
611 ASSERT_TRUE(login_form); | 621 ASSERT_TRUE(login_form); |
612 EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, login_form->layout); | 622 EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, login_form->layout); |
613 } | 623 } |
614 | 624 |
615 TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationSignup) { | 625 TEST_F(MAYBE_PasswordFormConversionUtilsTest, LayoutClassificationSignup) { |
616 PasswordFormBuilder builder(kTestFormActionURL); | 626 PasswordFormBuilder builder(kTestFormActionURL); |
617 builder.AddUsernameField("someotherfield", "", nullptr); | 627 builder.AddUsernameField("someotherfield", "", nullptr); |
618 builder.AddUsernameField("username", "", nullptr); | 628 builder.AddUsernameField("username", "", nullptr); |
619 builder.AddPasswordField("new_password", "", nullptr); | 629 builder.AddPasswordField("new_password", "", nullptr); |
620 builder.AddHiddenField(); | 630 builder.AddHiddenField(); |
621 builder.AddPasswordField("new_password2", "", nullptr); | 631 builder.AddPasswordField("new_password2", "", nullptr); |
622 builder.AddSubmitButton("submit", false); | 632 builder.AddSubmitButton("submit", false); |
623 std::string signup_html = builder.ProduceHTML(); | 633 std::string signup_html = builder.ProduceHTML(); |
624 | 634 |
625 scoped_ptr<PasswordForm> signup_form; | 635 scoped_ptr<PasswordForm> signup_form; |
626 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(signup_html, &signup_form)); | 636 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(signup_html, &signup_form)); |
627 ASSERT_TRUE(signup_form); | 637 ASSERT_TRUE(signup_form); |
628 EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, signup_form->layout); | 638 EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, signup_form->layout); |
629 } | 639 } |
630 | 640 |
631 TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationChange) { | 641 TEST_F(MAYBE_PasswordFormConversionUtilsTest, LayoutClassificationChange) { |
632 PasswordFormBuilder builder(kTestFormActionURL); | 642 PasswordFormBuilder builder(kTestFormActionURL); |
633 builder.AddUsernameField("username", "", nullptr); | 643 builder.AddUsernameField("username", "", nullptr); |
634 builder.AddPasswordField("old_password", "", nullptr); | 644 builder.AddPasswordField("old_password", "", nullptr); |
635 builder.AddHiddenField(); | 645 builder.AddHiddenField(); |
636 builder.AddPasswordField("new_password", "", nullptr); | 646 builder.AddPasswordField("new_password", "", nullptr); |
637 builder.AddPasswordField("new_password2", "", nullptr); | 647 builder.AddPasswordField("new_password2", "", nullptr); |
638 builder.AddSubmitButton("submit", false); | 648 builder.AddSubmitButton("submit", false); |
639 std::string change_html = builder.ProduceHTML(); | 649 std::string change_html = builder.ProduceHTML(); |
640 | 650 |
641 scoped_ptr<PasswordForm> change_form; | 651 scoped_ptr<PasswordForm> change_form; |
642 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(change_html, &change_form)); | 652 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(change_html, &change_form)); |
643 ASSERT_TRUE(change_form); | 653 ASSERT_TRUE(change_form); |
644 EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, change_form->layout); | 654 EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, change_form->layout); |
645 } | 655 } |
646 | 656 |
647 TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLoginPlusSignup_A) { | 657 TEST_F(MAYBE_PasswordFormConversionUtilsTest, |
| 658 LayoutClassificationLoginPlusSignup_A) { |
648 PasswordFormBuilder builder(kTestFormActionURL); | 659 PasswordFormBuilder builder(kTestFormActionURL); |
649 builder.AddUsernameField("username", "", nullptr); | 660 builder.AddUsernameField("username", "", nullptr); |
650 builder.AddHiddenField(); | 661 builder.AddHiddenField(); |
651 builder.AddPasswordField("password", "", nullptr); | 662 builder.AddPasswordField("password", "", nullptr); |
652 builder.AddUsernameField("username2", "", nullptr); | 663 builder.AddUsernameField("username2", "", nullptr); |
653 builder.AddUsernameField("someotherfield", "", nullptr); | 664 builder.AddUsernameField("someotherfield", "", nullptr); |
654 builder.AddPasswordField("new_password", "", nullptr); | 665 builder.AddPasswordField("new_password", "", nullptr); |
655 builder.AddPasswordField("new_password2", "", nullptr); | 666 builder.AddPasswordField("new_password2", "", nullptr); |
656 builder.AddHiddenField(); | 667 builder.AddHiddenField(); |
657 builder.AddSubmitButton("submit", false); | 668 builder.AddSubmitButton("submit", false); |
658 std::string login_plus_signup_html = builder.ProduceHTML(); | 669 std::string login_plus_signup_html = builder.ProduceHTML(); |
659 | 670 |
660 scoped_ptr<PasswordForm> login_plus_signup_form; | 671 scoped_ptr<PasswordForm> login_plus_signup_form; |
661 ASSERT_NO_FATAL_FAILURE( | 672 ASSERT_NO_FATAL_FAILURE( |
662 LoadHTMLAndConvertForm(login_plus_signup_html, &login_plus_signup_form)); | 673 LoadHTMLAndConvertForm(login_plus_signup_html, &login_plus_signup_form)); |
663 ASSERT_TRUE(login_plus_signup_form); | 674 ASSERT_TRUE(login_plus_signup_form); |
664 EXPECT_EQ(PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP, | 675 EXPECT_EQ(PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP, |
665 login_plus_signup_form->layout); | 676 login_plus_signup_form->layout); |
666 } | 677 } |
667 | 678 |
668 TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLoginPlusSignup_B) { | 679 TEST_F(MAYBE_PasswordFormConversionUtilsTest, |
| 680 LayoutClassificationLoginPlusSignup_B) { |
669 PasswordFormBuilder builder(kTestFormActionURL); | 681 PasswordFormBuilder builder(kTestFormActionURL); |
670 builder.AddUsernameField("username", "", nullptr); | 682 builder.AddUsernameField("username", "", nullptr); |
671 builder.AddHiddenField(); | 683 builder.AddHiddenField(); |
672 builder.AddPasswordField("password", "", nullptr); | 684 builder.AddPasswordField("password", "", nullptr); |
673 builder.AddUsernameField("username2", "", nullptr); | 685 builder.AddUsernameField("username2", "", nullptr); |
674 builder.AddUsernameField("someotherfield", "", nullptr); | 686 builder.AddUsernameField("someotherfield", "", nullptr); |
675 builder.AddPasswordField("new_password", "", nullptr); | 687 builder.AddPasswordField("new_password", "", nullptr); |
676 builder.AddUsernameField("someotherfield2", "", nullptr); | 688 builder.AddUsernameField("someotherfield2", "", nullptr); |
677 builder.AddHiddenField(); | 689 builder.AddHiddenField(); |
678 builder.AddSubmitButton("submit", false); | 690 builder.AddSubmitButton("submit", false); |
679 std::string login_plus_signup_html = builder.ProduceHTML(); | 691 std::string login_plus_signup_html = builder.ProduceHTML(); |
680 | 692 |
681 scoped_ptr<PasswordForm> login_plus_signup_form; | 693 scoped_ptr<PasswordForm> login_plus_signup_form; |
682 ASSERT_NO_FATAL_FAILURE( | 694 ASSERT_NO_FATAL_FAILURE( |
683 LoadHTMLAndConvertForm(login_plus_signup_html, &login_plus_signup_form)); | 695 LoadHTMLAndConvertForm(login_plus_signup_html, &login_plus_signup_form)); |
684 ASSERT_TRUE(login_plus_signup_form); | 696 ASSERT_TRUE(login_plus_signup_form); |
685 EXPECT_EQ(PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP, | 697 EXPECT_EQ(PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP, |
686 login_plus_signup_form->layout); | 698 login_plus_signup_form->layout); |
687 } | 699 } |
688 | 700 |
689 } // namespace autofill | 701 } // namespace autofill |
OLD | NEW |