layout/generic/test/test_bug904810.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:fcb609a74262
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=904810
5 -->
6 <head>
7 <title>Test for Bug 904810</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="text/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=904810">Mozilla Bug 904810</a>
14 <p id="display">
15 <textarea dir="ltr" id="textarea904810">
16 first line
17 second line
18 third line
19 </textarea></p>
20 <div id="content" style="display: none">
21
22 </div>
23 <pre id="test">
24 <script type="application/javascript">
25
26 /** Test for Bug 904810 **/
27
28 SimpleTest.waitForExplicitFinish();
29 SimpleTest.waitForFocus(function test() {
30 function shiftLeft(i) {
31 for ( ; i > 0; --i)
32 synthesizeKey("VK_LEFT", {shiftKey:true});
33 }
34
35 function shiftRight(i) {
36 for ( ; i > 0; --i)
37 synthesizeKey("VK_RIGHT", {shiftKey:true});
38 }
39
40 const isWindows = /WINNT/.test(SpecialPowers.OS);
41
42 var textarea = document.getElementById('textarea904810');
43 textarea.focus();
44
45 // Testing VK_DOWN with forward selection
46 textarea.selectionStart = 1;
47 textarea.selectionEnd = 1;
48 shiftRight(7);
49 synthesizeKey("VK_DOWN", {});
50 if (isWindows) {
51 is(textarea.selectionStart, 19, "caret moved to next line below selection end");
52 is(textarea.selectionEnd, 19, "caret moved to next line below selection end");
53 } else {
54 is(textarea.selectionStart, 8, "caret moved to visual end of selection");
55 is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
56 }
57
58 // Testing VK_DOWN with backward selection
59 textarea.selectionStart = 8;
60 textarea.selectionEnd = 8;
61 shiftLeft(7);
62 synthesizeKey("VK_DOWN", {});
63 if (isWindows) {
64 is(textarea.selectionStart, 12, "caret moved to next line below selection start");
65 is(textarea.selectionEnd, 12, "caret moved to next line below selection start");
66 } else {
67 is(textarea.selectionStart, 8, "caret moved to visual end of selection");
68 is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
69 }
70
71 // Testing VK_UP with forward selection
72 textarea.selectionStart = 12;
73 textarea.selectionEnd = 12;
74 shiftRight(7);
75 synthesizeKey("VK_UP", {});
76 var result = textarea.selectionEnd
77 if (isWindows) {
78 is(textarea.selectionStart, 8, "caret moved to previous line above selection end");
79 is(textarea.selectionEnd, 8, "caret moved to previous line above selection end");
80 } else {
81 is(textarea.selectionStart, 12, "caret moved to visual start of selection");
82 is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
83 }
84
85 // Testing VK_UP with backward selection
86 textarea.selectionStart = 19;
87 textarea.selectionEnd = 19;
88 shiftLeft(7);
89 synthesizeKey("VK_UP", {});
90 var result = textarea.selectionEnd
91 if (isWindows) {
92 is(textarea.selectionStart, 1, "caret moved to previous line above selection start");
93 is(textarea.selectionEnd, 1, "caret moved to previous line above selection start");
94 } else {
95 is(textarea.selectionStart, 12, "caret moved to visual start of selection");
96 is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
97 }
98
99
100
101 SimpleTest.finish();
102 });
103
104
105
106
107 </script>
108 </pre>
109 </body>
110 </html>

mercurial