| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 const std::vector<std::string>& control_types) { | 188 const std::vector<std::string>& control_types) { |
| 189 ASSERT_EQ(labels.size(), names.size()); | 189 ASSERT_EQ(labels.size(), names.size()); |
| 190 ASSERT_EQ(labels.size(), values.size()); | 190 ASSERT_EQ(labels.size(), values.size()); |
| 191 ASSERT_EQ(labels.size(), control_types.size()); | 191 ASSERT_EQ(labels.size(), control_types.size()); |
| 192 | 192 |
| 193 LoadHTML(html); | 193 LoadHTML(html); |
| 194 | 194 |
| 195 WebFrame* web_frame = GetMainFrame(); | 195 WebFrame* web_frame = GetMainFrame(); |
| 196 ASSERT_NE(nullptr, web_frame); | 196 ASSERT_NE(nullptr, web_frame); |
| 197 | 197 |
| 198 FormCache form_cache; | 198 FormCache form_cache(*web_frame); |
| 199 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 199 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 200 ASSERT_EQ(1U, forms.size()); | 200 ASSERT_EQ(1U, forms.size()); |
| 201 | 201 |
| 202 const FormData& form = forms[0]; | 202 const FormData& form = forms[0]; |
| 203 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 203 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 204 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 204 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 205 EXPECT_EQ(GURL("http://cnn.com"), form.action); | 205 EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| 206 | 206 |
| 207 const std::vector<FormFieldData>& fields = form.fields; | 207 const std::vector<FormFieldData>& fields = form.fields; |
| 208 ASSERT_EQ(labels.size(), fields.size()); | 208 ASSERT_EQ(labels.size(), fields.size()); |
| 209 for (size_t i = 0; i < labels.size(); ++i) { | 209 for (size_t i = 0; i < labels.size(); ++i) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 bool unowned, | 248 bool unowned, |
| 249 const AutofillFieldCase* field_cases, | 249 const AutofillFieldCase* field_cases, |
| 250 size_t number_of_field_cases, | 250 size_t number_of_field_cases, |
| 251 FillFormFunction fill_form_function, | 251 FillFormFunction fill_form_function, |
| 252 GetValueFunction get_value_function) { | 252 GetValueFunction get_value_function) { |
| 253 LoadHTML(html); | 253 LoadHTML(html); |
| 254 | 254 |
| 255 WebFrame* web_frame = GetMainFrame(); | 255 WebFrame* web_frame = GetMainFrame(); |
| 256 ASSERT_NE(nullptr, web_frame); | 256 ASSERT_NE(nullptr, web_frame); |
| 257 | 257 |
| 258 FormCache form_cache; | 258 FormCache form_cache(*web_frame); |
| 259 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 259 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 260 ASSERT_EQ(1U, forms.size()); | 260 ASSERT_EQ(1U, forms.size()); |
| 261 | 261 |
| 262 // Get the input element we want to find. | 262 // Get the input element we want to find. |
| 263 WebInputElement input_element = GetInputElementById("firstname"); | 263 WebInputElement input_element = GetInputElementById("firstname"); |
| 264 | 264 |
| 265 // Find the form that contains the input element. | 265 // Find the form that contains the input element. |
| 266 FormData form_data; | 266 FormData form_data; |
| 267 FormFieldData field; | 267 FormFieldData field; |
| 268 EXPECT_TRUE(FindFormAndFieldForFormControlElement( | 268 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| 269 input_element, &form_data, &field, REQUIRE_NONE)); | 269 input_element, &form_data, &field, REQUIRE_NONE)); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 WebInputElement firstname = GetInputElementById("firstname"); | 479 WebInputElement firstname = GetInputElementById("firstname"); |
| 480 EXPECT_EQ(0, firstname.selectionStart()); | 480 EXPECT_EQ(0, firstname.selectionStart()); |
| 481 EXPECT_EQ(19, firstname.selectionEnd()); | 481 EXPECT_EQ(19, firstname.selectionEnd()); |
| 482 } | 482 } |
| 483 | 483 |
| 484 void TestFindFormForInputElement(const char* html, bool unowned) { | 484 void TestFindFormForInputElement(const char* html, bool unowned) { |
| 485 LoadHTML(html); | 485 LoadHTML(html); |
| 486 WebFrame* web_frame = GetMainFrame(); | 486 WebFrame* web_frame = GetMainFrame(); |
| 487 ASSERT_NE(nullptr, web_frame); | 487 ASSERT_NE(nullptr, web_frame); |
| 488 | 488 |
| 489 FormCache form_cache; | 489 FormCache form_cache(*web_frame); |
| 490 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 490 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 491 ASSERT_EQ(1U, forms.size()); | 491 ASSERT_EQ(1U, forms.size()); |
| 492 | 492 |
| 493 // Get the input element we want to find. | 493 // Get the input element we want to find. |
| 494 WebInputElement input_element = GetInputElementById("firstname"); | 494 WebInputElement input_element = GetInputElementById("firstname"); |
| 495 | 495 |
| 496 // Find the form and verify it's the correct form. | 496 // Find the form and verify it's the correct form. |
| 497 FormData form; | 497 FormData form; |
| 498 FormFieldData field; | 498 FormFieldData field; |
| 499 EXPECT_TRUE(FindFormAndFieldForFormControlElement( | 499 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| 500 input_element, &form, &field, REQUIRE_NONE)); | 500 input_element, &form, &field, REQUIRE_NONE)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 expected.name = ASCIIToUTF16("phone"); | 559 expected.name = ASCIIToUTF16("phone"); |
| 560 expected.value = ASCIIToUTF16("1.800.555.1234"); | 560 expected.value = ASCIIToUTF16("1.800.555.1234"); |
| 561 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 561 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 562 } | 562 } |
| 563 | 563 |
| 564 void TestFindFormForTextAreaElement(const char* html, bool unowned) { | 564 void TestFindFormForTextAreaElement(const char* html, bool unowned) { |
| 565 LoadHTML(html); | 565 LoadHTML(html); |
| 566 WebFrame* web_frame = GetMainFrame(); | 566 WebFrame* web_frame = GetMainFrame(); |
| 567 ASSERT_NE(nullptr, web_frame); | 567 ASSERT_NE(nullptr, web_frame); |
| 568 | 568 |
| 569 FormCache form_cache; | 569 FormCache form_cache(*web_frame); |
| 570 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 570 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 571 ASSERT_EQ(1U, forms.size()); | 571 ASSERT_EQ(1U, forms.size()); |
| 572 | 572 |
| 573 // Get the textarea element we want to find. | 573 // Get the textarea element we want to find. |
| 574 WebElement element = web_frame->document().getElementById("street-address"); | 574 WebElement element = web_frame->document().getElementById("street-address"); |
| 575 WebTextAreaElement textarea_element = element.to<WebTextAreaElement>(); | 575 WebTextAreaElement textarea_element = element.to<WebTextAreaElement>(); |
| 576 | 576 |
| 577 // Find the form and verify it's the correct form. | 577 // Find the form and verify it's the correct form. |
| 578 FormData form; | 578 FormData form; |
| 579 FormFieldData field; | 579 FormFieldData field; |
| 580 EXPECT_TRUE(FindFormAndFieldForFormControlElement( | 580 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 expected.max_length = 0; | 649 expected.max_length = 0; |
| 650 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 650 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 651 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); | 651 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); |
| 652 } | 652 } |
| 653 | 653 |
| 654 void TestFillFormMaxLength(const char* html, bool unowned) { | 654 void TestFillFormMaxLength(const char* html, bool unowned) { |
| 655 LoadHTML(html); | 655 LoadHTML(html); |
| 656 WebFrame* web_frame = GetMainFrame(); | 656 WebFrame* web_frame = GetMainFrame(); |
| 657 ASSERT_NE(nullptr, web_frame); | 657 ASSERT_NE(nullptr, web_frame); |
| 658 | 658 |
| 659 FormCache form_cache; | 659 FormCache form_cache(*web_frame); |
| 660 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 660 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 661 ASSERT_EQ(1U, forms.size()); | 661 ASSERT_EQ(1U, forms.size()); |
| 662 | 662 |
| 663 // Get the input element we want to find. | 663 // Get the input element we want to find. |
| 664 WebInputElement input_element = GetInputElementById("firstname"); | 664 WebInputElement input_element = GetInputElementById("firstname"); |
| 665 | 665 |
| 666 // Find the form that contains the input element. | 666 // Find the form that contains the input element. |
| 667 FormData form; | 667 FormData form; |
| 668 FormFieldData field; | 668 FormFieldData field; |
| 669 EXPECT_TRUE(FindFormAndFieldForFormControlElement( | 669 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| 670 input_element, &form, &field, REQUIRE_NONE)); | 670 input_element, &form, &field, REQUIRE_NONE)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 expected.max_length = 9; | 737 expected.max_length = 9; |
| 738 expected.is_autofilled = true; | 738 expected.is_autofilled = true; |
| 739 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 739 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 740 } | 740 } |
| 741 | 741 |
| 742 void TestFillFormNegativeMaxLength(const char* html, bool unowned) { | 742 void TestFillFormNegativeMaxLength(const char* html, bool unowned) { |
| 743 LoadHTML(html); | 743 LoadHTML(html); |
| 744 WebFrame* web_frame = GetMainFrame(); | 744 WebFrame* web_frame = GetMainFrame(); |
| 745 ASSERT_NE(nullptr, web_frame); | 745 ASSERT_NE(nullptr, web_frame); |
| 746 | 746 |
| 747 FormCache form_cache; | 747 FormCache form_cache(*web_frame); |
| 748 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 748 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 749 ASSERT_EQ(1U, forms.size()); | 749 ASSERT_EQ(1U, forms.size()); |
| 750 | 750 |
| 751 // Get the input element we want to find. | 751 // Get the input element we want to find. |
| 752 WebInputElement input_element = GetInputElementById("firstname"); | 752 WebInputElement input_element = GetInputElementById("firstname"); |
| 753 | 753 |
| 754 // Find the form that contains the input element. | 754 // Find the form that contains the input element. |
| 755 FormData form; | 755 FormData form; |
| 756 FormFieldData field; | 756 FormFieldData field; |
| 757 EXPECT_TRUE(FindFormAndFieldForFormControlElement( | 757 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| 758 input_element, &form, &field, REQUIRE_NONE)); | 758 input_element, &form, &field, REQUIRE_NONE)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 expected.name = ASCIIToUTF16("email"); | 809 expected.name = ASCIIToUTF16("email"); |
| 810 expected.value = ASCIIToUTF16("brotherj@example.com"); | 810 expected.value = ASCIIToUTF16("brotherj@example.com"); |
| 811 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 811 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 812 } | 812 } |
| 813 | 813 |
| 814 void TestFillFormEmptyName(const char* html, bool unowned) { | 814 void TestFillFormEmptyName(const char* html, bool unowned) { |
| 815 LoadHTML(html); | 815 LoadHTML(html); |
| 816 WebFrame* web_frame = GetMainFrame(); | 816 WebFrame* web_frame = GetMainFrame(); |
| 817 ASSERT_NE(nullptr, web_frame); | 817 ASSERT_NE(nullptr, web_frame); |
| 818 | 818 |
| 819 FormCache form_cache; | 819 FormCache form_cache(*web_frame); |
| 820 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 820 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 821 ASSERT_EQ(1U, forms.size()); | 821 ASSERT_EQ(1U, forms.size()); |
| 822 | 822 |
| 823 // Get the input element we want to find. | 823 // Get the input element we want to find. |
| 824 WebInputElement input_element = GetInputElementById("firstname"); | 824 WebInputElement input_element = GetInputElementById("firstname"); |
| 825 | 825 |
| 826 // Find the form that contains the input element. | 826 // Find the form that contains the input element. |
| 827 FormData form; | 827 FormData form; |
| 828 FormFieldData field; | 828 FormFieldData field; |
| 829 EXPECT_TRUE(FindFormAndFieldForFormControlElement( | 829 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| 830 input_element, &form, &field, REQUIRE_NONE)); | 830 input_element, &form, &field, REQUIRE_NONE)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 expected.name = ASCIIToUTF16("email"); | 884 expected.name = ASCIIToUTF16("email"); |
| 885 expected.value = ASCIIToUTF16("wyatt@example.com"); | 885 expected.value = ASCIIToUTF16("wyatt@example.com"); |
| 886 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 886 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 887 } | 887 } |
| 888 | 888 |
| 889 void TestFillFormEmptyFormNames(const char* html, bool unowned) { | 889 void TestFillFormEmptyFormNames(const char* html, bool unowned) { |
| 890 LoadHTML(html); | 890 LoadHTML(html); |
| 891 WebFrame* web_frame = GetMainFrame(); | 891 WebFrame* web_frame = GetMainFrame(); |
| 892 ASSERT_NE(nullptr, web_frame); | 892 ASSERT_NE(nullptr, web_frame); |
| 893 | 893 |
| 894 FormCache form_cache; | 894 FormCache form_cache(*web_frame); |
| 895 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 895 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 896 const size_t expected_size = unowned ? 1 : 2; | 896 const size_t expected_size = unowned ? 1 : 2; |
| 897 ASSERT_EQ(expected_size, forms.size()); | 897 ASSERT_EQ(expected_size, forms.size()); |
| 898 | 898 |
| 899 // Get the input element we want to find. | 899 // Get the input element we want to find. |
| 900 WebInputElement input_element = GetInputElementById("apple"); | 900 WebInputElement input_element = GetInputElementById("apple"); |
| 901 | 901 |
| 902 // Find the form that contains the input element. | 902 // Find the form that contains the input element. |
| 903 FormData form; | 903 FormData form; |
| 904 FormFieldData field; | 904 FormFieldData field; |
| 905 EXPECT_TRUE(FindFormAndFieldForFormControlElement( | 905 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 expected.value = ASCIIToUTF16("Also Yellow"); | 967 expected.value = ASCIIToUTF16("Also Yellow"); |
| 968 expected.is_autofilled = true; | 968 expected.is_autofilled = true; |
| 969 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[unowned_offset + 2]); | 969 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[unowned_offset + 2]); |
| 970 } | 970 } |
| 971 | 971 |
| 972 void TestFillFormNonEmptyField(const char* html, bool unowned) { | 972 void TestFillFormNonEmptyField(const char* html, bool unowned) { |
| 973 LoadHTML(html); | 973 LoadHTML(html); |
| 974 WebFrame* web_frame = GetMainFrame(); | 974 WebFrame* web_frame = GetMainFrame(); |
| 975 ASSERT_NE(nullptr, web_frame); | 975 ASSERT_NE(nullptr, web_frame); |
| 976 | 976 |
| 977 FormCache form_cache; | 977 FormCache form_cache(*web_frame); |
| 978 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 978 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 979 ASSERT_EQ(1U, forms.size()); | 979 ASSERT_EQ(1U, forms.size()); |
| 980 | 980 |
| 981 // Get the input element we want to find. | 981 // Get the input element we want to find. |
| 982 WebInputElement input_element = GetInputElementById("firstname"); | 982 WebInputElement input_element = GetInputElementById("firstname"); |
| 983 | 983 |
| 984 // Simulate typing by modifying the field value. | 984 // Simulate typing by modifying the field value. |
| 985 input_element.setValue(ASCIIToUTF16("Wy")); | 985 input_element.setValue(ASCIIToUTF16("Wy")); |
| 986 | 986 |
| 987 // Find the form that contains the input element. | 987 // Find the form that contains the input element. |
| 988 FormData form; | 988 FormData form; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 // Verify that the cursor position has been updated. | 1063 // Verify that the cursor position has been updated. |
| 1064 EXPECT_EQ(5, input_element.selectionStart()); | 1064 EXPECT_EQ(5, input_element.selectionStart()); |
| 1065 EXPECT_EQ(5, input_element.selectionEnd()); | 1065 EXPECT_EQ(5, input_element.selectionEnd()); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 void TestClearFormWithNode(const char* html, bool unowned) { | 1068 void TestClearFormWithNode(const char* html, bool unowned) { |
| 1069 LoadHTML(html); | 1069 LoadHTML(html); |
| 1070 WebFrame* web_frame = GetMainFrame(); | 1070 WebFrame* web_frame = GetMainFrame(); |
| 1071 ASSERT_NE(nullptr, web_frame); | 1071 ASSERT_NE(nullptr, web_frame); |
| 1072 | 1072 |
| 1073 FormCache form_cache; | 1073 FormCache form_cache(*web_frame); |
| 1074 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 1074 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 1075 ASSERT_EQ(1U, forms.size()); | 1075 ASSERT_EQ(1U, forms.size()); |
| 1076 | 1076 |
| 1077 // Set the auto-filled attribute. | 1077 // Set the auto-filled attribute. |
| 1078 WebInputElement firstname = GetInputElementById("firstname"); | 1078 WebInputElement firstname = GetInputElementById("firstname"); |
| 1079 firstname.setAutofilled(true); | 1079 firstname.setAutofilled(true); |
| 1080 WebInputElement lastname = GetInputElementById("lastname"); | 1080 WebInputElement lastname = GetInputElementById("lastname"); |
| 1081 lastname.setAutofilled(true); | 1081 lastname.setAutofilled(true); |
| 1082 WebInputElement month = GetInputElementById("month"); | 1082 WebInputElement month = GetInputElementById("month"); |
| 1083 month.setAutofilled(true); | 1083 month.setAutofilled(true); |
| 1084 WebInputElement textarea = GetInputElementById("textarea"); | 1084 WebInputElement textarea = GetInputElementById("textarea"); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 EXPECT_EQ(0, firstname.selectionStart()); | 1159 EXPECT_EQ(0, firstname.selectionStart()); |
| 1160 EXPECT_EQ(0, firstname.selectionEnd()); | 1160 EXPECT_EQ(0, firstname.selectionEnd()); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 void TestClearFormWithNodeContainingSelectOne(const char* html, | 1163 void TestClearFormWithNodeContainingSelectOne(const char* html, |
| 1164 bool unowned) { | 1164 bool unowned) { |
| 1165 LoadHTML(html); | 1165 LoadHTML(html); |
| 1166 WebFrame* web_frame = GetMainFrame(); | 1166 WebFrame* web_frame = GetMainFrame(); |
| 1167 ASSERT_NE(nullptr, web_frame); | 1167 ASSERT_NE(nullptr, web_frame); |
| 1168 | 1168 |
| 1169 FormCache form_cache; | 1169 FormCache form_cache(*web_frame); |
| 1170 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 1170 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 1171 ASSERT_EQ(1U, forms.size()); | 1171 ASSERT_EQ(1U, forms.size()); |
| 1172 | 1172 |
| 1173 // Set the auto-filled attribute. | 1173 // Set the auto-filled attribute. |
| 1174 WebInputElement firstname = GetInputElementById("firstname"); | 1174 WebInputElement firstname = GetInputElementById("firstname"); |
| 1175 firstname.setAutofilled(true); | 1175 firstname.setAutofilled(true); |
| 1176 WebInputElement lastname = GetInputElementById("lastname"); | 1176 WebInputElement lastname = GetInputElementById("lastname"); |
| 1177 lastname.setAutofilled(true); | 1177 lastname.setAutofilled(true); |
| 1178 | 1178 |
| 1179 // Set the value and auto-filled attribute of the state element. | 1179 // Set the value and auto-filled attribute of the state element. |
| 1180 WebSelectElement state = | 1180 WebSelectElement state = |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 // Verify that the cursor position has been updated. | 1225 // Verify that the cursor position has been updated. |
| 1226 EXPECT_EQ(0, firstname.selectionStart()); | 1226 EXPECT_EQ(0, firstname.selectionStart()); |
| 1227 EXPECT_EQ(0, firstname.selectionEnd()); | 1227 EXPECT_EQ(0, firstname.selectionEnd()); |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 void TestClearPreviewedFormWithElement(const char* html) { | 1230 void TestClearPreviewedFormWithElement(const char* html) { |
| 1231 LoadHTML(html); | 1231 LoadHTML(html); |
| 1232 WebFrame* web_frame = GetMainFrame(); | 1232 WebFrame* web_frame = GetMainFrame(); |
| 1233 ASSERT_NE(nullptr, web_frame); | 1233 ASSERT_NE(nullptr, web_frame); |
| 1234 | 1234 |
| 1235 FormCache form_cache; | 1235 FormCache form_cache(*web_frame); |
| 1236 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 1236 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 1237 ASSERT_EQ(1U, forms.size()); | 1237 ASSERT_EQ(1U, forms.size()); |
| 1238 | 1238 |
| 1239 // Set the auto-filled attribute. | 1239 // Set the auto-filled attribute. |
| 1240 WebInputElement firstname = GetInputElementById("firstname"); | 1240 WebInputElement firstname = GetInputElementById("firstname"); |
| 1241 firstname.setAutofilled(true); | 1241 firstname.setAutofilled(true); |
| 1242 WebInputElement lastname = GetInputElementById("lastname"); | 1242 WebInputElement lastname = GetInputElementById("lastname"); |
| 1243 lastname.setAutofilled(true); | 1243 lastname.setAutofilled(true); |
| 1244 WebInputElement email = GetInputElementById("email"); | 1244 WebInputElement email = GetInputElementById("email"); |
| 1245 email.setAutofilled(true); | 1245 email.setAutofilled(true); |
| 1246 WebInputElement email2 = GetInputElementById("email2"); | 1246 WebInputElement email2 = GetInputElementById("email2"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 // Verify that the cursor position has been updated. | 1279 // Verify that the cursor position has been updated. |
| 1280 EXPECT_EQ(0, lastname.selectionStart()); | 1280 EXPECT_EQ(0, lastname.selectionStart()); |
| 1281 EXPECT_EQ(0, lastname.selectionEnd()); | 1281 EXPECT_EQ(0, lastname.selectionEnd()); |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 void TestClearPreviewedFormWithNonEmptyInitiatingNode(const char* html) { | 1284 void TestClearPreviewedFormWithNonEmptyInitiatingNode(const char* html) { |
| 1285 LoadHTML(html); | 1285 LoadHTML(html); |
| 1286 WebFrame* web_frame = GetMainFrame(); | 1286 WebFrame* web_frame = GetMainFrame(); |
| 1287 ASSERT_NE(nullptr, web_frame); | 1287 ASSERT_NE(nullptr, web_frame); |
| 1288 | 1288 |
| 1289 FormCache form_cache; | 1289 FormCache form_cache(*web_frame); |
| 1290 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 1290 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 1291 ASSERT_EQ(1U, forms.size()); | 1291 ASSERT_EQ(1U, forms.size()); |
| 1292 | 1292 |
| 1293 // Set the auto-filled attribute. | 1293 // Set the auto-filled attribute. |
| 1294 WebInputElement firstname = GetInputElementById("firstname"); | 1294 WebInputElement firstname = GetInputElementById("firstname"); |
| 1295 firstname.setAutofilled(true); | 1295 firstname.setAutofilled(true); |
| 1296 WebInputElement lastname = GetInputElementById("lastname"); | 1296 WebInputElement lastname = GetInputElementById("lastname"); |
| 1297 lastname.setAutofilled(true); | 1297 lastname.setAutofilled(true); |
| 1298 WebInputElement email = GetInputElementById("email"); | 1298 WebInputElement email = GetInputElementById("email"); |
| 1299 email.setAutofilled(true); | 1299 email.setAutofilled(true); |
| 1300 WebInputElement email2 = GetInputElementById("email2"); | 1300 WebInputElement email2 = GetInputElementById("email2"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 EXPECT_TRUE(phone.value().isEmpty()); | 1333 EXPECT_TRUE(phone.value().isEmpty()); |
| 1334 EXPECT_TRUE(phone.suggestedValue().isEmpty()); | 1334 EXPECT_TRUE(phone.suggestedValue().isEmpty()); |
| 1335 EXPECT_FALSE(phone.isAutofilled()); | 1335 EXPECT_FALSE(phone.isAutofilled()); |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 void TestClearPreviewedFormWithAutofilledInitiatingNode(const char* html) { | 1338 void TestClearPreviewedFormWithAutofilledInitiatingNode(const char* html) { |
| 1339 LoadHTML(html); | 1339 LoadHTML(html); |
| 1340 WebFrame* web_frame = GetMainFrame(); | 1340 WebFrame* web_frame = GetMainFrame(); |
| 1341 ASSERT_NE(nullptr, web_frame); | 1341 ASSERT_NE(nullptr, web_frame); |
| 1342 | 1342 |
| 1343 FormCache form_cache; | 1343 FormCache form_cache(*web_frame); |
| 1344 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 1344 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 1345 ASSERT_EQ(1U, forms.size()); | 1345 ASSERT_EQ(1U, forms.size()); |
| 1346 | 1346 |
| 1347 // Set the auto-filled attribute. | 1347 // Set the auto-filled attribute. |
| 1348 WebInputElement firstname = GetInputElementById("firstname"); | 1348 WebInputElement firstname = GetInputElementById("firstname"); |
| 1349 firstname.setAutofilled(true); | 1349 firstname.setAutofilled(true); |
| 1350 WebInputElement lastname = GetInputElementById("lastname"); | 1350 WebInputElement lastname = GetInputElementById("lastname"); |
| 1351 lastname.setAutofilled(true); | 1351 lastname.setAutofilled(true); |
| 1352 WebInputElement email = GetInputElementById("email"); | 1352 WebInputElement email = GetInputElementById("email"); |
| 1353 email.setAutofilled(true); | 1353 email.setAutofilled(true); |
| 1354 WebInputElement email2 = GetInputElementById("email2"); | 1354 WebInputElement email2 = GetInputElementById("email2"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 EXPECT_TRUE(phone.suggestedValue().isEmpty()); | 1387 EXPECT_TRUE(phone.suggestedValue().isEmpty()); |
| 1388 EXPECT_FALSE(phone.isAutofilled()); | 1388 EXPECT_FALSE(phone.isAutofilled()); |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 void TestClearOnlyAutofilledFields(const char* html) { | 1391 void TestClearOnlyAutofilledFields(const char* html) { |
| 1392 LoadHTML(html); | 1392 LoadHTML(html); |
| 1393 | 1393 |
| 1394 WebFrame* web_frame = GetMainFrame(); | 1394 WebFrame* web_frame = GetMainFrame(); |
| 1395 ASSERT_NE(nullptr, web_frame); | 1395 ASSERT_NE(nullptr, web_frame); |
| 1396 | 1396 |
| 1397 FormCache form_cache; | 1397 FormCache form_cache(*web_frame); |
| 1398 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 1398 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 1399 ASSERT_EQ(1U, forms.size()); | 1399 ASSERT_EQ(1U, forms.size()); |
| 1400 | 1400 |
| 1401 // Set the autofilled attribute. | 1401 // Set the autofilled attribute. |
| 1402 WebInputElement firstname = GetInputElementById("firstname"); | 1402 WebInputElement firstname = GetInputElementById("firstname"); |
| 1403 firstname.setAutofilled(false); | 1403 firstname.setAutofilled(false); |
| 1404 WebInputElement lastname = GetInputElementById("lastname"); | 1404 WebInputElement lastname = GetInputElementById("lastname"); |
| 1405 lastname.setAutofilled(true); | 1405 lastname.setAutofilled(true); |
| 1406 WebInputElement email = GetInputElementById("email"); | 1406 WebInputElement email = GetInputElementById("email"); |
| 1407 email.setAutofilled(true); | 1407 email.setAutofilled(true); |
| 1408 WebInputElement phone = GetInputElementById("phone"); | 1408 WebInputElement phone = GetInputElementById("phone"); |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 "<FORM name='TestForm2' action='http://zoo.com' method='post'>" | 2080 "<FORM name='TestForm2' action='http://zoo.com' method='post'>" |
| 2081 " <INPUT type='text' id='firstname' value='Jack'/>" | 2081 " <INPUT type='text' id='firstname' value='Jack'/>" |
| 2082 " <INPUT type='text' id='lastname' value='Adams'/>" | 2082 " <INPUT type='text' id='lastname' value='Adams'/>" |
| 2083 " <INPUT type='text' id='email' value='jack@example.com'/>" | 2083 " <INPUT type='text' id='email' value='jack@example.com'/>" |
| 2084 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2084 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2085 "</FORM>"); | 2085 "</FORM>"); |
| 2086 | 2086 |
| 2087 WebFrame* web_frame = GetMainFrame(); | 2087 WebFrame* web_frame = GetMainFrame(); |
| 2088 ASSERT_NE(nullptr, web_frame); | 2088 ASSERT_NE(nullptr, web_frame); |
| 2089 | 2089 |
| 2090 FormCache form_cache; | 2090 FormCache form_cache(*web_frame); |
| 2091 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 2091 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 2092 ASSERT_EQ(2U, forms.size()); | 2092 ASSERT_EQ(2U, forms.size()); |
| 2093 | 2093 |
| 2094 // First form. | 2094 // First form. |
| 2095 const FormData& form = forms[0]; | 2095 const FormData& form = forms[0]; |
| 2096 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 2096 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 2097 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2097 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 2098 EXPECT_EQ(GURL("http://cnn.com"), form.action); | 2098 EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| 2099 | 2099 |
| 2100 const std::vector<FormFieldData>& fields = form.fields; | 2100 const std::vector<FormFieldData>& fields = form.fields; |
| 2101 ASSERT_EQ(3U, fields.size()); | 2101 ASSERT_EQ(3U, fields.size()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2143 "<FORM id='testform' action='http://cnn.com' method='post'>" | 2143 "<FORM id='testform' action='http://cnn.com' method='post'>" |
| 2144 " <INPUT type='text' id='firstname' value='John'/>" | 2144 " <INPUT type='text' id='firstname' value='John'/>" |
| 2145 " <INPUT type='text' id='lastname' value='Smith'/>" | 2145 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 2146 " <INPUT type='text' id='email' value='john@example.com'/>" | 2146 " <INPUT type='text' id='email' value='john@example.com'/>" |
| 2147 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2147 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2148 "</FORM>"); | 2148 "</FORM>"); |
| 2149 | 2149 |
| 2150 WebFrame* web_frame = GetMainFrame(); | 2150 WebFrame* web_frame = GetMainFrame(); |
| 2151 ASSERT_NE(nullptr, web_frame); | 2151 ASSERT_NE(nullptr, web_frame); |
| 2152 | 2152 |
| 2153 FormCache form_cache; | 2153 FormCache form_cache(*web_frame); |
| 2154 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 2154 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 2155 ASSERT_EQ(1U, forms.size()); | 2155 ASSERT_EQ(1U, forms.size()); |
| 2156 | 2156 |
| 2157 // Second call should give nothing as there are no new forms. | 2157 // Second call should give nothing as there are no new forms. |
| 2158 forms = form_cache.ExtractNewForms(*web_frame); | 2158 forms = form_cache.ExtractNewForms(); |
| 2159 ASSERT_TRUE(forms.empty()); | 2159 ASSERT_TRUE(forms.empty()); |
| 2160 | 2160 |
| 2161 // Append to the current form will re-extract. | 2161 // Append to the current form will re-extract. |
| 2162 ExecuteJavaScript( | 2162 ExecuteJavaScript( |
| 2163 "var newInput = document.createElement('input');" | 2163 "var newInput = document.createElement('input');" |
| 2164 "newInput.setAttribute('type', 'text');" | 2164 "newInput.setAttribute('type', 'text');" |
| 2165 "newInput.setAttribute('id', 'telephone');" | 2165 "newInput.setAttribute('id', 'telephone');" |
| 2166 "newInput.value = '12345';" | 2166 "newInput.value = '12345';" |
| 2167 "document.getElementById('testform').appendChild(newInput);"); | 2167 "document.getElementById('testform').appendChild(newInput);"); |
| 2168 msg_loop_.RunUntilIdle(); | 2168 msg_loop_.RunUntilIdle(); |
| 2169 | 2169 |
| 2170 forms = form_cache.ExtractNewForms(*web_frame); | 2170 forms = form_cache.ExtractNewForms(); |
| 2171 ASSERT_EQ(1U, forms.size()); | 2171 ASSERT_EQ(1U, forms.size()); |
| 2172 | 2172 |
| 2173 const std::vector<FormFieldData>& fields = forms[0].fields; | 2173 const std::vector<FormFieldData>& fields = forms[0].fields; |
| 2174 ASSERT_EQ(4U, fields.size()); | 2174 ASSERT_EQ(4U, fields.size()); |
| 2175 | 2175 |
| 2176 FormFieldData expected; | 2176 FormFieldData expected; |
| 2177 expected.form_control_type = "text"; | 2177 expected.form_control_type = "text"; |
| 2178 expected.max_length = WebInputElement::defaultMaxLength(); | 2178 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2179 | 2179 |
| 2180 expected.name = ASCIIToUTF16("firstname"); | 2180 expected.name = ASCIIToUTF16("firstname"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 "newEmail.setAttribute('type', 'text');" | 2213 "newEmail.setAttribute('type', 'text');" |
| 2214 "newEmail.setAttribute('id', 'second_email');" | 2214 "newEmail.setAttribute('id', 'second_email');" |
| 2215 "newEmail.value = 'bobhope@example.com';" | 2215 "newEmail.value = 'bobhope@example.com';" |
| 2216 "newForm.appendChild(newFirstname);" | 2216 "newForm.appendChild(newFirstname);" |
| 2217 "newForm.appendChild(newLastname);" | 2217 "newForm.appendChild(newLastname);" |
| 2218 "newForm.appendChild(newEmail);" | 2218 "newForm.appendChild(newEmail);" |
| 2219 "document.body.appendChild(newForm);"); | 2219 "document.body.appendChild(newForm);"); |
| 2220 msg_loop_.RunUntilIdle(); | 2220 msg_loop_.RunUntilIdle(); |
| 2221 | 2221 |
| 2222 web_frame = GetMainFrame(); | 2222 web_frame = GetMainFrame(); |
| 2223 forms = form_cache.ExtractNewForms(*web_frame); | 2223 forms = form_cache.ExtractNewForms(); |
| 2224 ASSERT_EQ(1U, forms.size()); | 2224 ASSERT_EQ(1U, forms.size()); |
| 2225 | 2225 |
| 2226 const std::vector<FormFieldData>& fields2 = forms[0].fields; | 2226 const std::vector<FormFieldData>& fields2 = forms[0].fields; |
| 2227 ASSERT_EQ(3U, fields2.size()); | 2227 ASSERT_EQ(3U, fields2.size()); |
| 2228 | 2228 |
| 2229 expected.name = ASCIIToUTF16("second_firstname"); | 2229 expected.name = ASCIIToUTF16("second_firstname"); |
| 2230 expected.value = ASCIIToUTF16("Bob"); | 2230 expected.value = ASCIIToUTF16("Bob"); |
| 2231 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | 2231 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
| 2232 | 2232 |
| 2233 expected.name = ASCIIToUTF16("second_lastname"); | 2233 expected.name = ASCIIToUTF16("second_lastname"); |
| 2234 expected.value = ASCIIToUTF16("Hope"); | 2234 expected.value = ASCIIToUTF16("Hope"); |
| 2235 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); | 2235 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); |
| 2236 | 2236 |
| 2237 expected.name = ASCIIToUTF16("second_email"); | 2237 expected.name = ASCIIToUTF16("second_email"); |
| 2238 expected.value = ASCIIToUTF16("bobhope@example.com"); | 2238 expected.value = ASCIIToUTF16("bobhope@example.com"); |
| 2239 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 2239 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 2240 } | 2240 } |
| 2241 | 2241 |
| 2242 // We should not extract a form if it has too few fillable fields. | 2242 // We should not extract a form if it has too few fillable fields. |
| 2243 TEST_F(FormAutofillTest, ExtractFormsTooFewFields) { | 2243 TEST_F(FormAutofillTest, ExtractFormsTooFewFields) { |
| 2244 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" | 2244 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" |
| 2245 " <INPUT type='text' id='firstname' value='John'/>" | 2245 " <INPUT type='text' id='firstname' value='John'/>" |
| 2246 " <INPUT type='text' id='lastname' value='Smith'/>" | 2246 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 2247 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2247 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2248 "</FORM>"); | 2248 "</FORM>"); |
| 2249 | 2249 |
| 2250 WebFrame* web_frame = GetMainFrame(); | 2250 WebFrame* web_frame = GetMainFrame(); |
| 2251 ASSERT_NE(nullptr, web_frame); | 2251 ASSERT_NE(nullptr, web_frame); |
| 2252 | 2252 |
| 2253 FormCache form_cache; | 2253 FormCache form_cache(*web_frame); |
| 2254 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 2254 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 2255 ASSERT_TRUE(forms.empty()); | 2255 ASSERT_TRUE(forms.empty()); |
| 2256 } | 2256 } |
| 2257 | 2257 |
| 2258 // We should not report additional forms for empty forms. | 2258 // We should not report additional forms for empty forms. |
| 2259 TEST_F(FormAutofillTest, ExtractFormsSkippedForms) { | 2259 TEST_F(FormAutofillTest, ExtractFormsSkippedForms) { |
| 2260 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" | 2260 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" |
| 2261 " <INPUT type='text' id='firstname' value='John'/>" | 2261 " <INPUT type='text' id='firstname' value='John'/>" |
| 2262 " <INPUT type='text' id='lastname' value='Smith'/>" | 2262 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 2263 "</FORM>"); | 2263 "</FORM>"); |
| 2264 | 2264 |
| 2265 WebFrame* web_frame = GetMainFrame(); | 2265 WebFrame* web_frame = GetMainFrame(); |
| 2266 ASSERT_NE(nullptr, web_frame); | 2266 ASSERT_NE(nullptr, web_frame); |
| 2267 | 2267 |
| 2268 FormCache form_cache; | 2268 FormCache form_cache(*web_frame); |
| 2269 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 2269 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 2270 ASSERT_TRUE(forms.empty()); | 2270 ASSERT_TRUE(forms.empty()); |
| 2271 } | 2271 } |
| 2272 | 2272 |
| 2273 // We should not report additional forms for empty forms. | 2273 // We should not report additional forms for empty forms. |
| 2274 TEST_F(FormAutofillTest, ExtractFormsNoFields) { | 2274 TEST_F(FormAutofillTest, ExtractFormsNoFields) { |
| 2275 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" | 2275 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" |
| 2276 "</FORM>"); | 2276 "</FORM>"); |
| 2277 | 2277 |
| 2278 WebFrame* web_frame = GetMainFrame(); | 2278 WebFrame* web_frame = GetMainFrame(); |
| 2279 ASSERT_NE(nullptr, web_frame); | 2279 ASSERT_NE(nullptr, web_frame); |
| 2280 | 2280 |
| 2281 FormCache form_cache; | 2281 FormCache form_cache(*web_frame); |
| 2282 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 2282 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 2283 ASSERT_TRUE(forms.empty()); | 2283 ASSERT_TRUE(forms.empty()); |
| 2284 } | 2284 } |
| 2285 | 2285 |
| 2286 // We should not extract a form if it has too few fillable fields. | 2286 // We should not extract a form if it has too few fillable fields. |
| 2287 // Make sure radio and checkbox fields don't count. | 2287 // Make sure radio and checkbox fields don't count. |
| 2288 TEST_F(FormAutofillTest, ExtractFormsTooFewFieldsSkipsCheckable) { | 2288 TEST_F(FormAutofillTest, ExtractFormsTooFewFieldsSkipsCheckable) { |
| 2289 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" | 2289 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" |
| 2290 " <INPUT type='text' id='firstname' value='John'/>" | 2290 " <INPUT type='text' id='firstname' value='John'/>" |
| 2291 " <INPUT type='text' id='lastname' value='Smith'/>" | 2291 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 2292 " <INPUT type='radio' id='a_radio' value='0'/>" | 2292 " <INPUT type='radio' id='a_radio' value='0'/>" |
| 2293 " <INPUT type='checkbox' id='a_check' value='1'/>" | 2293 " <INPUT type='checkbox' id='a_check' value='1'/>" |
| 2294 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2294 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2295 "</FORM>"); | 2295 "</FORM>"); |
| 2296 | 2296 |
| 2297 WebFrame* web_frame = GetMainFrame(); | 2297 WebFrame* web_frame = GetMainFrame(); |
| 2298 ASSERT_NE(nullptr, web_frame); | 2298 ASSERT_NE(nullptr, web_frame); |
| 2299 | 2299 |
| 2300 FormCache form_cache; | 2300 FormCache form_cache(*web_frame); |
| 2301 std::vector<FormData> forms = form_cache.ExtractNewForms(*web_frame); | 2301 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 2302 ASSERT_TRUE(forms.empty()); | 2302 ASSERT_TRUE(forms.empty()); |
| 2303 } | 2303 } |
| 2304 | 2304 |
| 2305 TEST_F(FormAutofillTest, WebFormElementToFormDataAutocomplete) { | 2305 TEST_F(FormAutofillTest, WebFormElementToFormDataAutocomplete) { |
| 2306 { | 2306 { |
| 2307 // Form is not auto-completable due to autocomplete=off. | 2307 // Form is not auto-completable due to autocomplete=off. |
| 2308 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'" | 2308 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'" |
| 2309 " autocomplete=off>" | 2309 " autocomplete=off>" |
| 2310 " <INPUT type='text' id='firstname' value='John'/>" | 2310 " <INPUT type='text' id='firstname' value='John'/>" |
| 2311 " <INPUT type='text' id='lastname' value='Smith'/>" | 2311 " <INPUT type='text' id='lastname' value='Smith'/>" |
| (...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4086 ASSERT_TRUE(control_elements.empty()); | 4086 ASSERT_TRUE(control_elements.empty()); |
| 4087 ASSERT_TRUE(fieldsets.empty()); | 4087 ASSERT_TRUE(fieldsets.empty()); |
| 4088 | 4088 |
| 4089 FormData form; | 4089 FormData form; |
| 4090 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( | 4090 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( |
| 4091 fieldsets, control_elements, nullptr, dummy_origin, REQUIRE_NONE, | 4091 fieldsets, control_elements, nullptr, dummy_origin, REQUIRE_NONE, |
| 4092 extract_mask, &form, nullptr)); | 4092 extract_mask, &form, nullptr)); |
| 4093 } | 4093 } |
| 4094 | 4094 |
| 4095 } // namespace autofill | 4095 } // namespace autofill |
| OLD | NEW |