editor/libeditor/text/tests/test_bug318065.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/text/tests/test_bug318065.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     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=318065
    1.11 +-->
    1.12 +
    1.13 +<head>
    1.14 +  <title>Test for Bug 318065</title>
    1.15 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.16 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.17 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
    1.18 +</head>
    1.19 +
    1.20 +<body>
    1.21 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=318065">Mozilla Bug 318065</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">
    1.28 +
    1.29 +      /** Test for Bug 318065 **/
    1.30 +      SimpleTest.waitForExplicitFinish();
    1.31 +      SimpleTest.waitForFocus(function() {
    1.32 +        var expectedValues = ["A", "", "A", "", "A", "", "A"];
    1.33 +        var messages = ["Initial text inserted",
    1.34 +                        "Initial text deleted",
    1.35 +                        "Undo of deletion",
    1.36 +                        "Redo of deletion",
    1.37 +                        "Initial text typed",
    1.38 +                        "Undo of typing",
    1.39 +                        "Redo of typing"];
    1.40 +        var step = 0;
    1.41 +
    1.42 +        function onInput() {
    1.43 +          is(this.value, expectedValues[step], messages[step]);
    1.44 +          step++;
    1.45 +          if (step == expectedValues.length) {
    1.46 +            this.removeEventListener("input", onInput, false); 
    1.47 +            SimpleTest.finish();
    1.48 +          }
    1.49 +        }
    1.50 +
    1.51 +        var input = document.getElementById("t1");
    1.52 +        input.addEventListener("input", onInput, false);
    1.53 +        var input2 = document.getElementById("t2");
    1.54 +        input2.addEventListener("input", onInput, false);
    1.55 +
    1.56 +        input.focus();
    1.57 +
    1.58 +        // Tests 0 + 1: Input letter and delete it again
    1.59 +        synthesizeKey("A", {});
    1.60 +        synthesizeKey("VK_BACK_SPACE", {});
    1.61 +
    1.62 +        // Test 2: Undo deletion. Value of input should be "A"
    1.63 +        synthesizeKey("Z", {accelKey: true});
    1.64 +
    1.65 +        // Test 3: Redo deletion. Value of input should be ""
    1.66 +        synthesizeKey("Z", {accelKey: true, shiftKey: true});
    1.67 +
    1.68 +        input2.focus();
    1.69 +
    1.70 +        // Test 4: Input letter
    1.71 +        synthesizeKey("A", {});
    1.72 +
    1.73 +        // Test 5: Undo typing. Value of input should be ""
    1.74 +        synthesizeKey("Z", {accelKey: true});
    1.75 +
    1.76 +        // Test 6: Redo typing. Value of input should be "A"
    1.77 +        synthesizeKey("Z", {accelKey: true, shiftKey: true});
    1.78 +      });
    1.79 +   </script>
    1.80 +  </pre>
    1.81 +
    1.82 +  <input type="text" value="" id="t1" />
    1.83 +  <input type="text" value="" id="t2" />
    1.84 +</body>
    1.85 +</html>

mercurial