Bug 1879774 [wpt PR 44524] - WebKit export: Implement field-sizing support for input...
[gecko.git] / layout / generic / test / test_bug288789.html
blob1d52bed70d9fe0088d77813aefb09fc0f89492f7
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=288789
5 -->
6 <head>
7 <title>Test for Bug 288789</title>
8 <script src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script src="/tests/SimpleTest/EventUtils.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=288789">Mozilla Bug 288789</a>
14 <p id="display"></p>
15 <div id="content">
16 <textarea id="ta" dir="rtl">
18 &#x05d0;a&#x05d1;
20 </textarea>
21 <textarea id="tb">
23 abc
25 </textarea>
26 </div>
27 <pre id="test">
28 <script class="testbody" type="text/javascript">
30 /** Test for Bug 288789 **/
32 SimpleTest.waitForExplicitFinish();
34 // This seems to be necessary because the selection is not set up properly otherwise
35 setTimeout(test, 0);
37 function test() {
38 var textarea = $("ta");
40 function collapse(offset) {
41 textarea.selectionStart = offset;
42 textarea.selectionEnd = offset;
45 function testRight(offset) {
46 synthesizeKey("KEY_ArrowRight");
47 is(textarea.selectionStart, offset, "Right movement broken");
50 function testLeft(offset) {
51 synthesizeKey("KEY_ArrowLeft");
52 is(textarea.selectionStart, offset, "Left movement broken");
55 textarea.focus();
56 collapse(0);
57 ok(true, "Testing forward movement in RTL mode");
58 for (var i = 0; i < textarea.textContent.length; ++i) {
59 if (i == 0) {
60 testRight(i);
62 if (textarea.textContent[i] == 'a') {
63 testLeft(i);
64 } else {
65 testLeft(i + 1);
67 if (i == textarea.textContent.length - 1) {
68 testLeft(i + 1);
71 ok(true, "Testing backward movement in RTL mode");
72 for (var i = textarea.textContent.length; i > 0; --i) {
73 if (i == textarea.textContent.length) {
74 testLeft(i);
76 if (i > 0 && textarea.textContent[i - 1] == 'a') {
77 testRight(i);
78 } else {
79 testRight(i - 1);
81 if (i == 1) {
82 testRight(i - 1);
86 textarea = $("tb");
87 textarea.focus();
88 collapse(0);
89 ok(true, "Testing forward movement in LTR mode");
90 for (var i = 0; i < textarea.textContent.length; ++i) {
91 if (i == 0) {
92 testLeft(i);
94 testRight(i + 1);
95 if (i == textarea.textContent.length - 1) {
96 testRight(i + 1);
99 ok(true, "Testing backward movement in LTR mode");
100 for (var i = textarea.textContent.length; i > 0; --i) {
101 if (i == textarea.textContent.length) {
102 testRight(i);
104 testLeft(i - 1);
105 if (i == 1) {
106 testLeft(i - 1);
110 SimpleTest.finish();
113 </script>
114 </pre>
115 </body>
116 </html>