1<html>
2<head>
3<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
4<script>
5
6function log(str) {
7 var li = document.createElement("li");
8 li.appendChild(document.createTextNode(str));
9 var console = document.getElementById("console");
10 console.appendChild(li);
11}
12
13function assertEqual(test_name, actual, expected)
14{
15 if (actual != expected) {
16 log("==================================");
17 log("FAILED: " + test_name);
18 log("actual: " + actual);
19 log("expected: " + expected);
20 }
21}
22function testCaretPosition(elementId, caretPosition)
23{
24 e = document.getElementById(elementId, caretPosition);
25 e.focus();
26 if (window.textInputController) {
27 var caretRect = textInputController.firstRectForCharacterRange(0, 0);
28 assertEqual(elementId, caretRect[0], caretPosition);
29 }
30}
31
32function runTest()
33{
34 if (window.layoutTestController)
35 layoutTestController.dumpAsText();
36 var e = document.getElementById("right-align-div");
37 e.focus();
38 selectAllCommand();
39 typeCharacterCommand();
40 if (window.textInputController) {
41 var caretRect = textInputController.firstRectForCharacterRange(1, 0);
42 assertEqual("right-align-div", caretRect[0], 208);
43 }
44
45 testCaretPosition("rtl-div", 208);
46 testCaretPosition("0-right-padding-rtl-textarea", 206);
47 testCaretPosition("ltr-div", 9);
48 testCaretPosition("ltr-textarea", 10);
49 testCaretPosition("no-wrapping-right-align-div", 208);
50 testCaretPosition("no-wrapping-rtl-div", 208);
51 testCaretPosition("no-wrapping-0-right-padding-rtl-textarea", 206);
52 testCaretPosition("no-wrapping-ltr-div", 9);
53 testCaretPosition("no-wrapping-ltr-textarea", 10);
54}
55
56</script>
57</head>
58<body>
59<br>
60Right aligned div.
61<br>
62<div CONTENTEDITABLE id="right-align-div" style="text-align: right; width:200px; border: solid thin;"></div>
63<br>
64RTL div.
65<br>
66<div CONTENTEDITABLE id="rtl-div" style="direction: rtl; width:200px; border: solid thin; ">a</div>
67<br>
680px right padding RTL textarea.
69<br>
70<textarea id="0-right-padding-rtl-textarea" style="direction:rtl; padding: 1px 0px 1px 1px; width:200px">a</textarea>
71<br>
72LTR div and textarea.
73<br>
74<div CONTENTEDITABLE id="ltr-div" style="width:200px; border: solid thin; ">a</div>
75<br>
76<textarea id="ltr-textarea" style="padding: 1px 0px 1px 1px; width:200px">a</textarea>
77<br>
78NO WRAPPING
79<br>
80No wrapping right aligned div.
81<br>
82<div CONTENTEDITABLE id="no-wrapping-right-align-div" style="white-space:nowrap; text-align: right; width:200px; border: solid thin;"></div>
83<br>
84No wrapping RTL div.
85<br>
86<div CONTENTEDITABLE id="no-wrapping-rtl-div" style="white-space:nowrap; direction: rtl; width:200px; border: solid thin; ">a</div>
87<br>
88No wrapping 0px right padding RTL textarea.
89<br>
90<textarea id="no-wrapping-0-right-padding-rtl-textarea" style="white-space:nowrap; direction:rtl; padding: 1px 0px 1px 1px; width:200px">a</textarea>
91<br>
92No wrapping LTR div and textarea.
93<br>
94<div CONTENTEDITABLE id="no-wrapping-ltr-div" style="white-space:nowrap; width:200px; border: solid thin; ">a</div>
95<br>
96<textarea id="no-wrapping-ltr-textarea" style="white-space:nowrap; padding: 1px 0px 1px 1px; width:200px">a</textarea>
97<br>
98<ul id="console"></ul>
99</body>
100<script> runTest(); </script>
101</html>