Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / editor / libeditor / tests / test_bug332636.html
blob6fc255f7d613b168a1e8bef478d62aa861b524ae
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=332636
5 -->
6 <head>
7 <title>Test for Bug 332636</title>
8 <script src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 <script src="/tests/SimpleTest/EventUtils.js"></script>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=332636">Mozilla Bug 332636</a>
14 <p id="display"></p>
15 <div id="content">
16 <div id="edit0" contenteditable="true">axb</div><!-- reference: plane 0 base character -->
17 <div id="edit1" contenteditable="true">a&#x0308;b</div><!-- reference: plane 0 diacritic -->
18 <div id="edit2" contenteditable="true">a&#x10400;b</div><!-- plane 1 base character -->
19 <div id="edit3" contenteditable="true">a&#x10a0f;b</div><!-- plane 1 diacritic -->
21 <div id="edit0b" contenteditable="true">axb</div><!-- reference: plane 0 base character -->
22 <div id="edit1b" contenteditable="true">a&#x0308;b</div><!-- reference: plane 0 diacritic -->
23 <div id="edit2b" contenteditable="true">a&#x10400;b</div><!-- plane 1 base character -->
24 <div id="edit3b" contenteditable="true">a&#x10a0f;b</div><!-- plane 1 diacritic -->
25 </div>
26 <pre id="test">
27 <script type="application/javascript">
29 /** Test for Bug 332636 **/
31 SimpleTest.waitForExplicitFinish();
32 addLoadEvent(runTest);
34 function test(edit) {
35 edit.focus();
36 var sel = window.getSelection();
37 sel.collapse(edit.childNodes[0], edit.textContent.length - 1);
38 synthesizeKey("KEY_Backspace");
39 is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
42 function testWithMove(edit, offset) {
43 edit.focus();
44 var sel = window.getSelection();
45 sel.collapse(edit.childNodes[0], 0);
46 var i;
47 for (i = 0; i < offset; ++i) {
48 synthesizeKey("KEY_ArrowRight");
49 synthesizeKey("KEY_ArrowLeft");
50 synthesizeKey("KEY_ArrowRight");
52 synthesizeKey("KEY_Backspace");
53 is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
56 function runTest() {
57 /* test backspace-deletion of the middle character */
58 test(document.getElementById("edit0"));
59 test(document.getElementById("edit1"));
60 test(document.getElementById("edit2"));
61 test(document.getElementById("edit3"));
63 /* extra tests with the use of RIGHT and LEFT to get to the right place */
64 testWithMove(document.getElementById("edit0b"), 2);
65 testWithMove(document.getElementById("edit1b"), 1);
66 testWithMove(document.getElementById("edit2b"), 2);
67 testWithMove(document.getElementById("edit3b"), 1);
69 SimpleTest.finish();
72 </script>
73 </pre>
74 </body>
75 </html>