4 https://bugzilla.mozilla.org/show_bug.cgi?id=1053048
8 <title>Test for Bug
1053048</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
11 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
12 <script type=
"application/javascript">
14 /** Test for Bug
1053048 **/
15 SimpleTest.waitForExplicitFinish();
16 SimpleTest.waitForFocus(runTests);
18 const nsISelectionListener = SpecialPowers.Ci.nsISelectionListener;
20 async function runTests() {
21 var textarea = SpecialPowers.wrap(document.getElementById(
"textarea"));
24 var editor = textarea.editor;
25 var selectionPrivate = editor.selection;
27 // Move caret to the end of the textarea
28 synthesizeMouse(textarea,
290,
10, {});
29 is(textarea.selectionStart,
3,
"selectionStart should be 3 (after \"foo\
")");
30 is(textarea.selectionEnd,
3,
"selectionEnd should be 3 (after \"foo\
")");
32 // This test **was** trying to check whether a selection listener which
33 // runs while an editor handles an edit action does not stop handling it.
34 // However, this selection listener caught previous selection change
35 // notification immediately before synthesizing the `Enter` key press
36 // unexpectedly. And now, selection listener may not run immediately after
37 // synthesizing the key press. So, we don't need to check whether a
38 // notification actually comes here.
39 let selectionListener = {
40 notifySelectionChanged() {
41 ok(true,
"selectionStart: " + textarea.selectionStart);
42 ok(true,
"selectionEnd: " + textarea.selectionEnd);
45 selectionPrivate.addSelectionListener(selectionListener);
46 synthesizeKey(
"KEY_Enter");
47 is(textarea.selectionStart,
4,
"selectionStart should be 4");
48 is(textarea.selectionEnd,
4,
"selectionEnd should be 4");
49 is(textarea.value,
"foo\n",
"The line break should be appended");
50 selectionPrivate.removeSelectionListener(selectionListener);
57 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1053048">Mozilla Bug
1053048</a>
59 <div id=
"content" style=
"display: none">
63 <textarea id=
"textarea"
64 style=
"height: 100px; width: 300px; -moz-appearance: none"
66 onkeydown=
"this.style.display='block'; this.style.height='200px';">foo
</textarea>