editor/libeditor/html/tests/test_bug456244.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug456244.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html><head>
     1.6 +<title>Test for bug 456244</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_end_bs(e) {
    1.30 +    const msg = "Deleting all text in contenteditable inline element";
    1.31 +    var before = e.parentNode.childNodes[0].nodeValue;
    1.32 +    sendKey("right");
    1.33 +    sendKey("back_space");
    1.34 +    sendKey("back_space");
    1.35 +    is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
    1.36 +    is(e.innerHTML, "", msg + " with id=" + e.id);
    1.37 +  }
    1.38 +
    1.39 +  test_end_bs(select("t1"));
    1.40 +  test_end_bs(setupIframe('i1',0));
    1.41 +
    1.42 +  {
    1.43 +    const msg = "Deleting all text in contenteditable body element";
    1.44 +    var e = document.getElementById('i2');
    1.45 +    var doc = e.contentDocument;
    1.46 +    doc.body.setAttribute("contenteditable", "true");
    1.47 +    doc.body.focus();
    1.48 +    sendKey("right");
    1.49 +    sendKey("back_space");
    1.50 +    is(doc.body.innerHTML, "<br>", msg + " with id=" + e.id);
    1.51 +  }
    1.52 +
    1.53 +  SimpleTest.finish();
    1.54 +}
    1.55 +
    1.56 +SimpleTest.waitForExplicitFinish();
    1.57 +addLoadEvent(runTest);
    1.58 +</script>
    1.59 +</head>
    1.60 +<body>
    1.61 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=456244">Mozilla Bug 456244</a>
    1.62 +<p id="display"></p>
    1.63 +
    1.64 +<pre id="test">
    1.65 +</pre>
    1.66 +
    1.67 +<div> <span id="t1" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
    1.68 +
    1.69 +<iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
    1.70 +<iframe id="i2" width="200" height="100" src="about:blank">X</iframe><br>
    1.71 +
    1.72 +</body>
    1.73 +</html>

mercurial