|
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 type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" 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"> |
|
17 |
|
18 אaב |
|
19 |
|
20 </textarea> |
|
21 <textarea id="tb"> |
|
22 |
|
23 abc |
|
24 |
|
25 </textarea> |
|
26 </div> |
|
27 <pre id="test"> |
|
28 <script class="testbody" type="text/javascript"> |
|
29 |
|
30 /** Test for Bug 288789 **/ |
|
31 |
|
32 SimpleTest.waitForExplicitFinish(); |
|
33 |
|
34 // This seems to be necessary because the selection is not set up properly otherwise |
|
35 setTimeout(test, 0); |
|
36 |
|
37 function test() { |
|
38 var textarea = $("ta"); |
|
39 |
|
40 function collapse(offset) { |
|
41 textarea.selectionStart = offset; |
|
42 textarea.selectionEnd = offset; |
|
43 } |
|
44 |
|
45 function testRight(offset) { |
|
46 synthesizeKey("VK_RIGHT", {}); |
|
47 is(textarea.selectionStart, offset, "Right movement broken"); |
|
48 } |
|
49 |
|
50 function testLeft(offset) { |
|
51 synthesizeKey("VK_LEFT", {}); |
|
52 is(textarea.selectionStart, offset, "Left movement broken"); |
|
53 } |
|
54 |
|
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); |
|
61 } |
|
62 if (textarea.textContent[i] == 'a') { |
|
63 testLeft(i); |
|
64 } else { |
|
65 testLeft(i + 1); |
|
66 } |
|
67 if (i == textarea.textContent.length - 1) { |
|
68 testLeft(i + 1); |
|
69 } |
|
70 } |
|
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); |
|
75 } |
|
76 if (i > 0 && textarea.textContent[i - 1] == 'a') { |
|
77 testRight(i); |
|
78 } else { |
|
79 testRight(i - 1); |
|
80 } |
|
81 if (i == 1) { |
|
82 testRight(i - 1); |
|
83 } |
|
84 } |
|
85 |
|
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); |
|
93 } |
|
94 testRight(i + 1); |
|
95 if (i == textarea.textContent.length - 1) { |
|
96 testRight(i + 1); |
|
97 } |
|
98 } |
|
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); |
|
103 } |
|
104 testLeft(i - 1); |
|
105 if (i == 1) { |
|
106 testLeft(i - 1); |
|
107 } |
|
108 } |
|
109 |
|
110 SimpleTest.finish(); |
|
111 } |
|
112 |
|
113 </script> |
|
114 </pre> |
|
115 </body> |
|
116 </html> |
|
117 |