Browser Test for Autocomplete's confusion about direction if inline style and...

Browser Test for Autocomplete's confusion about direction if inline style and inherited dir attribute are mixed.

This patch provides browser_tests for the corresponding blink patch:
https://codereview.chromium.org/419023007/ which deals with the Bug:Autocomplete
confused about direction if inline style and inherited dir attribute is mixed.

BUG=397831

Review URL: https://codereview.chromium.org/446843002

Cr-Commit-Position: refs/heads/master@{#288318}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288318 0039d316-1c4b-4281-b951-d872f2087c98
parent c48bc24e
...@@ -681,6 +681,125 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) { ...@@ -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) { TEST_F(FormAutofillTest, WebFormElementToFormData) {
LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
" <LABEL for=\"firstname\">First name:</LABEL>" " <LABEL for=\"firstname\">First name:</LABEL>"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment