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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 { "experimental", "text", "" }, | 653 { "experimental", "text", "" }, |
654 // <select> elements should behave no differently from text fields here. | 654 // <select> elements should behave no differently from text fields here. |
655 { "select", "select-one", "state" }, | 655 { "select", "select-one", "state" }, |
656 // <textarea> elements should also behave no differently from text fields. | 656 // <textarea> elements should also behave no differently from text fields. |
657 { "textarea", "textarea", "street-address" }, | 657 { "textarea", "textarea", "street-address" }, |
658 // Very long attribute values should be replaced by a default string, to | 658 // Very long attribute values should be replaced by a default string, to |
659 // prevent malicious websites from DOSing the browser process. | 659 // prevent malicious websites from DOSing the browser process. |
660 { "malicious", "text", "x-max-data-length-exceeded" }, | 660 { "malicious", "text", "x-max-data-length-exceeded" }, |
661 }; | 661 }; |
662 | 662 |
663 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 663 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
664 WebElement web_element = frame->document().getElementById( | 664 WebElement web_element = frame->document().getElementById( |
665 ASCIIToUTF16(test_cases[i].element_id)); | 665 ASCIIToUTF16(test_cases[i].element_id)); |
666 WebFormControlElement element = web_element.to<WebFormControlElement>(); | 666 WebFormControlElement element = web_element.to<WebFormControlElement>(); |
667 FormFieldData result; | 667 FormFieldData result; |
668 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); | 668 WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result); |
669 | 669 |
670 FormFieldData expected; | 670 FormFieldData expected; |
671 expected.name = ASCIIToUTF16(test_cases[i].element_id); | 671 expected.name = ASCIIToUTF16(test_cases[i].element_id); |
672 expected.form_control_type = test_cases[i].form_control_type; | 672 expected.form_control_type = test_cases[i].form_control_type; |
673 expected.autocomplete_attribute = test_cases[i].autocomplete_attribute; | 673 expected.autocomplete_attribute = test_cases[i].autocomplete_attribute; |
(...skipping 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3679 expected.max_length = WebInputElement::defaultMaxLength(); | 3679 expected.max_length = WebInputElement::defaultMaxLength(); |
3680 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3680 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
3681 | 3681 |
3682 expected.name = ASCIIToUTF16("country"); | 3682 expected.name = ASCIIToUTF16("country"); |
3683 expected.value = ASCIIToUTF16("AL"); | 3683 expected.value = ASCIIToUTF16("AL"); |
3684 expected.form_control_type = "select-one"; | 3684 expected.form_control_type = "select-one"; |
3685 expected.max_length = 0; | 3685 expected.max_length = 0; |
3686 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3686 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
3687 } | 3687 } |
3688 } // namespace autofill | 3688 } // namespace autofill |
OLD | NEW |