editor/libeditor/html/tests/test_bug487524.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug487524.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,65 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html><head>
     1.6 +<title>Test for bug 487524</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 setupIframe(e,html,focus_id) {
    1.15 +    var doc = e.contentDocument;
    1.16 +    doc.body.innerHTML = html;
    1.17 +    doc.designMode = "on";
    1.18 +    e = doc.getElementById(focus_id);
    1.19 +    doc.defaultView.focus();
    1.20 +    if (e) e.focus();
    1.21 +    return e;
    1.22 +  }
    1.23 +
    1.24 +  var i1 = document.getElementById('i1')
    1.25 +  var li1 = setupIframe(i1,'<ul><li id="li1">one</li><li>two</li><ul><li>a</li></ul></ul>','li1')
    1.26 +  var doc = li1.ownerDocument;
    1.27 +
    1.28 +  var selection = doc.defaultView.getSelection();
    1.29 +  selection.removeAllRanges();
    1.30 +
    1.31 +  var range = doc.createRange();
    1.32 +  range.setStart(li1,0);
    1.33 +  range.setEnd(li1.nextSibling,0);
    1.34 +  selection.addRange(range);
    1.35 +
    1.36 +  sendKey('delete');
    1.37 +  is(doc.body.innerHTML,'<ul><li>two</li><ul><li>a</li></ul></ul>','delete 1st LI');
    1.38 +
    1.39 +  var li2 = setupIframe(i1,'<ul><li id="li2">two</li><ul><li>a</li></ul></ul>','li2')
    1.40 +  selection = doc.defaultView.getSelection();
    1.41 +  selection.removeAllRanges();
    1.42 +
    1.43 +  range = doc.createRange();
    1.44 +  range.setStart(li2,0);
    1.45 +  range.setEnd(li2.nextSibling.firstChild,0);
    1.46 +  selection.addRange(range);
    1.47 +
    1.48 +  sendKey('delete');
    1.49 +  is(doc.body.innerHTML,'<ul><ul><li>a</li></ul></ul>','delete 2nd LI');
    1.50 +
    1.51 +  SimpleTest.finish();
    1.52 +}
    1.53 +
    1.54 +SimpleTest.waitForExplicitFinish();
    1.55 +addLoadEvent(runTest);
    1.56 +</script>
    1.57 +</head>
    1.58 +<body>
    1.59 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=487524">Mozilla Bug 487524</a>
    1.60 +<p id="display"></p>
    1.61 +
    1.62 +<pre id="test">
    1.63 +</pre>
    1.64 +
    1.65 +<iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
    1.66 +
    1.67 +</body>
    1.68 +</html>

mercurial