tor-browser

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

test_bug930374-content.html (2461B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=930374
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 930374</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="/tests/SimpleTest/EventUtils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=930374">Mozilla Bug 930374</a>
     15 <div id="display">
     16  <input id="input-text" inputmode="none">
     17 </div>
     18 <div id="content" style="display: none">
     19 </div>
     20 <pre id="test">
     21  <script type="application/javascript">
     22    SimpleTest.waitForExplicitFinish();
     23 
     24    var gKeyPress = null;
     25    function onKeyPress(aEvent)
     26    {
     27      gKeyPress = aEvent;
     28      is(aEvent.target, document.getElementById("input-text"), "input element should have focus");
     29      ok(!aEvent.defaultPrevented, "keypress event should be consumed before keypress event handler");
     30    }
     31 
     32    function runTests()
     33    {
     34      document.addEventListener("keypress", onKeyPress);
     35      var input = document.getElementById("input-text");
     36      input.focus();
     37 
     38      input.addEventListener("input", function (aEvent) {
     39          ok(gKeyPress,
     40             "Test1: keypress event must be fired before an input event");
     41          ok(!gKeyPress.defaultPrevented,
     42             "Test1: keypress event's defaultPrevented should be false even though it's consumed by the default action handler of editor");
     43          gKeyPress.preventDefault();
     44          ok(gKeyPress.defaultPrevented,
     45             "Test1: keypress event's defaultPrevented should become true because of a call of preventDefault()");
     46        }, {once: true});
     47 
     48      sendChar("a");
     49      gKeyPress = null;
     50 
     51      input.addEventListener("input", function (aEvent) {
     52          ok(gKeyPress,
     53             "Test2: keypress event must be fired before an input event");
     54          ok(!gKeyPress.defaultPrevented,
     55             "Test2: keypress event's defaultPrevented should be false even though it's consumed by the default action handler of editor");
     56          setTimeout(function () {
     57            ok(!gKeyPress.defaultPrevented,
     58               "Test2: keypress event's defaultPrevented should not become true after event dispatching finished");
     59            SimpleTest.finish();
     60          }, 0);
     61        }, {once: true});
     62 
     63      sendChar("b");
     64    }
     65 
     66    SimpleTest.waitForFocus(runTests);
     67  </script>
     68 </pre>
     69 </body>
     70 </html>