tor-browser

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

test_bug930374-chrome.html (1904B)


      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="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/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">
     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 true in chrome even if it's consumed by default action handler of editor");
     43          setTimeout(function () {
     44            ok(gKeyPress.defaultPrevented,
     45               "Test2: keypress event's defaultPrevented should be true after event dispatching finished");
     46            SimpleTest.finish();
     47          }, 0);
     48        }, {once: true});
     49 
     50      sendChar("a");
     51    }
     52 
     53    SimpleTest.waitForFocus(runTests);
     54  </script>
     55 </pre>
     56 </body>
     57 </html>