tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug974309.html (2100B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=974309
      5 -->
      6 <head>
      7  <title>Test for Bug 974309</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=974309">Mozilla Bug 974309</a>
     14 <div id="edit_not_table_parent" contenteditable="true"></div>
     15 <div>
     16  <table id="table" border="1" width="100%">
     17    <tbody>
     18      <tr>
     19        <td>a</td>
     20        <td>b</td>
     21        <td>c</td>
     22      </tr>
     23      <tr>
     24        <td>d</td>
     25        <td id="cell">e</td>
     26        <td>f</td>
     27      </tr>
     28      <tr>
     29        <td>g</td>
     30        <td>h</td>
     31        <td>i</td>
     32      </tr>
     33    </tbody>
     34  </table>
     35 </div>
     36 <script type="application/javascript">
     37 
     38 /**
     39 * Test for Bug 974309
     40 *
     41 * Tests that editing a table row fails when the table or row is _not_ a child of a contenteditable node.
     42 * See bug 857487 for tests that cover when the table or row _is_ a child of a contenteditable node.
     43 */
     44 
     45 function getEditor() {
     46  const Ci = SpecialPowers.Ci;
     47  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
     48  return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor);
     49 }
     50 
     51 var cell = document.getElementById("cell");
     52 cell.focus();
     53 
     54 // place caret at end of center cell
     55 var sel = getSelection();
     56 sel.collapse(cell, cell.childNodes.length);
     57 
     58 var table = document.getElementById("table");
     59 
     60 var tableHTML = table.innerHTML;
     61 
     62 var editor = getEditor();
     63 editor.deleteTableRow(1);
     64 
     65 is(table.innerHTML == tableHTML, true, "editor should not modify non-editable table" );
     66 
     67 isnot(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  ",
     68   true, "editor.deleteTableRow(1) should not delete a non-editable row containing the selection");
     69 
     70 </script>
     71 
     72 
     73 </body>
     74 </html>