editor/libeditor/html/tests/test_bug332636.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug332636.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=332636
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 332636</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=332636">Mozilla Bug 332636</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content">
    1.19 +  <div id="edit0" contenteditable="true">axb</div><!-- reference: plane 0 base character -->
    1.20 +  <div id="edit1" contenteditable="true">a&#x0308;b</div><!-- reference: plane 0 diacritic -->
    1.21 +  <div id="edit2" contenteditable="true">a&#x10400;b</div><!-- plane 1 base character -->
    1.22 +  <div id="edit3" contenteditable="true">a&#x10a0f;b</div><!-- plane 1 diacritic -->
    1.23 +
    1.24 +  <div id="edit0b" contenteditable="true">axb</div><!-- reference: plane 0 base character -->
    1.25 +  <div id="edit1b" contenteditable="true">a&#x0308;b</div><!-- reference: plane 0 diacritic -->
    1.26 +  <div id="edit2b" contenteditable="true">a&#x10400;b</div><!-- plane 1 base character -->
    1.27 +  <div id="edit3b" contenteditable="true">a&#x10a0f;b</div><!-- plane 1 diacritic -->
    1.28 +</div>
    1.29 +<pre id="test">
    1.30 +<script type="application/javascript">
    1.31 +
    1.32 +/** Test for Bug 332636 **/
    1.33 +
    1.34 +SimpleTest.waitForExplicitFinish();
    1.35 +addLoadEvent(runTest);
    1.36 +
    1.37 +function test(edit) {
    1.38 +  edit.focus();
    1.39 +  var sel = window.getSelection();
    1.40 +  sel.collapse(edit.childNodes[0], edit.textContent.length - 1);
    1.41 +  synthesizeKey("VK_BACK_SPACE", {});
    1.42 +  is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
    1.43 +}
    1.44 +
    1.45 +function testWithMove(edit, offset) {
    1.46 +  edit.focus();
    1.47 +  var sel = window.getSelection();
    1.48 +  sel.collapse(edit.childNodes[0], 0);
    1.49 +  var i;
    1.50 +  for (i = 0; i < offset; ++i) {
    1.51 +    synthesizeKey("VK_RIGHT", {});
    1.52 +    synthesizeKey("VK_LEFT", {});
    1.53 +    synthesizeKey("VK_RIGHT", {});
    1.54 +  }
    1.55 +  synthesizeKey("VK_BACK_SPACE", {});
    1.56 +  is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly");
    1.57 +}
    1.58 +
    1.59 +function runTest() {
    1.60 +  /* test backspace-deletion of the middle character */
    1.61 +  test(document.getElementById("edit0"));
    1.62 +  test(document.getElementById("edit1"));
    1.63 +  test(document.getElementById("edit2"));
    1.64 +  test(document.getElementById("edit3"));
    1.65 +
    1.66 +  /* extra tests with the use of RIGHT and LEFT to get to the right place */
    1.67 +  testWithMove(document.getElementById("edit0b"), 2);
    1.68 +  testWithMove(document.getElementById("edit1b"), 1);
    1.69 +  testWithMove(document.getElementById("edit2b"), 2);
    1.70 +  testWithMove(document.getElementById("edit3b"), 1);
    1.71 +
    1.72 +  SimpleTest.finish();
    1.73 +}
    1.74 +
    1.75 +</script>
    1.76 +</pre>
    1.77 +</body>
    1.78 +</html>

mercurial