Index: chrome/renderer/autofill/form_autofill_browsertest.cc |
diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc |
index f76ee97fd465deb7e0fde8bb50a0b54e9c8f70b2..12db8acc6b7a8eaf71021007e1f470b7724115a6 100644 |
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc |
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc |
@@ -681,6 +681,132 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) { |
} |
} |
+// Both text input and autocomplete should have same direction: test_case#1 |
+TEST_F(FormAutofillTest, DetectTextDirectionFromDirectStyle) { |
+ LoadHTML("<STYLE>input{direction:rtl}</STYLE>" |
+ "<FORM>" |
+ " <INPUT type='text' id='element'>" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
+ |
+ WebElement web_element = frame->document().getElementById("element"); |
+ WebFormControlElement element = web_element.to<WebFormControlElement>(); |
+ |
+ FormFieldData result; |
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
+} |
+ |
+// Both text input and autocomplete should have same direction: test_case#2 |
+TEST_F(FormAutofillTest, DetectTextDirectionFromDirectDIRAttribute) { |
+ LoadHTML("<FORM>" |
+ " <INPUT dir='rtl' type='text' id='element'/>" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
+ |
+ WebElement web_element = frame->document().getElementById("element"); |
+ WebFormControlElement element = web_element.to<WebFormControlElement>(); |
+ |
+ FormFieldData result; |
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
+} |
+ |
+// Both text input and autocomplete should have same direction: test_case#3 |
+TEST_F(FormAutofillTest, DetectTextDirectionFromDirectParentStyle) { |
Ilya Sherman
2014/08/08 04:59:31
nit: "DirectParent" -> "Parent"
Sunil Ratnu
2014/08/08 05:06:24
Done.
|
+ LoadHTML("<STYLE>form{direction:rtl}</STYLE>" |
+ "<FORM>" |
+ " <INPUT type='text' id='element'/>" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
+ |
+ WebElement web_element = frame->document().getElementById("element"); |
+ WebFormControlElement element = web_element.to<WebFormControlElement>(); |
+ |
+ FormFieldData result; |
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
+} |
+ |
+// Both text input and autocomplete should have same direction: test_case#4 |
+TEST_F(FormAutofillTest, DetectTextDirectionFromDirectParentDIRAttribute) { |
Ilya Sherman
2014/08/08 04:59:31
nit: Ditto
Sunil Ratnu
2014/08/08 05:06:24
Done.
|
+ LoadHTML("<FORM dir='rtl'>" |
+ " <INPUT type='text' id='element'/>" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
+ |
+ WebElement web_element = frame->document().getElementById("element"); |
+ WebFormControlElement element = web_element.to<WebFormControlElement>(); |
+ |
+ FormFieldData result; |
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
+} |
+ |
+// Both text input and autocomplete should have same direction: test_case#5 |
+TEST_F(FormAutofillTest, DetectTextDirectionWhenStyleAndDIRAttributMixed) { |
+ LoadHTML("<STYLE>input{direction:ltr}</STYLE>" |
+ "<FORM dir='rtl'>" |
+ " <INPUT type='text' id='element'/>" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
+ |
+ WebElement web_element = frame->document().getElementById("element"); |
+ WebFormControlElement element = web_element.to<WebFormControlElement>(); |
+ |
+ FormFieldData result; |
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
+ EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); |
+} |
+ |
+// Both text input and autocomplete should have same direction: test_case#6 |
Ilya Sherman
2014/08/08 04:59:32
nit: I'd either expand these comments to be more s
Sunil Ratnu
2014/08/08 05:06:24
Removing them entirely as the names are self expla
|
+TEST_F(FormAutofillTest, |
+ DetectTextDirectionWhenParentHaveBothDIRAttributeAndStyle) { |
Ilya Sherman
2014/08/08 04:59:31
nit: "Have" -> "Has"
Sunil Ratnu
2014/08/08 05:06:24
Done.
|
+ LoadHTML("<STYLE>form{direction:ltr}</STYLE>" |
+ "<FORM dir='rtl'>" |
+ " <INPUT type='text' id='element'/>" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
+ |
+ WebElement web_element = frame->document().getElementById("element"); |
+ WebFormControlElement element = web_element.to<WebFormControlElement>(); |
+ |
+ FormFieldData result; |
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
+ EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); |
+} |
+ |
+// Both text input and autocomplete should have same direction: test_case#7 |
+TEST_F(FormAutofillTest, DetectTextDirectionWhenAncestorHaveInlineStyle) { |
Ilya Sherman
2014/08/08 04:59:32
nit: "Have" -> "Has"
Sunil Ratnu
2014/08/08 05:06:24
Done.
|
+ LoadHTML("<FORM style='direction:ltr'>" |
+ " <SPAN dir='rtl'>" |
+ " <INPUT type='text' id='element'/>" |
+ " </SPAN>" |
+ "</FORM>"); |
+ |
+ WebFrame* frame = GetMainFrame(); |
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
+ |
+ WebElement web_element = frame->document().getElementById("element"); |
+ WebFormControlElement element = web_element.to<WebFormControlElement>(); |
+ |
+ FormFieldData result; |
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
+} |
+ |
TEST_F(FormAutofillTest, WebFormElementToFormData) { |
LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
" <LABEL for=\"firstname\">First name:</LABEL>" |