editor/libeditor/text/tests/test_bug471722.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 -->
    10 <head>
    11   <title>Test for Bug 471722</title>
    12   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    13   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    14   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
    15 </head>
    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>
    23   <pre id="test">
    24     <script type="application/javascript">
    26       /** Test for Bug 471722 **/
    28       SimpleTest.waitForExplicitFinish();
    30       function doTest() {
    31         var t1 = $("t1");
    32         var editor = null;
    34         if (t1 instanceof SpecialPowers.Ci.nsIDOMNSEditableElement)
    35           editor = SpecialPowers.wrap(t1).editor;
    36         ok(editor, "able to get editor for the element");
    37         t1.focus();
    38         t1.select();
    40         try {
    42           // Cut the initial text in the textbox
    43           ok(editor.canCut(), "can cut text");
    44           editor.cut();
    45           is(t1.value, "", "initial text was removed");
    47           // So now we will have emptied the textfield
    48           // and the editor will have created a bogus node
    49           // Check the transaction is in the undo stack...
    50           var t1Enabled = {};
    51           var t1CanUndo = {};
    52           editor.canUndo(t1Enabled, t1CanUndo);
    53           ok(t1CanUndo.value, "undo is enabled");
    55           // Undo the cut
    56           editor.undo(1);
    57           is(t1.value, "minefield", "text reinserted");
    59           // So now, the cut should be in the redo stack,
    60           // so executing the redo will clear the text once again
    61           // and reinsert the bogus node that was removed after undo.
    62           // This will require the editor to figure out that we have a
    63           // bogus node again...
    64           var t1CanRedo = {};
    65           editor.canRedo(t1Enabled, t1CanRedo);
    66           ok(t1CanRedo.value, "redo is enabled");
    67           editor.redo(1);
    69           // Did the editor notice a bogus node reappeared?
    70           is(t1.value, "", "editor found bogus node");
    71        } catch (e) {
    72          ok(false, "test failed with error "+e);
    73        }
    74        SimpleTest.finish();
    75      }
    76    </script>
    77   </pre>
    79   <input type="text" value="minefield" id="t1" />
    80 </body>
    81 </html>

mercurial