editor/libeditor/html/tests/test_bug857487.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=857487
     5 -->
     6 <head>
     7   <title>Test for Bug 857487</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=857487">Mozilla Bug 857487</a>
    14 <div id="edit" contenteditable="true">
    15   <table id="table" border="1" width="100%">
    16     <tbody>
    17       <tr>
    18         <td>a</td>
    19         <td>b</td>
    20         <td>c</td>
    21       </tr>
    22       <tr>
    23         <td>d</td>
    24         <td id="cell">e</td>
    25         <td>f</td>
    26       </tr>
    27       <tr>
    28         <td>g</td>
    29         <td>h</td>
    30         <td>i</td>
    31       </tr>
    32     </tbody>
    33   </table>
    34 </div>
    35 <script type="application/javascript">
    37 /**
    38  * Test for Bug 857487
    39  *
    40  * Tests that removing a table row through nsIHTMLEditor works
    41  */
    43 function getEditor() {
    44   const Ci = SpecialPowers.Ci;
    45   var editingSession = SpecialPowers.wrap(window)
    46                                     .QueryInterface(Ci.nsIInterfaceRequestor)
    47                                     .getInterface(Ci.nsIWebNavigation)
    48                                     .QueryInterface(Ci.nsIInterfaceRequestor)
    49                                     .getInterface(Ci.nsIEditingSession);
    50   return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor);
    51 }
    53 var cell = document.getElementById("cell");
    54 cell.focus();
    56 // place caret at end of center cell
    57 var sel = getSelection();
    58 sel.collapse(cell, cell.childNodes.length);
    60 var editor = getEditor();
    61 editor.deleteTableRow(1);
    63 var table = document.getElementById("table");
    65 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  ",
    66    true, "editor.deleteTableRow(1) should delete the row containing the selection");
    68 </script>
    71 </body>
    72 </html>

mercurial