| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 WebFrame* frame = GetMainFrame(); | 2074 WebFrame* frame = GetMainFrame(); |
| 2075 ASSERT_NE(nullptr, frame); | 2075 ASSERT_NE(nullptr, frame); |
| 2076 | 2076 |
| 2077 WebFormControlElement element = GetFormControlElementById("element"); | 2077 WebFormControlElement element = GetFormControlElementById("element"); |
| 2078 | 2078 |
| 2079 FormFieldData result; | 2079 FormFieldData result; |
| 2080 WebFormControlElementToFormField(element, EXTRACT_VALUE, &result); | 2080 WebFormControlElementToFormField(element, EXTRACT_VALUE, &result); |
| 2081 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); | 2081 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); |
| 2082 } | 2082 } |
| 2083 | 2083 |
| 2084 TEST_F(FormAutofillTest, TextAlignOverridesDirection) { |
| 2085 // text-align: right |
| 2086 LoadHTML("<STYLE>input{direction:ltr;text-align:right}</STYLE>" |
| 2087 "<FORM>" |
| 2088 " <INPUT type='text' id='element'/>" |
| 2089 "</FORM>"); |
| 2090 |
| 2091 WebFrame* frame = GetMainFrame(); |
| 2092 ASSERT_NE(nullptr, frame); |
| 2093 |
| 2094 WebFormControlElement element = GetFormControlElementById("element"); |
| 2095 |
| 2096 FormFieldData result; |
| 2097 WebFormControlElementToFormField(element, EXTRACT_VALUE, &result); |
| 2098 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
| 2099 |
| 2100 // text-align: left |
| 2101 LoadHTML("<STYLE>input{direction:rtl;text-align:left}</STYLE>" |
| 2102 "<FORM>" |
| 2103 " <INPUT type='text' id='element'/>" |
| 2104 "</FORM>"); |
| 2105 |
| 2106 frame = GetMainFrame(); |
| 2107 ASSERT_NE(nullptr, frame); |
| 2108 |
| 2109 element = GetFormControlElementById("element"); |
| 2110 |
| 2111 WebFormControlElementToFormField(element, EXTRACT_VALUE, &result); |
| 2112 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); |
| 2113 } |
| 2114 |
| 2084 TEST_F(FormAutofillTest, | 2115 TEST_F(FormAutofillTest, |
| 2085 DetectTextDirectionWhenParentHasBothDIRAttributeAndStyle) { | 2116 DetectTextDirectionWhenParentHasBothDIRAttributeAndStyle) { |
| 2086 LoadHTML("<STYLE>form{direction:ltr}</STYLE>" | 2117 LoadHTML("<STYLE>form{direction:ltr}</STYLE>" |
| 2087 "<FORM dir='rtl'>" | 2118 "<FORM dir='rtl'>" |
| 2088 " <INPUT type='text' id='element'/>" | 2119 " <INPUT type='text' id='element'/>" |
| 2089 "</FORM>"); | 2120 "</FORM>"); |
| 2090 | 2121 |
| 2091 WebFrame* frame = GetMainFrame(); | 2122 WebFrame* frame = GetMainFrame(); |
| 2092 ASSERT_NE(nullptr, frame); | 2123 ASSERT_NE(nullptr, frame); |
| 2093 | 2124 |
| (...skipping 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4608 | 4639 |
| 4609 if (test_case.has_extracted_form) { | 4640 if (test_case.has_extracted_form) { |
| 4610 EXPECT_EQ(test_case.is_form_tag, forms[0].is_form_tag); | 4641 EXPECT_EQ(test_case.is_form_tag, forms[0].is_form_tag); |
| 4611 EXPECT_EQ(test_case.is_formless_checkout, forms[0].is_formless_checkout); | 4642 EXPECT_EQ(test_case.is_formless_checkout, forms[0].is_formless_checkout); |
| 4612 } | 4643 } |
| 4613 } | 4644 } |
| 4614 } | 4645 } |
| 4615 | 4646 |
| 4616 } // namespace form_util | 4647 } // namespace form_util |
| 4617 } // namespace autofill | 4648 } // namespace autofill |
| OLD | NEW |