editor/libeditor/html/tests/test_bug455992.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug455992.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html><head>
     1.6 +<title>Test for bug 455992</title>
     1.7 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     1.8 +<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.10 +
    1.11 +<script class="testbody" type="application/javascript">
    1.12 +function runTest() {
    1.13 +
    1.14 +  function select(id) {
    1.15 +    var e = document.getElementById(id);
    1.16 +    e.focus();
    1.17 +    return e;
    1.18 +  }
    1.19 +
    1.20 +  function setupIframe(id) {
    1.21 +    var e = document.getElementById(id);
    1.22 +    var doc = e.contentDocument;
    1.23 +    doc.body.innerHTML = String.fromCharCode(10)+'<span id="' + id + '_span" style="border:1px solid blue" contenteditable="true">X</span>'+String.fromCharCode(10);
    1.24 +    e = doc.getElementById(id + "_span");
    1.25 +    e.focus();
    1.26 +    return e;
    1.27 +  }
    1.28 +
    1.29 +  function test_begin_bs(e) {
    1.30 +    const msg = "BACKSPACE at beginning of contenteditable inline element";
    1.31 +    var before = e.parentNode.childNodes[0].nodeValue;
    1.32 +    sendKey("back_space");
    1.33 +    is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
    1.34 +    is(e.innerHTML, "X", msg + " with id=" + e.id);
    1.35 +  }
    1.36 +
    1.37 +  function test_begin_space(e) {
    1.38 +    const msg = "SPACE at beginning of contenteditable inline element";
    1.39 +    var before = e.parentNode.childNodes[0].nodeValue;
    1.40 +    sendChar(" ");
    1.41 +    is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
    1.42 +    is(e.innerHTML, "&nbsp;X", msg + " with id=" + e.id);
    1.43 +  }
    1.44 +
    1.45 +  function test_end_delete(e) {
    1.46 +    const msg = "DEL at end of contenteditable inline element";
    1.47 +    var before = e.parentNode.childNodes[2].nodeValue;
    1.48 +    sendKey("right");
    1.49 +    sendKey("delete");
    1.50 +    is(e.parentNode.childNodes[2].nodeValue, before, msg + " with id=" + e.id);
    1.51 +    is(e.innerHTML, "X", msg + " with id=" + e.id);
    1.52 +  }
    1.53 +
    1.54 +  function test_end_space(e) {
    1.55 +    const msg = "SPACE at end of contenteditable inline element";
    1.56 +    var before = e.parentNode.childNodes[2].nodeValue;
    1.57 +    sendKey("right");
    1.58 +    sendChar(" ");
    1.59 +    is(e.parentNode.childNodes[2].nodeValue, before, msg + " with id=" + e.id);
    1.60 +    is(e.innerHTML, "X" + (e.tagName=="SPAN" ? "&nbsp;" : " <br>"), msg + " with id=" + e.id);
    1.61 +  }
    1.62 +
    1.63 +  test_begin_bs(select("t1"));
    1.64 +  test_begin_space(select("t2"));
    1.65 +  test_end_delete(select("t3"));
    1.66 +  test_end_space(select("t4"));
    1.67 +  test_end_space(select("t5"));
    1.68 +
    1.69 +  test_begin_bs(setupIframe('i1'));
    1.70 +  test_begin_space(setupIframe('i2'));
    1.71 +  test_end_delete(setupIframe('i3'));
    1.72 +  test_end_space(setupIframe('i4'));
    1.73 +
    1.74 +  SimpleTest.finish();
    1.75 +}
    1.76 +
    1.77 +SimpleTest.waitForExplicitFinish();
    1.78 +addLoadEvent(runTest);
    1.79 +</script>
    1.80 +</head>
    1.81 +<body>
    1.82 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=455992">Mozilla Bug 455992</a>
    1.83 +<p id="display"></p>
    1.84 +
    1.85 +<pre id="test">
    1.86 +</pre>
    1.87 +
    1.88 +<div> <span id="t1" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
    1.89 +<div> <span id="t2" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
    1.90 +<div> <span id="t3" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
    1.91 +<div> <span id="t4" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
    1.92 +<div> <div id="t5" style="border:1px solid blue" contenteditable="true">X</div> Y</div>
    1.93 +
    1.94 +<iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
    1.95 +<iframe id="i2" width="200" height="100" src="about:blank"></iframe><br>
    1.96 +<iframe id="i3" width="200" height="100" src="about:blank"></iframe><br>
    1.97 +<iframe id="i4" width="200" height="100" src="about:blank"></iframe><br>
    1.98 +
    1.99 +</body>
   1.100 +</html>

mercurial