OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2322 EXPECT_TRUE(WebFormElementToFormData(web_form, WebFormControlElement(), | 2322 EXPECT_TRUE(WebFormElementToFormData(web_form, WebFormControlElement(), |
2323 EXTRACT_NONE, &form, nullptr)); | 2323 EXTRACT_NONE, &form, nullptr)); |
2324 | 2324 |
2325 ASSERT_EQ(3U, form.fields.size()); | 2325 ASSERT_EQ(3U, form.fields.size()); |
2326 | 2326 |
2327 EXPECT_FALSE(form.fields[0].should_autocomplete); | 2327 EXPECT_FALSE(form.fields[0].should_autocomplete); |
2328 EXPECT_TRUE(form.fields[1].should_autocomplete); | 2328 EXPECT_TRUE(form.fields[1].should_autocomplete); |
2329 EXPECT_TRUE(form.fields[2].should_autocomplete); | 2329 EXPECT_TRUE(form.fields[2].should_autocomplete); |
2330 } | 2330 } |
2331 | 2331 |
| 2332 // Tests CSS classes are set. |
| 2333 TEST_F(FormAutofillTest, WebFormElementToFormData_CssClasses) { |
| 2334 LoadHTML( |
| 2335 "<FORM name='TestForm' id='form' action='http://cnn.com' method='post' " |
| 2336 "autocomplete='off'>" |
| 2337 " <INPUT type='text' id='firstname' class='firstname_field' />" |
| 2338 " <INPUT type='text' id='lastname' class='lastname_field' />" |
| 2339 " <INPUT type='text' id='addressline1' />" |
| 2340 "</FORM>"); |
| 2341 |
| 2342 WebFrame* frame = GetMainFrame(); |
| 2343 ASSERT_NE(nullptr, frame); |
| 2344 |
| 2345 WebFormElement web_form = |
| 2346 frame->document().getElementById("form").to<WebFormElement>(); |
| 2347 ASSERT_FALSE(web_form.isNull()); |
| 2348 |
| 2349 FormData form; |
| 2350 EXPECT_TRUE(WebFormElementToFormData(web_form, WebFormControlElement(), |
| 2351 EXTRACT_NONE, &form, nullptr)); |
| 2352 |
| 2353 EXPECT_EQ(3U, form.fields.size()); |
| 2354 EXPECT_EQ(ASCIIToUTF16("firstname_field"), form.fields[0].css_classes); |
| 2355 EXPECT_EQ(ASCIIToUTF16("lastname_field"), form.fields[1].css_classes); |
| 2356 EXPECT_EQ(base::string16(), form.fields[2].css_classes); |
| 2357 } |
| 2358 |
2332 TEST_F(FormAutofillTest, ExtractForms) { | 2359 TEST_F(FormAutofillTest, ExtractForms) { |
2333 ExpectJohnSmithLabels( | 2360 ExpectJohnSmithLabels( |
2334 "<FORM name='TestForm' action='http://cnn.com' method='post'>" | 2361 "<FORM name='TestForm' action='http://cnn.com' method='post'>" |
2335 " First name: <INPUT type='text' id='firstname' value='John'/>" | 2362 " First name: <INPUT type='text' id='firstname' value='John'/>" |
2336 " Last name: <INPUT type='text' id='lastname' value='Smith'/>" | 2363 " Last name: <INPUT type='text' id='lastname' value='Smith'/>" |
2337 " Email: <INPUT type='text' id='email' value='john@example.com'/>" | 2364 " Email: <INPUT type='text' id='email' value='john@example.com'/>" |
2338 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2365 " <INPUT type='submit' name='reply-send' value='Send'/>" |
2339 "</FORM>"); | 2366 "</FORM>"); |
2340 } | 2367 } |
2341 | 2368 |
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4580 | 4607 |
4581 if (test_case.has_extracted_form) { | 4608 if (test_case.has_extracted_form) { |
4582 EXPECT_EQ(test_case.is_form_tag, forms[0].is_form_tag); | 4609 EXPECT_EQ(test_case.is_form_tag, forms[0].is_form_tag); |
4583 EXPECT_EQ(test_case.is_formless_checkout, forms[0].is_formless_checkout); | 4610 EXPECT_EQ(test_case.is_formless_checkout, forms[0].is_formless_checkout); |
4584 } | 4611 } |
4585 } | 4612 } |
4586 } | 4613 } |
4587 | 4614 |
4588 } // namespace form_util | 4615 } // namespace form_util |
4589 } // namespace autofill | 4616 } // namespace autofill |
OLD | NEW |