| 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/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 namespace autofill { | 87 namespace autofill { |
| 88 | 88 |
| 89 class FormAutofillTest : public ChromeRenderViewTest { | 89 class FormAutofillTest : public ChromeRenderViewTest { |
| 90 public: | 90 public: |
| 91 FormAutofillTest() : ChromeRenderViewTest() {} | 91 FormAutofillTest() : ChromeRenderViewTest() {} |
| 92 virtual ~FormAutofillTest() {} | 92 virtual ~FormAutofillTest() {} |
| 93 | 93 |
| 94 void ExpectLabels(const char* html, | 94 void ExpectLabels(const char* html, |
| 95 const std::vector<string16>& labels, | 95 const std::vector<base::string16>& labels, |
| 96 const std::vector<string16>& names, | 96 const std::vector<base::string16>& names, |
| 97 const std::vector<string16>& values) { | 97 const std::vector<base::string16>& values) { |
| 98 std::vector<std::string> control_types(labels.size(), "text"); | 98 std::vector<std::string> control_types(labels.size(), "text"); |
| 99 ExpectLabelsAndTypes(html, labels, names, values, control_types); | 99 ExpectLabelsAndTypes(html, labels, names, values, control_types); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void ExpectLabelsAndTypes(const char* html, | 102 void ExpectLabelsAndTypes(const char* html, |
| 103 const std::vector<string16>& labels, | 103 const std::vector<base::string16>& labels, |
| 104 const std::vector<string16>& names, | 104 const std::vector<base::string16>& names, |
| 105 const std::vector<string16>& values, | 105 const std::vector<base::string16>& values, |
| 106 const std::vector<std::string>& control_types) { | 106 const std::vector<std::string>& control_types) { |
| 107 ASSERT_EQ(labels.size(), names.size()); | 107 ASSERT_EQ(labels.size(), names.size()); |
| 108 ASSERT_EQ(labels.size(), values.size()); | 108 ASSERT_EQ(labels.size(), values.size()); |
| 109 ASSERT_EQ(labels.size(), control_types.size()); | 109 ASSERT_EQ(labels.size(), control_types.size()); |
| 110 | 110 |
| 111 LoadHTML(html); | 111 LoadHTML(html); |
| 112 | 112 |
| 113 WebFrame* web_frame = GetMainFrame(); | 113 WebFrame* web_frame = GetMainFrame(); |
| 114 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 114 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 115 | 115 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 133 expected.name = names[i]; | 133 expected.name = names[i]; |
| 134 expected.value = values[i]; | 134 expected.value = values[i]; |
| 135 expected.form_control_type = control_types[i]; | 135 expected.form_control_type = control_types[i]; |
| 136 expected.max_length = max_length; | 136 expected.max_length = max_length; |
| 137 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); | 137 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); |
| 138 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[i]); | 138 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[i]); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 void ExpectJohnSmithLabels(const char* html) { | 142 void ExpectJohnSmithLabels(const char* html) { |
| 143 std::vector<string16> labels, names, values; | 143 std::vector<base::string16> labels, names, values; |
| 144 | 144 |
| 145 labels.push_back(ASCIIToUTF16("First name:")); | 145 labels.push_back(ASCIIToUTF16("First name:")); |
| 146 names.push_back(ASCIIToUTF16("firstname")); | 146 names.push_back(ASCIIToUTF16("firstname")); |
| 147 values.push_back(ASCIIToUTF16("John")); | 147 values.push_back(ASCIIToUTF16("John")); |
| 148 | 148 |
| 149 labels.push_back(ASCIIToUTF16("Last name:")); | 149 labels.push_back(ASCIIToUTF16("Last name:")); |
| 150 names.push_back(ASCIIToUTF16("lastname")); | 150 names.push_back(ASCIIToUTF16("lastname")); |
| 151 values.push_back(ASCIIToUTF16("Smith")); | 151 values.push_back(ASCIIToUTF16("Smith")); |
| 152 | 152 |
| 153 labels.push_back(ASCIIToUTF16("Email:")); | 153 labels.push_back(ASCIIToUTF16("Email:")); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 WebElement web_element = frame->document().getElementById("element"); | 277 WebElement web_element = frame->document().getElementById("element"); |
| 278 WebFormControlElement element = web_element.to<WebFormControlElement>(); | 278 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| 279 FormFieldData result1; | 279 FormFieldData result1; |
| 280 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result1); | 280 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result1); |
| 281 | 281 |
| 282 FormFieldData expected; | 282 FormFieldData expected; |
| 283 expected.form_control_type = "text"; | 283 expected.form_control_type = "text"; |
| 284 expected.max_length = WebInputElement::defaultMaxLength(); | 284 expected.max_length = WebInputElement::defaultMaxLength(); |
| 285 | 285 |
| 286 expected.name = ASCIIToUTF16("element"); | 286 expected.name = ASCIIToUTF16("element"); |
| 287 expected.value = string16(); | 287 expected.value = base::string16(); |
| 288 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result1); | 288 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result1); |
| 289 | 289 |
| 290 FormFieldData result2; | 290 FormFieldData result2; |
| 291 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result2); | 291 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result2); |
| 292 | 292 |
| 293 expected.name = ASCIIToUTF16("element"); | 293 expected.name = ASCIIToUTF16("element"); |
| 294 expected.value = ASCIIToUTF16("value"); | 294 expected.value = ASCIIToUTF16("value"); |
| 295 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); | 295 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); |
| 296 } | 296 } |
| 297 | 297 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 element, | 425 element, |
| 426 static_cast<autofill::ExtractMask>(autofill::EXTRACT_VALUE | | 426 static_cast<autofill::ExtractMask>(autofill::EXTRACT_VALUE | |
| 427 autofill::EXTRACT_OPTION_TEXT), | 427 autofill::EXTRACT_OPTION_TEXT), |
| 428 &result2); | 428 &result2); |
| 429 expected.value = ASCIIToUTF16("California"); | 429 expected.value = ASCIIToUTF16("California"); |
| 430 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); | 430 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); |
| 431 | 431 |
| 432 FormFieldData result3; | 432 FormFieldData result3; |
| 433 WebFormControlElementToFormField(element, autofill::EXTRACT_OPTIONS, | 433 WebFormControlElementToFormField(element, autofill::EXTRACT_OPTIONS, |
| 434 &result3); | 434 &result3); |
| 435 expected.value = string16(); | 435 expected.value = base::string16(); |
| 436 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result3); | 436 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result3); |
| 437 | 437 |
| 438 ASSERT_EQ(2U, result3.option_values.size()); | 438 ASSERT_EQ(2U, result3.option_values.size()); |
| 439 ASSERT_EQ(2U, result3.option_contents.size()); | 439 ASSERT_EQ(2U, result3.option_contents.size()); |
| 440 EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_values[0]); | 440 EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_values[0]); |
| 441 EXPECT_EQ(ASCIIToUTF16("California"), result3.option_contents[0]); | 441 EXPECT_EQ(ASCIIToUTF16("California"), result3.option_contents[0]); |
| 442 EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_values[1]); | 442 EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_values[1]); |
| 443 EXPECT_EQ(ASCIIToUTF16("Texas"), result3.option_contents[1]); | 443 EXPECT_EQ(ASCIIToUTF16("Texas"), result3.option_contents[1]); |
| 444 } | 444 } |
| 445 | 445 |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 " <TD></TD>" | 1360 " <TD></TD>" |
| 1361 " <TD>" | 1361 " <TD>" |
| 1362 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1362 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1363 " </TD>" | 1363 " </TD>" |
| 1364 " </TR>" | 1364 " </TR>" |
| 1365 "</TABLE>" | 1365 "</TABLE>" |
| 1366 "</FORM>"); | 1366 "</FORM>"); |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 TEST_F(FormAutofillTest, LabelsInferredFromTableCellNested) { | 1369 TEST_F(FormAutofillTest, LabelsInferredFromTableCellNested) { |
| 1370 std::vector<string16> labels, names, values; | 1370 std::vector<base::string16> labels, names, values; |
| 1371 | 1371 |
| 1372 labels.push_back(ASCIIToUTF16("First name: Bogus")); | 1372 labels.push_back(ASCIIToUTF16("First name: Bogus")); |
| 1373 names.push_back(ASCIIToUTF16("firstname")); | 1373 names.push_back(ASCIIToUTF16("firstname")); |
| 1374 values.push_back(ASCIIToUTF16("John")); | 1374 values.push_back(ASCIIToUTF16("John")); |
| 1375 | 1375 |
| 1376 labels.push_back(ASCIIToUTF16("Last name:")); | 1376 labels.push_back(ASCIIToUTF16("Last name:")); |
| 1377 names.push_back(ASCIIToUTF16("lastname")); | 1377 names.push_back(ASCIIToUTF16("lastname")); |
| 1378 values.push_back(ASCIIToUTF16("Smith")); | 1378 values.push_back(ASCIIToUTF16("Smith")); |
| 1379 | 1379 |
| 1380 labels.push_back(ASCIIToUTF16("Email:")); | 1380 labels.push_back(ASCIIToUTF16("Email:")); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 " <TD>" | 1428 " <TD>" |
| 1429 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1429 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1430 " </TD>" | 1430 " </TD>" |
| 1431 " </TR>" | 1431 " </TR>" |
| 1432 "</TABLE>" | 1432 "</TABLE>" |
| 1433 "</FORM>", | 1433 "</FORM>", |
| 1434 labels, names, values); | 1434 labels, names, values); |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 TEST_F(FormAutofillTest, LabelsInferredFromTableEmptyTDs) { | 1437 TEST_F(FormAutofillTest, LabelsInferredFromTableEmptyTDs) { |
| 1438 std::vector<string16> labels, names, values; | 1438 std::vector<base::string16> labels, names, values; |
| 1439 | 1439 |
| 1440 labels.push_back(ASCIIToUTF16("* First Name")); | 1440 labels.push_back(ASCIIToUTF16("* First Name")); |
| 1441 names.push_back(ASCIIToUTF16("firstname")); | 1441 names.push_back(ASCIIToUTF16("firstname")); |
| 1442 values.push_back(ASCIIToUTF16("John")); | 1442 values.push_back(ASCIIToUTF16("John")); |
| 1443 | 1443 |
| 1444 labels.push_back(ASCIIToUTF16("* Last Name")); | 1444 labels.push_back(ASCIIToUTF16("* Last Name")); |
| 1445 names.push_back(ASCIIToUTF16("lastname")); | 1445 names.push_back(ASCIIToUTF16("lastname")); |
| 1446 values.push_back(ASCIIToUTF16("Smith")); | 1446 values.push_back(ASCIIToUTF16("Smith")); |
| 1447 | 1447 |
| 1448 labels.push_back(ASCIIToUTF16("* Email")); | 1448 labels.push_back(ASCIIToUTF16("* Email")); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 " <TD>" | 1487 " <TD>" |
| 1488 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1488 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1489 " </TD>" | 1489 " </TD>" |
| 1490 " </TR>" | 1490 " </TR>" |
| 1491 "</TABLE>" | 1491 "</TABLE>" |
| 1492 "</FORM>", | 1492 "</FORM>", |
| 1493 labels, names, values); | 1493 labels, names, values); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 TEST_F(FormAutofillTest, LabelsInferredFromPreviousTD) { | 1496 TEST_F(FormAutofillTest, LabelsInferredFromPreviousTD) { |
| 1497 std::vector<string16> labels, names, values; | 1497 std::vector<base::string16> labels, names, values; |
| 1498 | 1498 |
| 1499 labels.push_back(ASCIIToUTF16("* First Name")); | 1499 labels.push_back(ASCIIToUTF16("* First Name")); |
| 1500 names.push_back(ASCIIToUTF16("firstname")); | 1500 names.push_back(ASCIIToUTF16("firstname")); |
| 1501 values.push_back(ASCIIToUTF16("John")); | 1501 values.push_back(ASCIIToUTF16("John")); |
| 1502 | 1502 |
| 1503 labels.push_back(ASCIIToUTF16("* Last Name")); | 1503 labels.push_back(ASCIIToUTF16("* Last Name")); |
| 1504 names.push_back(ASCIIToUTF16("lastname")); | 1504 names.push_back(ASCIIToUTF16("lastname")); |
| 1505 values.push_back(ASCIIToUTF16("Smith")); | 1505 values.push_back(ASCIIToUTF16("Smith")); |
| 1506 | 1506 |
| 1507 labels.push_back(ASCIIToUTF16("* Email")); | 1507 labels.push_back(ASCIIToUTF16("* Email")); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 " </TR>" | 1539 " </TR>" |
| 1540 "</TABLE>" | 1540 "</TABLE>" |
| 1541 "</FORM>", | 1541 "</FORM>", |
| 1542 labels, names, values); | 1542 labels, names, values); |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 // <script>, <noscript> and <option> tags are excluded when the labels are | 1545 // <script>, <noscript> and <option> tags are excluded when the labels are |
| 1546 // inferred. | 1546 // inferred. |
| 1547 // Also <!-- comment --> is excluded. | 1547 // Also <!-- comment --> is excluded. |
| 1548 TEST_F(FormAutofillTest, LabelsInferredFromTableWithSpecialElements) { | 1548 TEST_F(FormAutofillTest, LabelsInferredFromTableWithSpecialElements) { |
| 1549 std::vector<string16> labels, names, values; | 1549 std::vector<base::string16> labels, names, values; |
| 1550 std::vector<std::string> control_types; | 1550 std::vector<std::string> control_types; |
| 1551 | 1551 |
| 1552 labels.push_back(ASCIIToUTF16("* First Name")); | 1552 labels.push_back(ASCIIToUTF16("* First Name")); |
| 1553 names.push_back(ASCIIToUTF16("firstname")); | 1553 names.push_back(ASCIIToUTF16("firstname")); |
| 1554 values.push_back(ASCIIToUTF16("John")); | 1554 values.push_back(ASCIIToUTF16("John")); |
| 1555 control_types.push_back("text"); | 1555 control_types.push_back("text"); |
| 1556 | 1556 |
| 1557 labels.push_back(ASCIIToUTF16("* Middle Name")); | 1557 labels.push_back(ASCIIToUTF16("* Middle Name")); |
| 1558 names.push_back(ASCIIToUTF16("middlename")); | 1558 names.push_back(ASCIIToUTF16("middlename")); |
| 1559 values.push_back(ASCIIToUTF16("Joe")); | 1559 values.push_back(ASCIIToUTF16("Joe")); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 " </TD>" | 1696 " </TD>" |
| 1697 " </TR>" | 1697 " </TR>" |
| 1698 "</TABLE>" | 1698 "</TABLE>" |
| 1699 "<INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1699 "<INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1700 "</FORM>"); | 1700 "</FORM>"); |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 // Verify that we correctly infer labels when the label text spans multiple | 1703 // Verify that we correctly infer labels when the label text spans multiple |
| 1704 // adjacent HTML elements, not separated by whitespace. | 1704 // adjacent HTML elements, not separated by whitespace. |
| 1705 TEST_F(FormAutofillTest, LabelsInferredFromTableAdjacentElements) { | 1705 TEST_F(FormAutofillTest, LabelsInferredFromTableAdjacentElements) { |
| 1706 std::vector<string16> labels, names, values; | 1706 std::vector<base::string16> labels, names, values; |
| 1707 | 1707 |
| 1708 labels.push_back(ASCIIToUTF16("*First Name")); | 1708 labels.push_back(ASCIIToUTF16("*First Name")); |
| 1709 names.push_back(ASCIIToUTF16("firstname")); | 1709 names.push_back(ASCIIToUTF16("firstname")); |
| 1710 values.push_back(ASCIIToUTF16("John")); | 1710 values.push_back(ASCIIToUTF16("John")); |
| 1711 | 1711 |
| 1712 labels.push_back(ASCIIToUTF16("*Last Name")); | 1712 labels.push_back(ASCIIToUTF16("*Last Name")); |
| 1713 names.push_back(ASCIIToUTF16("lastname")); | 1713 names.push_back(ASCIIToUTF16("lastname")); |
| 1714 values.push_back(ASCIIToUTF16("Smith")); | 1714 values.push_back(ASCIIToUTF16("Smith")); |
| 1715 | 1715 |
| 1716 labels.push_back(ASCIIToUTF16("*Email")); | 1716 labels.push_back(ASCIIToUTF16("*Email")); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1750 " </TD>" | 1750 " </TD>" |
| 1751 " </TR>" | 1751 " </TR>" |
| 1752 "</TABLE>" | 1752 "</TABLE>" |
| 1753 "</FORM>", | 1753 "</FORM>", |
| 1754 labels, names, values); | 1754 labels, names, values); |
| 1755 } | 1755 } |
| 1756 | 1756 |
| 1757 // Verify that we correctly infer labels when the label text resides in the | 1757 // Verify that we correctly infer labels when the label text resides in the |
| 1758 // previous row. | 1758 // previous row. |
| 1759 TEST_F(FormAutofillTest, LabelsInferredFromTableRow) { | 1759 TEST_F(FormAutofillTest, LabelsInferredFromTableRow) { |
| 1760 std::vector<string16> labels, names, values; | 1760 std::vector<base::string16> labels, names, values; |
| 1761 | 1761 |
| 1762 labels.push_back(ASCIIToUTF16("*First Name *Last Name *Email")); | 1762 labels.push_back(ASCIIToUTF16("*First Name *Last Name *Email")); |
| 1763 names.push_back(ASCIIToUTF16("firstname")); | 1763 names.push_back(ASCIIToUTF16("firstname")); |
| 1764 values.push_back(ASCIIToUTF16("John")); | 1764 values.push_back(ASCIIToUTF16("John")); |
| 1765 | 1765 |
| 1766 labels.push_back(ASCIIToUTF16("*First Name *Last Name *Email")); | 1766 labels.push_back(ASCIIToUTF16("*First Name *Last Name *Email")); |
| 1767 names.push_back(ASCIIToUTF16("lastname")); | 1767 names.push_back(ASCIIToUTF16("lastname")); |
| 1768 values.push_back(ASCIIToUTF16("Smith")); | 1768 values.push_back(ASCIIToUTF16("Smith")); |
| 1769 | 1769 |
| 1770 labels.push_back(ASCIIToUTF16("*First Name *Last Name *Email")); | 1770 labels.push_back(ASCIIToUTF16("*First Name *Last Name *Email")); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1794 " <TD>" | 1794 " <TD>" |
| 1795 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1795 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1796 " </TD>" | 1796 " </TD>" |
| 1797 " </TR>" | 1797 " </TR>" |
| 1798 "</TABLE>", | 1798 "</TABLE>", |
| 1799 labels, names, values); | 1799 labels, names, values); |
| 1800 } | 1800 } |
| 1801 | 1801 |
| 1802 // Verify that we correctly infer labels when enclosed within a list item. | 1802 // Verify that we correctly infer labels when enclosed within a list item. |
| 1803 TEST_F(FormAutofillTest, LabelsInferredFromListItem) { | 1803 TEST_F(FormAutofillTest, LabelsInferredFromListItem) { |
| 1804 std::vector<string16> labels, names, values; | 1804 std::vector<base::string16> labels, names, values; |
| 1805 | 1805 |
| 1806 labels.push_back(ASCIIToUTF16("* Home Phone")); | 1806 labels.push_back(ASCIIToUTF16("* Home Phone")); |
| 1807 names.push_back(ASCIIToUTF16("areacode")); | 1807 names.push_back(ASCIIToUTF16("areacode")); |
| 1808 values.push_back(ASCIIToUTF16("415")); | 1808 values.push_back(ASCIIToUTF16("415")); |
| 1809 | 1809 |
| 1810 labels.push_back(ASCIIToUTF16("* Home Phone")); | 1810 labels.push_back(ASCIIToUTF16("* Home Phone")); |
| 1811 names.push_back(ASCIIToUTF16("prefix")); | 1811 names.push_back(ASCIIToUTF16("prefix")); |
| 1812 values.push_back(ASCIIToUTF16("555")); | 1812 values.push_back(ASCIIToUTF16("555")); |
| 1813 | 1813 |
| 1814 labels.push_back(ASCIIToUTF16("* Home Phone")); | 1814 labels.push_back(ASCIIToUTF16("* Home Phone")); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1829 " </LI>" | 1829 " </LI>" |
| 1830 " <LI>" | 1830 " <LI>" |
| 1831 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1831 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1832 " </LI>" | 1832 " </LI>" |
| 1833 "</DIV>" | 1833 "</DIV>" |
| 1834 "</FORM>", | 1834 "</FORM>", |
| 1835 labels, names, values); | 1835 labels, names, values); |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 TEST_F(FormAutofillTest, LabelsInferredFromDefinitionList) { | 1838 TEST_F(FormAutofillTest, LabelsInferredFromDefinitionList) { |
| 1839 std::vector<string16> labels, names, values; | 1839 std::vector<base::string16> labels, names, values; |
| 1840 | 1840 |
| 1841 labels.push_back(ASCIIToUTF16("* First name: Bogus")); | 1841 labels.push_back(ASCIIToUTF16("* First name: Bogus")); |
| 1842 names.push_back(ASCIIToUTF16("firstname")); | 1842 names.push_back(ASCIIToUTF16("firstname")); |
| 1843 values.push_back(ASCIIToUTF16("John")); | 1843 values.push_back(ASCIIToUTF16("John")); |
| 1844 | 1844 |
| 1845 labels.push_back(ASCIIToUTF16("Last name:")); | 1845 labels.push_back(ASCIIToUTF16("Last name:")); |
| 1846 names.push_back(ASCIIToUTF16("lastname")); | 1846 names.push_back(ASCIIToUTF16("lastname")); |
| 1847 values.push_back(ASCIIToUTF16("Smith")); | 1847 values.push_back(ASCIIToUTF16("Smith")); |
| 1848 | 1848 |
| 1849 labels.push_back(ASCIIToUTF16("Email:")); | 1849 labels.push_back(ASCIIToUTF16("Email:")); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 " <DT></DT>" | 1892 " <DT></DT>" |
| 1893 " <DD>" | 1893 " <DD>" |
| 1894 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1894 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1895 " </DD>" | 1895 " </DD>" |
| 1896 "</DL>" | 1896 "</DL>" |
| 1897 "</FORM>", | 1897 "</FORM>", |
| 1898 labels, names, values); | 1898 labels, names, values); |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 TEST_F(FormAutofillTest, LabelsInferredWithSameName) { | 1901 TEST_F(FormAutofillTest, LabelsInferredWithSameName) { |
| 1902 std::vector<string16> labels, names, values; | 1902 std::vector<base::string16> labels, names, values; |
| 1903 | 1903 |
| 1904 labels.push_back(ASCIIToUTF16("Address Line 1:")); | 1904 labels.push_back(ASCIIToUTF16("Address Line 1:")); |
| 1905 names.push_back(ASCIIToUTF16("Address")); | 1905 names.push_back(ASCIIToUTF16("Address")); |
| 1906 values.push_back(string16()); | 1906 values.push_back(base::string16()); |
| 1907 | 1907 |
| 1908 labels.push_back(ASCIIToUTF16("Address Line 2:")); | 1908 labels.push_back(ASCIIToUTF16("Address Line 2:")); |
| 1909 names.push_back(ASCIIToUTF16("Address")); | 1909 names.push_back(ASCIIToUTF16("Address")); |
| 1910 values.push_back(string16()); | 1910 values.push_back(base::string16()); |
| 1911 | 1911 |
| 1912 labels.push_back(ASCIIToUTF16("Address Line 3:")); | 1912 labels.push_back(ASCIIToUTF16("Address Line 3:")); |
| 1913 names.push_back(ASCIIToUTF16("Address")); | 1913 names.push_back(ASCIIToUTF16("Address")); |
| 1914 values.push_back(string16()); | 1914 values.push_back(base::string16()); |
| 1915 | 1915 |
| 1916 ExpectLabels( | 1916 ExpectLabels( |
| 1917 "<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 1917 "<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| 1918 " Address Line 1:" | 1918 " Address Line 1:" |
| 1919 " <INPUT type=\"text\" name=\"Address\"/>" | 1919 " <INPUT type=\"text\" name=\"Address\"/>" |
| 1920 " Address Line 2:" | 1920 " Address Line 2:" |
| 1921 " <INPUT type=\"text\" name=\"Address\"/>" | 1921 " <INPUT type=\"text\" name=\"Address\"/>" |
| 1922 " Address Line 3:" | 1922 " Address Line 3:" |
| 1923 " <INPUT type=\"text\" name=\"Address\"/>" | 1923 " <INPUT type=\"text\" name=\"Address\"/>" |
| 1924 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1924 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1925 "</FORM>", | 1925 "</FORM>", |
| 1926 labels, names, values); | 1926 labels, names, values); |
| 1927 } | 1927 } |
| 1928 | 1928 |
| 1929 TEST_F(FormAutofillTest, LabelsInferredWithImageTags) { | 1929 TEST_F(FormAutofillTest, LabelsInferredWithImageTags) { |
| 1930 std::vector<string16> labels, names, values; | 1930 std::vector<base::string16> labels, names, values; |
| 1931 | 1931 |
| 1932 labels.push_back(ASCIIToUTF16("Phone:")); | 1932 labels.push_back(ASCIIToUTF16("Phone:")); |
| 1933 names.push_back(ASCIIToUTF16("dayphone1")); | 1933 names.push_back(ASCIIToUTF16("dayphone1")); |
| 1934 values.push_back(string16()); | 1934 values.push_back(base::string16()); |
| 1935 | 1935 |
| 1936 labels.push_back(ASCIIToUTF16("-")); | 1936 labels.push_back(ASCIIToUTF16("-")); |
| 1937 names.push_back(ASCIIToUTF16("dayphone2")); | 1937 names.push_back(ASCIIToUTF16("dayphone2")); |
| 1938 values.push_back(string16()); | 1938 values.push_back(base::string16()); |
| 1939 | 1939 |
| 1940 labels.push_back(ASCIIToUTF16("-")); | 1940 labels.push_back(ASCIIToUTF16("-")); |
| 1941 names.push_back(ASCIIToUTF16("dayphone3")); | 1941 names.push_back(ASCIIToUTF16("dayphone3")); |
| 1942 values.push_back(string16()); | 1942 values.push_back(base::string16()); |
| 1943 | 1943 |
| 1944 labels.push_back(ASCIIToUTF16("ext.:")); | 1944 labels.push_back(ASCIIToUTF16("ext.:")); |
| 1945 names.push_back(ASCIIToUTF16("dayphone4")); | 1945 names.push_back(ASCIIToUTF16("dayphone4")); |
| 1946 values.push_back(string16()); | 1946 values.push_back(base::string16()); |
| 1947 | 1947 |
| 1948 labels.push_back(string16()); | 1948 labels.push_back(base::string16()); |
| 1949 names.push_back(ASCIIToUTF16("dummy")); | 1949 names.push_back(ASCIIToUTF16("dummy")); |
| 1950 values.push_back(string16()); | 1950 values.push_back(base::string16()); |
| 1951 | 1951 |
| 1952 ExpectLabels( | 1952 ExpectLabels( |
| 1953 "<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 1953 "<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| 1954 " Phone:" | 1954 " Phone:" |
| 1955 " <input type=\"text\" name=\"dayphone1\">" | 1955 " <input type=\"text\" name=\"dayphone1\">" |
| 1956 " <img/>" | 1956 " <img/>" |
| 1957 " -" | 1957 " -" |
| 1958 " <img/>" | 1958 " <img/>" |
| 1959 " <input type=\"text\" name=\"dayphone2\">" | 1959 " <input type=\"text\" name=\"dayphone2\">" |
| 1960 " <img/>" | 1960 " <img/>" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 | 2334 |
| 2335 // Get the input element we want to find. | 2335 // Get the input element we want to find. |
| 2336 WebElement element = web_frame->document().getElementById("apple"); | 2336 WebElement element = web_frame->document().getElementById("apple"); |
| 2337 WebInputElement input_element = element.to<WebInputElement>(); | 2337 WebInputElement input_element = element.to<WebInputElement>(); |
| 2338 | 2338 |
| 2339 // Find the form that contains the input element. | 2339 // Find the form that contains the input element. |
| 2340 FormData form; | 2340 FormData form; |
| 2341 FormFieldData field; | 2341 FormFieldData field; |
| 2342 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, | 2342 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, |
| 2343 autofill::REQUIRE_NONE)); | 2343 autofill::REQUIRE_NONE)); |
| 2344 EXPECT_EQ(string16(), form.name); | 2344 EXPECT_EQ(base::string16(), form.name); |
| 2345 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2345 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 2346 EXPECT_EQ(GURL("http://abc.com"), form.action); | 2346 EXPECT_EQ(GURL("http://abc.com"), form.action); |
| 2347 | 2347 |
| 2348 const std::vector<FormFieldData>& fields = form.fields; | 2348 const std::vector<FormFieldData>& fields = form.fields; |
| 2349 ASSERT_EQ(3U, fields.size()); | 2349 ASSERT_EQ(3U, fields.size()); |
| 2350 | 2350 |
| 2351 FormFieldData expected; | 2351 FormFieldData expected; |
| 2352 expected.form_control_type = "text"; | 2352 expected.form_control_type = "text"; |
| 2353 expected.max_length = WebInputElement::defaultMaxLength(); | 2353 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2354 | 2354 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2369 form.fields[1].value = ASCIIToUTF16("Yellow"); | 2369 form.fields[1].value = ASCIIToUTF16("Yellow"); |
| 2370 form.fields[2].value = ASCIIToUTF16("Also Yellow"); | 2370 form.fields[2].value = ASCIIToUTF16("Also Yellow"); |
| 2371 FillForm(form, input_element); | 2371 FillForm(form, input_element); |
| 2372 | 2372 |
| 2373 // Find the newly-filled form that contains the input element. | 2373 // Find the newly-filled form that contains the input element. |
| 2374 FormData form2; | 2374 FormData form2; |
| 2375 FormFieldData field2; | 2375 FormFieldData field2; |
| 2376 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 2376 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, |
| 2377 autofill::REQUIRE_NONE)); | 2377 autofill::REQUIRE_NONE)); |
| 2378 | 2378 |
| 2379 EXPECT_EQ(string16(), form2.name); | 2379 EXPECT_EQ(base::string16(), form2.name); |
| 2380 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2380 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
| 2381 EXPECT_EQ(GURL("http://abc.com"), form2.action); | 2381 EXPECT_EQ(GURL("http://abc.com"), form2.action); |
| 2382 | 2382 |
| 2383 const std::vector<FormFieldData>& fields2 = form2.fields; | 2383 const std::vector<FormFieldData>& fields2 = form2.fields; |
| 2384 ASSERT_EQ(3U, fields2.size()); | 2384 ASSERT_EQ(3U, fields2.size()); |
| 2385 | 2385 |
| 2386 expected.name = ASCIIToUTF16("apple"); | 2386 expected.name = ASCIIToUTF16("apple"); |
| 2387 expected.value = ASCIIToUTF16("Red"); | 2387 expected.value = ASCIIToUTF16("Red"); |
| 2388 expected.is_autofilled = true; | 2388 expected.is_autofilled = true; |
| 2389 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | 2389 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2510 expected.name = ASCIIToUTF16("dayphone3"); | 2510 expected.name = ASCIIToUTF16("dayphone3"); |
| 2511 expected.max_length = 4; | 2511 expected.max_length = 4; |
| 2512 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 2512 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 2513 | 2513 |
| 2514 expected.label = ASCIIToUTF16("ext.:"); | 2514 expected.label = ASCIIToUTF16("ext.:"); |
| 2515 expected.name = ASCIIToUTF16("dayphone4"); | 2515 expected.name = ASCIIToUTF16("dayphone4"); |
| 2516 expected.max_length = 5; | 2516 expected.max_length = 5; |
| 2517 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); | 2517 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); |
| 2518 | 2518 |
| 2519 // When unspecified |size|, default is returned. | 2519 // When unspecified |size|, default is returned. |
| 2520 expected.label = string16(); | 2520 expected.label = base::string16(); |
| 2521 expected.name = ASCIIToUTF16("default1"); | 2521 expected.name = ASCIIToUTF16("default1"); |
| 2522 expected.max_length = WebInputElement::defaultMaxLength(); | 2522 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2523 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[4]); | 2523 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[4]); |
| 2524 | 2524 |
| 2525 // When invalid |size|, default is returned. | 2525 // When invalid |size|, default is returned. |
| 2526 expected.label = string16(); | 2526 expected.label = base::string16(); |
| 2527 expected.name = ASCIIToUTF16("invalid1"); | 2527 expected.name = ASCIIToUTF16("invalid1"); |
| 2528 expected.max_length = WebInputElement::defaultMaxLength(); | 2528 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2529 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[5]); | 2529 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[5]); |
| 2530 } | 2530 } |
| 2531 | 2531 |
| 2532 // This test re-creates the experience of typing in a field then selecting a | 2532 // This test re-creates the experience of typing in a field then selecting a |
| 2533 // profile from the Autofill suggestions popup. The field that is being typed | 2533 // profile from the Autofill suggestions popup. The field that is being typed |
| 2534 // into should be filled even though it's not technically empty. | 2534 // into should be filled even though it's not technically empty. |
| 2535 TEST_F(FormAutofillTest, FillFormNonEmptyField) { | 2535 TEST_F(FormAutofillTest, FillFormNonEmptyField) { |
| 2536 LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">" | 2536 LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 FormFieldData expected; | 2570 FormFieldData expected; |
| 2571 expected.form_control_type = "text"; | 2571 expected.form_control_type = "text"; |
| 2572 expected.max_length = WebInputElement::defaultMaxLength(); | 2572 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2573 | 2573 |
| 2574 expected.name = ASCIIToUTF16("firstname"); | 2574 expected.name = ASCIIToUTF16("firstname"); |
| 2575 expected.value = ASCIIToUTF16("Wy"); | 2575 expected.value = ASCIIToUTF16("Wy"); |
| 2576 expected.is_autofilled = false; | 2576 expected.is_autofilled = false; |
| 2577 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); | 2577 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); |
| 2578 | 2578 |
| 2579 expected.name = ASCIIToUTF16("lastname"); | 2579 expected.name = ASCIIToUTF16("lastname"); |
| 2580 expected.value = string16(); | 2580 expected.value = base::string16(); |
| 2581 expected.is_autofilled = false; | 2581 expected.is_autofilled = false; |
| 2582 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 2582 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 2583 | 2583 |
| 2584 expected.name = ASCIIToUTF16("email"); | 2584 expected.name = ASCIIToUTF16("email"); |
| 2585 expected.value = string16(); | 2585 expected.value = base::string16(); |
| 2586 expected.is_autofilled = false; | 2586 expected.is_autofilled = false; |
| 2587 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 2587 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 2588 | 2588 |
| 2589 // Preview the form and verify that the cursor position has been updated. | 2589 // Preview the form and verify that the cursor position has been updated. |
| 2590 form.fields[0].value = ASCIIToUTF16("Wyatt"); | 2590 form.fields[0].value = ASCIIToUTF16("Wyatt"); |
| 2591 form.fields[1].value = ASCIIToUTF16("Earp"); | 2591 form.fields[1].value = ASCIIToUTF16("Earp"); |
| 2592 form.fields[2].value = ASCIIToUTF16("wyatt@example.com"); | 2592 form.fields[2].value = ASCIIToUTF16("wyatt@example.com"); |
| 2593 PreviewForm(form, input_element); | 2593 PreviewForm(form, input_element); |
| 2594 EXPECT_EQ(2, input_element.selectionStart()); | 2594 EXPECT_EQ(2, input_element.selectionStart()); |
| 2595 EXPECT_EQ(5, input_element.selectionEnd()); | 2595 EXPECT_EQ(5, input_element.selectionEnd()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2682 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2682 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
| 2683 | 2683 |
| 2684 const std::vector<FormFieldData>& fields2 = form2.fields; | 2684 const std::vector<FormFieldData>& fields2 = form2.fields; |
| 2685 ASSERT_EQ(9U, fields2.size()); | 2685 ASSERT_EQ(9U, fields2.size()); |
| 2686 | 2686 |
| 2687 FormFieldData expected; | 2687 FormFieldData expected; |
| 2688 expected.form_control_type = "text"; | 2688 expected.form_control_type = "text"; |
| 2689 expected.max_length = WebInputElement::defaultMaxLength(); | 2689 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2690 | 2690 |
| 2691 expected.name = ASCIIToUTF16("firstname"); | 2691 expected.name = ASCIIToUTF16("firstname"); |
| 2692 expected.value = string16(); | 2692 expected.value = base::string16(); |
| 2693 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | 2693 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
| 2694 | 2694 |
| 2695 expected.name = ASCIIToUTF16("lastname"); | 2695 expected.name = ASCIIToUTF16("lastname"); |
| 2696 expected.value = string16(); | 2696 expected.value = base::string16(); |
| 2697 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); | 2697 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); |
| 2698 | 2698 |
| 2699 expected.name = ASCIIToUTF16("noAC"); | 2699 expected.name = ASCIIToUTF16("noAC"); |
| 2700 expected.value = string16(); | 2700 expected.value = base::string16(); |
| 2701 expected.autocomplete_attribute = "off"; | 2701 expected.autocomplete_attribute = "off"; |
| 2702 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 2702 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 2703 expected.autocomplete_attribute = std::string(); // reset | 2703 expected.autocomplete_attribute = std::string(); // reset |
| 2704 | 2704 |
| 2705 expected.name = ASCIIToUTF16("notenabled"); | 2705 expected.name = ASCIIToUTF16("notenabled"); |
| 2706 expected.value = ASCIIToUTF16("no clear"); | 2706 expected.value = ASCIIToUTF16("no clear"); |
| 2707 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[3]); | 2707 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[3]); |
| 2708 | 2708 |
| 2709 expected.form_control_type = "month"; | 2709 expected.form_control_type = "month"; |
| 2710 expected.max_length = 0; | 2710 expected.max_length = 0; |
| 2711 expected.name = ASCIIToUTF16("month"); | 2711 expected.name = ASCIIToUTF16("month"); |
| 2712 expected.value = string16(); | 2712 expected.value = base::string16(); |
| 2713 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[4]); | 2713 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[4]); |
| 2714 | 2714 |
| 2715 expected.name = ASCIIToUTF16("month-disabled"); | 2715 expected.name = ASCIIToUTF16("month-disabled"); |
| 2716 expected.value = ASCIIToUTF16("2012-11"); | 2716 expected.value = ASCIIToUTF16("2012-11"); |
| 2717 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[5]); | 2717 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[5]); |
| 2718 | 2718 |
| 2719 expected.form_control_type = "textarea"; | 2719 expected.form_control_type = "textarea"; |
| 2720 expected.name = ASCIIToUTF16("textarea"); | 2720 expected.name = ASCIIToUTF16("textarea"); |
| 2721 expected.value = string16(); | 2721 expected.value = base::string16(); |
| 2722 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[6]); | 2722 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[6]); |
| 2723 | 2723 |
| 2724 expected.name = ASCIIToUTF16("textarea-disabled"); | 2724 expected.name = ASCIIToUTF16("textarea-disabled"); |
| 2725 expected.value = ASCIIToUTF16(" Banana! "); | 2725 expected.value = ASCIIToUTF16(" Banana! "); |
| 2726 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[7]); | 2726 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[7]); |
| 2727 | 2727 |
| 2728 expected.name = ASCIIToUTF16("textarea-noAC"); | 2728 expected.name = ASCIIToUTF16("textarea-noAC"); |
| 2729 expected.value = string16(); | 2729 expected.value = base::string16(); |
| 2730 expected.autocomplete_attribute = "off"; | 2730 expected.autocomplete_attribute = "off"; |
| 2731 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[8]); | 2731 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[8]); |
| 2732 expected.autocomplete_attribute = std::string(); // reset | 2732 expected.autocomplete_attribute = std::string(); // reset |
| 2733 | 2733 |
| 2734 // Verify that the cursor position has been updated. | 2734 // Verify that the cursor position has been updated. |
| 2735 EXPECT_EQ(0, firstname.selectionStart()); | 2735 EXPECT_EQ(0, firstname.selectionStart()); |
| 2736 EXPECT_EQ(0, firstname.selectionEnd()); | 2736 EXPECT_EQ(0, firstname.selectionEnd()); |
| 2737 } | 2737 } |
| 2738 | 2738 |
| 2739 TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) { | 2739 TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2782 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 2782 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
| 2783 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2783 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
| 2784 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2784 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
| 2785 | 2785 |
| 2786 const std::vector<FormFieldData>& fields2 = form2.fields; | 2786 const std::vector<FormFieldData>& fields2 = form2.fields; |
| 2787 ASSERT_EQ(3U, fields2.size()); | 2787 ASSERT_EQ(3U, fields2.size()); |
| 2788 | 2788 |
| 2789 FormFieldData expected; | 2789 FormFieldData expected; |
| 2790 | 2790 |
| 2791 expected.name = ASCIIToUTF16("firstname"); | 2791 expected.name = ASCIIToUTF16("firstname"); |
| 2792 expected.value = string16(); | 2792 expected.value = base::string16(); |
| 2793 expected.form_control_type = "text"; | 2793 expected.form_control_type = "text"; |
| 2794 expected.max_length = WebInputElement::defaultMaxLength(); | 2794 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2795 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | 2795 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
| 2796 | 2796 |
| 2797 expected.name = ASCIIToUTF16("lastname"); | 2797 expected.name = ASCIIToUTF16("lastname"); |
| 2798 expected.value = string16(); | 2798 expected.value = base::string16(); |
| 2799 expected.form_control_type = "text"; | 2799 expected.form_control_type = "text"; |
| 2800 expected.max_length = WebInputElement::defaultMaxLength(); | 2800 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2801 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); | 2801 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); |
| 2802 | 2802 |
| 2803 expected.name = ASCIIToUTF16("state"); | 2803 expected.name = ASCIIToUTF16("state"); |
| 2804 expected.value = ASCIIToUTF16("?"); | 2804 expected.value = ASCIIToUTF16("?"); |
| 2805 expected.form_control_type = "select-one"; | 2805 expected.form_control_type = "select-one"; |
| 2806 expected.max_length = 0; | 2806 expected.max_length = 0; |
| 2807 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 2807 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 2808 | 2808 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3039 EXPECT_FALSE(FormWithElementIsAutofilled(firstname)); | 3039 EXPECT_FALSE(FormWithElementIsAutofilled(firstname)); |
| 3040 | 3040 |
| 3041 // Set the auto-filled attribute. | 3041 // Set the auto-filled attribute. |
| 3042 firstname.setAutofilled(true); | 3042 firstname.setAutofilled(true); |
| 3043 | 3043 |
| 3044 EXPECT_TRUE(FormWithElementIsAutofilled(firstname)); | 3044 EXPECT_TRUE(FormWithElementIsAutofilled(firstname)); |
| 3045 } | 3045 } |
| 3046 | 3046 |
| 3047 // If we have multiple labels per id, the labels concatenated into label string. | 3047 // If we have multiple labels per id, the labels concatenated into label string. |
| 3048 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { | 3048 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { |
| 3049 std::vector<string16> labels, names, values; | 3049 std::vector<base::string16> labels, names, values; |
| 3050 | 3050 |
| 3051 labels.push_back(ASCIIToUTF16("First Name:")); | 3051 labels.push_back(ASCIIToUTF16("First Name:")); |
| 3052 names.push_back(ASCIIToUTF16("firstname")); | 3052 names.push_back(ASCIIToUTF16("firstname")); |
| 3053 values.push_back(ASCIIToUTF16("John")); | 3053 values.push_back(ASCIIToUTF16("John")); |
| 3054 | 3054 |
| 3055 labels.push_back(ASCIIToUTF16("Last Name:")); | 3055 labels.push_back(ASCIIToUTF16("Last Name:")); |
| 3056 names.push_back(ASCIIToUTF16("lastname")); | 3056 names.push_back(ASCIIToUTF16("lastname")); |
| 3057 values.push_back(ASCIIToUTF16("Smith")); | 3057 values.push_back(ASCIIToUTF16("Smith")); |
| 3058 | 3058 |
| 3059 labels.push_back(ASCIIToUTF16("Email: xxx@yyy.com")); | 3059 labels.push_back(ASCIIToUTF16("Email: xxx@yyy.com")); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3188 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3188 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 3189 | 3189 |
| 3190 expected.name = ASCIIToUTF16("country"); | 3190 expected.name = ASCIIToUTF16("country"); |
| 3191 expected.value = ASCIIToUTF16("AL"); | 3191 expected.value = ASCIIToUTF16("AL"); |
| 3192 expected.form_control_type = "select-one"; | 3192 expected.form_control_type = "select-one"; |
| 3193 expected.max_length = 0; | 3193 expected.max_length = 0; |
| 3194 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3194 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 3195 } | 3195 } |
| 3196 | 3196 |
| 3197 } // namespace autofill | 3197 } // namespace autofill |
| OLD | NEW |