editor/libeditor/text/tests/test_bug471319.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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=471319
     8 -->
    10 <head>
    11   <title>Test for Bug 471319</title>
    12   <script type="application/javascript"
    13           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    14   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
    15 </head>
    17 <body onload="doTest();">
    18   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=471319">Mozilla Bug 471319</a>
    19   <p id="display"></p>
    20   <div id="content" style="display: none">
    21   </div>
    23   <pre id="test">
    24     <script type="application/javascript;version=1.7">
    26       /** Test for Bug 471319 **/
    28       SimpleTest.waitForExplicitFinish();
    30       function doTest() {
    31         let t1 = $("t1");
    32         let editor = null;
    34         // Test 1: Undo on an empty editor - the editor should not forget about
    35         // the bogus node
    36         t1.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
    37         t1Editor = t1.editor;
    39         // Did the editor recognize the new bogus node?
    40         t1Editor.undo(1);
    41         ok(!t1.value, "<br> still recognized as bogus node on undo");
    44         // Test 2: Redo on an empty editor - the editor should not forget about
    45         // the bogus node
    46         let t2 = $("t2");
    47         t2.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
    48         t2Editor = t2.editor;
    50         // Did the editor recognize the new bogus node?
    51         t2Editor.redo(1);
    52         ok(!t2.value, "<br> still recognized as bogus node on redo");
    55         // Test 3: Undoing a batched transaction where both end points of the
    56         // transaction are the bogus node - the bogus node should still be
    57         // recognized as bogus
    58         t1Editor.transactionManager.beginBatch(null);
    59         t1.value = "mozilla";
    60         t1.value = "";
    61         t1Editor.transactionManager.endBatch(false);
    62         t1Editor.undo(1);
    63         ok(!t1.value,
    64            "recreated <br> from undo transaction recognized as bogus");
    67         // Test 4: Redoing a batched transaction where both end points of the
    68         // transaction are the bogus node - the bogus node should still be
    69         // recognized as bogus
    70         t1Editor.redo(1);
    71         ok(!t1.value,
    72            "recreated <br> from redo transaction recognized as bogus");
    73         SimpleTest.finish();
    74      }
    75    </script>
    76   </pre>
    78   <input type="text" id="t1" />
    79   <input type="text" id="t2" />
    80 </body>
    81 </html>

mercurial