editor/libeditor/text/tests/test_bug471319.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/text/tests/test_bug471319.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.8 +<html>
     1.9 +<!--
    1.10 +https://bugzilla.mozilla.org/show_bug.cgi?id=471319
    1.11 +-->
    1.12 +
    1.13 +<head>
    1.14 +  <title>Test for Bug 471319</title>
    1.15 +  <script type="application/javascript"
    1.16 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.17 +  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
    1.18 +</head>
    1.19 +
    1.20 +<body onload="doTest();">
    1.21 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=471319">Mozilla Bug 471319</a>
    1.22 +  <p id="display"></p>
    1.23 +  <div id="content" style="display: none">
    1.24 +  </div>
    1.25 +
    1.26 +  <pre id="test">
    1.27 +    <script type="application/javascript;version=1.7">
    1.28 +
    1.29 +      /** Test for Bug 471319 **/
    1.30 +    
    1.31 +      SimpleTest.waitForExplicitFinish();
    1.32 +
    1.33 +      function doTest() {
    1.34 +        let t1 = $("t1");
    1.35 +        let editor = null;
    1.36 +
    1.37 +        // Test 1: Undo on an empty editor - the editor should not forget about
    1.38 +        // the bogus node
    1.39 +        t1.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
    1.40 +        t1Editor = t1.editor;
    1.41 +
    1.42 +        // Did the editor recognize the new bogus node?
    1.43 +        t1Editor.undo(1);
    1.44 +        ok(!t1.value, "<br> still recognized as bogus node on undo");
    1.45 +
    1.46 +
    1.47 +        // Test 2: Redo on an empty editor - the editor should not forget about
    1.48 +        // the bogus node
    1.49 +        let t2 = $("t2");
    1.50 +        t2.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
    1.51 +        t2Editor = t2.editor;
    1.52 +
    1.53 +        // Did the editor recognize the new bogus node?
    1.54 +        t2Editor.redo(1);
    1.55 +        ok(!t2.value, "<br> still recognized as bogus node on redo");
    1.56 +
    1.57 +
    1.58 +        // Test 3: Undoing a batched transaction where both end points of the
    1.59 +        // transaction are the bogus node - the bogus node should still be
    1.60 +        // recognized as bogus
    1.61 +        t1Editor.transactionManager.beginBatch(null);
    1.62 +        t1.value = "mozilla";
    1.63 +        t1.value = "";
    1.64 +        t1Editor.transactionManager.endBatch(false);
    1.65 +        t1Editor.undo(1);
    1.66 +        ok(!t1.value,
    1.67 +           "recreated <br> from undo transaction recognized as bogus");
    1.68 +
    1.69 +
    1.70 +        // Test 4: Redoing a batched transaction where both end points of the
    1.71 +        // transaction are the bogus node - the bogus node should still be
    1.72 +        // recognized as bogus
    1.73 +        t1Editor.redo(1);
    1.74 +        ok(!t1.value,
    1.75 +           "recreated <br> from redo transaction recognized as bogus");
    1.76 +        SimpleTest.finish();
    1.77 +     }
    1.78 +   </script>
    1.79 +  </pre>
    1.80 +
    1.81 +  <input type="text" id="t1" />
    1.82 +  <input type="text" id="t2" />
    1.83 +</body>
    1.84 +</html>

mercurial