Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / editor / libeditor / tests / test_bug1053048.html
blob416d6442d66d1cf4ed74711216b6811b8ce2e374
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1053048
5 -->
6 <head>
7 <meta charset="utf-8">
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"));
22 textarea.focus();
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);
52 SimpleTest.finish();
54 </script>
55 </head>
56 <body>
57 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1053048">Mozilla Bug 1053048</a>
58 <p id="display"></p>
59 <div id="content" style="display: none">
61 </div>
63 <textarea id="textarea"
64 style="height: 100px; width: 300px; -moz-appearance: none"
65 spellcheck="false"
66 onkeydown="this.style.display='block'; this.style.height='200px';">foo</textarea>
68 <pre id="test">
69 </pre>
70 </body>
71 </html>