editor/libeditor/html/tests/test_bug332636.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:77f850129c29
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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 <script type="text/javascript" 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 -->
20
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">
28
29 /** Test for Bug 332636 **/
30
31 SimpleTest.waitForExplicitFinish();
32 addLoadEvent(runTest);
33
34 function test(edit) {
35 edit.focus();
36 var sel = window.getSelection();
37 sel.collapse(edit.childNodes[0], edit.textContent.length - 1);
38 synthesizeKey("VK_BACK_SPACE", {});
39 is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
40 }
41
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("VK_RIGHT", {});
49 synthesizeKey("VK_LEFT", {});
50 synthesizeKey("VK_RIGHT", {});
51 }
52 synthesizeKey("VK_BACK_SPACE", {});
53 is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
54 }
55
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"));
62
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);
68
69 SimpleTest.finish();
70 }
71
72 </script>
73 </pre>
74 </body>
75 </html>

mercurial