[WK2] Small Caps font variant issue for Italic fonts
[framework/web/webkit-efl.git] / LayoutTests / editing / style / text-indent.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 </head>
5 <body>
6 </body>
7 <script>
8 function testTextIndent(testContent, characterIndex)
9 {
10     document.body.innerHTML = testContent;
11     var editor = document.getElementById('textIndentTest');
12     editor.focus();
13
14     var caretRect = textInputController.firstRectForCharacterRange(0, 0);
15     var caretXPosition_withoutTextRender = caretRect[0];
16
17     editor.setSelectionRange(0, 0);
18     document.execCommand('InsertText', false, 'a');
19
20     caretRect = textInputController.firstRectForCharacterRange(characterIndex, 0);
21     var caretXPosition_withTextRender = caretRect[0];
22     
23     if (caretXPosition_withoutTextRender == caretXPosition_withTextRender)
24         return "Success. The caret's x positions of empty&nonempty input field were the same.\n";
25     else
26         return "Failure. The caret's x position of empty input field was " + caretXPosition_withoutTextRender + ", should have been " + caretXPosition_withTextRender + ".\n"; 
27 }
28
29 function testTextIndentWhenTextAlignsToCenter(textIndent)
30 {
31     document.body.innerHTML = "<input id='textIndentTest' type='text' style='text-align:center;'>";
32     var editor = document.getElementById('textIndentTest');
33     editor.focus();
34
35     var caretRect = textInputController.firstRectForCharacterRange(0, 0);
36     var caretXPosition_withoutTextIndent = caretRect[0];
37
38     editor.blur();
39     editor.style.textIndent = textIndent + "px";
40     editor.focus();
41
42     caretRect = textInputController.firstRectForCharacterRange(0, 0);
43     var caretXPosition_withTextIndent = caretRect[0];
44
45     var desiredCaretXPosition = caretXPosition_withoutTextIndent + textIndent / 2;
46     if (desiredCaretXPosition == caretXPosition_withTextIndent)
47         return "Success. The caret's x positions was set to desired position when the text-align is center.\n";
48     else
49         return "Failure. The caret's x position of input field was " + caretXPosition_withTextIndent + ", should have been " + desiredCaretXPosition + ".\n";
50 }
51
52 if (window.testRunner)
53     window.testRunner.dumpAsText();
54
55 var output = "";
56 output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;'></input>", 0);
57 output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:-30px;'>", 0);
58 output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;text-align:left'>", 0);
59 output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;text-align:right'>", 1);
60 output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;direction:rtl;'>", 0);
61 output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;direction:rtl;text-align:right;'>", 0);
62 output += testTextIndentWhenTextAlignsToCenter(30);
63 output += testTextIndentWhenTextAlignsToCenter(-30);
64 document.body.innerText = output;
65 </script>
66 </html>