Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6265)

Unified Diff: chrome/renderer/autofill/form_autofill_browsertest.cc

Issue 446843002: Browser Test: Autocomplete confused about direction if inline style and inherited dir attribute… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review Comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5b8a6f3887fb02c99a466ec44ead1b42cbd6bc82 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -681,6 +681,125 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) {
}
}
+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);
+}
+
+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);
+}
+
+TEST_F(FormAutofillTest, DetectTextDirectionFromParentStyle) {
+ 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);
+}
+
+TEST_F(FormAutofillTest, DetectTextDirectionFromParentDIRAttribute) {
+ 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);
+}
+
+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);
+}
+
+TEST_F(FormAutofillTest,
+ DetectTextDirectionWhenParentHasBothDIRAttributeAndStyle) {
+ 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);
+}
+
+TEST_F(FormAutofillTest, DetectTextDirectionWhenAncestorHasInlineStyle) {
+ 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>"
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698