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

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: 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..af4327b1a6dd9e987281d81690ea2345e904d307 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -681,6 +681,103 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) {
}
}
+// Both text input and autocomplete should have same direction.
+TEST_F(FormAutofillTest,
+ WebFormControlElementToFormFieldAutocompleteDirection) {
Ilya Sherman 2014/08/06 20:45:21 nit: This line should be indented more, like so:
+ WebFrame* frame = NULL;
+ LoadHTML("<STYLE>input{direction:rtl}</STYLE>"
+ "<FORM autocomplete=\"on\">"
+ " <INPUT type=\"text\" id=\"element\" value=\"RTL\"/>"
Ilya Sherman 2014/08/06 20:45:21 nit: It might be cleaner to use single quotes to s
Ilya Sherman 2014/08/06 20:45:21 nit: Please indent by two spaces, rather than by o
+ "</FORM>");
+
+ frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ WebElement web_element = frame->document().getElementById("element");
+ WebFormControlElement element = web_element.to<WebFormControlElement>();
+
+ FormFieldData result1;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result1);
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result1.text_direction);
+
+ LoadHTML("<STYLE>span{direction:rtl}</STYLE>"
+ "<FORM autocomplete=\"on\">"
+ " <SPAN>"
+ " <INPUT type=\"text\" id=\"element\" value=\"RTL\"/>"
+ " </SPAN>"
+ "</FORM>");
Ilya Sherman 2014/08/06 20:45:21 Please write separate TEST_F test cases for each H
+
+ frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ web_element = frame->document().getElementById("element");
+ element = web_element.to<WebFormControlElement>();
+ FormFieldData result2;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result2);
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result2.text_direction);
+
+ LoadHTML("<FORM autocomplete=\"on\">"
+ " <SPAN>"
+ " <INPUT dir=\"rtl\" type=\"text\" id=\"element\" value=\"RTL\"/>"
+ " </SPAN>"
+ "</FORM>");
+
+ frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ web_element = frame->document().getElementById("element");
+ element = web_element.to<WebFormControlElement>();
+ FormFieldData result3;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result3);
+ EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result3.text_direction);
+
+ LoadHTML("<STYLE>input{direction:ltr}</STYLE>"
+ "<FORM dir=\"rtl\" autocomplete=\"on\">"
+ " <INPUT type=\"text\" id=\"element\" value=\"LTR\"/>"
+ "</FORM>");
+
+ frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ web_element = frame->document().getElementById("element");
+ element = web_element.to<WebFormControlElement>();
+ FormFieldData result4;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result4);
+ EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result4.text_direction);
+
+ LoadHTML("<STYLE>span{direction:ltr}</STYLE>"
+ "<FORM autocomplete=\"on\">"
+ " <SPAN dir=\"rtl\">"
+ " <INPUT type=\"text\" id=\"element\" value=\"LTR\"/>"
+ " </SPAN>"
+ "</FORM>");
+
+ frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ web_element = frame->document().getElementById("element");
+ element = web_element.to<WebFormControlElement>();
+ FormFieldData result5;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result5);
+ EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result5.text_direction);
+
+ LoadHTML("<BODY dir=\"rtl\">"
+ "<FORM style=\"direction:ltr\" autocomplete=\"on\">"
+ " <SPAN dir=\"rtl\">"
+ " <INPUT dir=\"ltr\" type=\"text\" id=\"element\" value=\"LTR\"/>"
+ " </SPAN>"
+ "</FORM>");
+
+ frame = GetMainFrame();
+ ASSERT_NE(static_cast<WebFrame*>(NULL), frame);
+
+ web_element = frame->document().getElementById("element");
+ element = web_element.to<WebFormControlElement>();
+ FormFieldData result6;
+ WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result6);
+ EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result6.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