tor-browser

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

test_bug1268736.html (1708B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1268736
      5 -->
      6 <head>
      7  <title>Test for Bug 1268736</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=1268736">Mozilla Bug 1268736</a>
     14 <table id="table" border="1" width="100%">
     15  <tbody>
     16    <tr>
     17      <td>a</td>
     18      <td>b</td>
     19      <td>c</td>
     20    </tr>
     21    <tr>
     22      <td>d</td>
     23      <td id="cell_readonly">e</td>
     24      <td contenteditable="true" id="cell_writable">f</td>
     25    </tr>
     26  </tbody>
     27 </table>
     28 
     29 <script type="application/javascript">
     30 
     31 /**
     32 * Test for Bug 1268736
     33 *
     34 * Tests for editing a table cell's contents when the table cell is or isn't a child of a contenteditable node.
     35 *
     36 */
     37 
     38 function getEditor() {
     39  const Ci = SpecialPowers.Ci;
     40  const editingSession = SpecialPowers.wrap(window).docShell.editingSession;
     41  return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor);
     42 }
     43 
     44 const table = document.getElementById("table");
     45 const tableHTML = table.innerHTML;
     46 const editor = getEditor();
     47 
     48 const readOnlyCell = document.getElementById("cell_readonly");
     49 readOnlyCell.focus();
     50 try {
     51  editor.deleteTableCellContents();
     52 } catch (e) {}
     53 is(table.innerHTML == tableHTML, true, "editor should not modify non-editable table cell" );
     54 
     55 const editableCell = document.getElementById("cell_writable");
     56 editableCell.focus();
     57 editor.deleteTableCellContents();
     58 is(editableCell.innerHTML == "<br>", true, "editor can modify editable table cells" );
     59 
     60 </script>
     61 </body>
     62 </html>