tor-browser

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

test_bug471722.html (2442B)


      1 <!DOCTYPE HTML>
      2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
      3   - License, v. 2.0. If a copy of the MPL was not distributed with this
      4   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
      5 <html>
      6 <!--
      7 https://bugzilla.mozilla.org/show_bug.cgi?id=471722
      8 -->
      9 
     10 <head>
     11  <title>Test for Bug 471722</title>
     12  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     13  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     14  <script src="/tests/SimpleTest/EventUtils.js"></script>  
     15 </head>
     16 
     17 <body onload="doTest();">
     18  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=471722">Mozilla Bug 471722</a>
     19  <p id="display"></p>
     20  <div id="content" style="display: none">
     21  </div>
     22 
     23  <pre id="test">
     24    <script type="application/javascript">
     25 
     26      /** Test for Bug 471722 */
     27 
     28      SimpleTest.waitForExplicitFinish();
     29 
     30      function doTest() {
     31        var t1 = $("t1");
     32        var editor = SpecialPowers.wrap(t1).editor;
     33 
     34        ok(editor, "able to get editor for the element");
     35        t1.focus();
     36        t1.select();
     37 
     38        try {
     39          // Cut the initial text in the textbox
     40          ok(editor.canCut(), "can cut text");
     41          editor.cut();
     42          is(t1.value, "", "initial text was removed");
     43 
     44          // So now we will have emptied the textfield and the editor will have
     45          // created a padding <br> element for empty editor.
     46          // Check the transaction is in the undo stack...
     47          ok(editor.canUndo, "undo should be available");
     48 
     49          // Undo the cut
     50          editor.undo();
     51          is(t1.value, "minefield", "text reinserted");
     52 
     53          // So now, the cut should be in the redo stack, so executing the redo
     54          // will clear the text once again and reinsert the padding <br>
     55          // element for empty editor that was removed after undo.
     56          // This will require the editor to figure out that we have a padding
     57          // <br> element again...
     58          ok(editor.canRedo, "redo should be available");
     59          editor.redo();
     60 
     61          // Did the editor notice a padding <br> element for empty editor
     62          // reappeared?
     63          is(t1.value, "", "editor found padding <br> element");
     64       } catch (e) {
     65         ok(false, "test failed with error " + e);
     66       }
     67       SimpleTest.finish();
     68     }
     69   </script>
     70  </pre>
     71 
     72  <input type="text" value="minefield" id="t1" />
     73 </body>
     74 </html>