test_bug857487.html (1692B)
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 src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 <script 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"> 36 37 /** 38 * Test for Bug 857487 39 * 40 * Tests that removing a table row through nsIHTMLEditor works 41 */ 42 43 function getEditor() { 44 const Ci = SpecialPowers.Ci; 45 var editingSession = SpecialPowers.wrap(window).docShell.editingSession; 46 return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor); 47 } 48 49 var cell = document.getElementById("cell"); 50 cell.focus(); 51 52 // place caret at end of center cell 53 var sel = getSelection(); 54 sel.collapse(cell, cell.childNodes.length); 55 56 var editor = getEditor(); 57 editor.deleteTableRow(1); 58 59 var table = document.getElementById("table"); 60 61 is( 62 table.innerHTML.replaceAll(/[ \n]/g, ""), 63 "<tbody><tr><td>a</td><td>b</td><td>c</td></tr><tr><td>g</td><td>h</td><td>i</td></tr></tbody>", 64 "editor.deleteTableRow(1) should delete the row containing the selection" 65 ); 66 67 </script> 68 69 70 </body> 71 </html>