editor/libeditor/html/tests/test_bug857487.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug857487.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=857487
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 857487</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=857487">Mozilla Bug 857487</a>
    1.17 +<div id="edit" contenteditable="true">
    1.18 +  <table id="table" border="1" width="100%">
    1.19 +    <tbody>
    1.20 +      <tr>
    1.21 +        <td>a</td>
    1.22 +        <td>b</td>
    1.23 +        <td>c</td>
    1.24 +      </tr>
    1.25 +      <tr>
    1.26 +        <td>d</td>
    1.27 +        <td id="cell">e</td>
    1.28 +        <td>f</td>
    1.29 +      </tr>
    1.30 +      <tr>
    1.31 +        <td>g</td>
    1.32 +        <td>h</td>
    1.33 +        <td>i</td>
    1.34 +      </tr>
    1.35 +    </tbody>
    1.36 +  </table>
    1.37 +</div>
    1.38 +<script type="application/javascript">
    1.39 +
    1.40 +/**
    1.41 + * Test for Bug 857487
    1.42 + *
    1.43 + * Tests that removing a table row through nsIHTMLEditor works
    1.44 + */
    1.45 +
    1.46 +function getEditor() {
    1.47 +  const Ci = SpecialPowers.Ci;
    1.48 +  var editingSession = SpecialPowers.wrap(window)
    1.49 +                                    .QueryInterface(Ci.nsIInterfaceRequestor)
    1.50 +                                    .getInterface(Ci.nsIWebNavigation)
    1.51 +                                    .QueryInterface(Ci.nsIInterfaceRequestor)
    1.52 +                                    .getInterface(Ci.nsIEditingSession);
    1.53 +  return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor);
    1.54 +}
    1.55 +
    1.56 +var cell = document.getElementById("cell");
    1.57 +cell.focus();
    1.58 +
    1.59 +// place caret at end of center cell
    1.60 +var sel = getSelection();
    1.61 +sel.collapse(cell, cell.childNodes.length);
    1.62 +
    1.63 +var editor = getEditor();
    1.64 +editor.deleteTableRow(1);
    1.65 +
    1.66 +var table = document.getElementById("table");
    1.67 +
    1.68 +is(table.innerHTML == "\n    <tbody>\n      <tr>\n        <td>a</td>\n        <td>b</td>\n        <td>c</td>\n      </tr>\n      \n      <tr>\n        <td>g</td>\n        <td>h</td>\n        <td>i</td>\n      </tr>\n    </tbody>\n  ",
    1.69 +   true, "editor.deleteTableRow(1) should delete the row containing the selection");
    1.70 +
    1.71 +</script>
    1.72 +
    1.73 +
    1.74 +</body>
    1.75 +</html>

mercurial