tor-browser

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

test_bug318065.html (2614B)


      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=318065
      8 -->
      9 
     10 <head>
     11  <title>Test for Bug 318065</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>
     18  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=318065">Mozilla Bug 318065</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 318065 */
     27      SimpleTest.waitForExplicitFinish();
     28      SimpleTest.waitForFocus(function() {
     29        var expectedValues = ["A", "", "A", "", "A", "", "A"];
     30        var messages = ["Initial text inserted",
     31                        "Initial text deleted",
     32                        "Undo of deletion",
     33                        "Redo of deletion",
     34                        "Initial text typed",
     35                        "Undo of typing",
     36                        "Redo of typing"];
     37        var step = 0;
     38 
     39        function onInput() {
     40          is(this.value, expectedValues[step], messages[step]);
     41          step++;
     42          if (step == expectedValues.length) {
     43            this.removeEventListener("input", onInput);
     44            SimpleTest.finish();
     45          }
     46        }
     47 
     48        var input = document.getElementById("t1");
     49        input.addEventListener("input", onInput);
     50        var input2 = document.getElementById("t2");
     51        input2.addEventListener("input", onInput);
     52 
     53        input.focus();
     54 
     55        // Tests 0 + 1: Input letter and delete it again
     56        sendString("A");
     57        synthesizeKey("KEY_Backspace");
     58 
     59        // Test 2: Undo deletion. Value of input should be "A"
     60        synthesizeKey("Z", {accelKey: true});
     61 
     62        // Test 3: Redo deletion. Value of input should be ""
     63        synthesizeKey("Z", {accelKey: true, shiftKey: true});
     64 
     65        input2.focus();
     66 
     67        // Test 4: Input letter
     68        sendString("A");
     69 
     70        // Test 5: Undo typing. Value of input should be ""
     71        synthesizeKey("Z", {accelKey: true});
     72 
     73        // Test 6: Redo typing. Value of input should be "A"
     74        synthesizeKey("Z", {accelKey: true, shiftKey: true});
     75      });
     76   </script>
     77  </pre>
     78 
     79  <input type="text" value="" id="t1" />
     80  <input type="text" value="" id="t2" />
     81 </body>
     82 </html>