|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=240933 |
|
5 --> |
|
6 |
|
7 <head> |
|
8 <title>Test for Bug 240933</title> |
|
9 <script type="application/javascript" src="/MochiKit/MochiKit.js"></script> |
|
10 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
11 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
13 </head> |
|
14 |
|
15 <body> |
|
16 <a target="_blank" |
|
17 href="https://bugzilla.mozilla.org/show_bug.cgi?id=240933"> |
|
18 Mozilla Bug 240933 |
|
19 </a> |
|
20 <p id="display"></p> |
|
21 <div id="content" style="display: none"> |
|
22 </div> |
|
23 |
|
24 <pre id="test"> |
|
25 <script type="application/javascript"> |
|
26 |
|
27 /** Test for Bug 240933 **/ |
|
28 |
|
29 SimpleTest.waitForExplicitFinish(); |
|
30 |
|
31 SimpleTest.waitForFocus(function() { |
|
32 var t = document.getElementById("t"); |
|
33 synthesizeMouse(t, t.clientWidth / 2, 5, {}, window); |
|
34 is(t.selectionStart, 3, "The selection should be set before the newline"); |
|
35 is(t.selectionEnd, 3, "The selection should be set before the newline"); |
|
36 |
|
37 t = document.getElementById("ta"); |
|
38 t.focus(); |
|
39 t.selectionStart = t.selectionEnd = t.value.length; |
|
40 var val = t.value; |
|
41 synthesizeKey("VK_RETURN", {}); |
|
42 is(t.value, val + "\n", "Pressing enter right after focusing the textarea should work"); |
|
43 |
|
44 t = document.getElementById("tb"); |
|
45 t.focus(); |
|
46 synthesizeKey("VK_RETURN", {}); |
|
47 is(t.value, "\n", "Pressing enter for the first time should work"); |
|
48 synthesizeKey("VK_RETURN", {}); |
|
49 is(t.value, "\n\n", "Pressing enter for the second time should work"); |
|
50 synthesizeKey("VK_BACK_SPACE", {}); |
|
51 is(t.value, "\n", "Pressing backspace for the first time should work"); |
|
52 synthesizeKey("VK_BACK_SPACE", {}); |
|
53 is(t.value, "", "Pressing backspace for the second time should work"); |
|
54 SimpleTest.finish(); |
|
55 }); |
|
56 |
|
57 </script> |
|
58 </pre> |
|
59 |
|
60 <textarea id="t" rows="10" cols="10">abc |
|
61 </textarea> |
|
62 <textarea id="ta" rows="10" cols="10"> |
|
63 test |
|
64 |
|
65 </textarea> |
|
66 <textarea id="tb" rows="10" cols="10"></textarea> |
|
67 |
|
68 </body> |
|
69 </html> |