dom/events/test/test_bug930374-chrome.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    10   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
    11   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    12   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
    13 </head>
    14 <body>
    15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=930374">Mozilla Bug 930374</a>
    16 <div id="display">
    17   <input id="input-text">
    18 </div>
    19 <div id="content" style="display: none">
    20 </div>
    21 <pre id="test">
    22   <script type="application/javascript">
    23     SimpleTest.waitForExplicitFinish();
    25     var gKeyPress = null;
    26     function onKeyPress(aEvent)
    27     {
    28       gKeyPress = aEvent;
    29       is(aEvent.target, document.getElementById("input-text"), "input element should have focus");
    30       ok(!aEvent.defaultPrevented, "keypress event should be consumed before keypress event handler");
    31     }
    33     function runTests()
    34     {
    35       document.addEventListener("keypress", onKeyPress, false);
    36       var input = document.getElementById("input-text");
    37       input.focus();
    39       input.addEventListener("input", function (aEvent) {
    40           input.removeEventListener("input", arguments.callee, false);
    41           ok(gKeyPress,
    42              "Test1: keypress event must be fired before an input event");
    43           ok(gKeyPress.defaultPrevented,
    44              "Test1: keypress event's defaultPrevented should be true in chrome even if it's consumed by default action handler of editor");
    45           setTimeout(function () {
    46             ok(gKeyPress.defaultPrevented,
    47                "Test2: keypress event's defaultPrevented should be true after event dispatching finished");
    48             SimpleTest.finish();
    49           }, 0);
    50         }, false);
    52       sendChar("a");
    53     }
    55     SimpleTest.waitForFocus(runTests);
    56   </script>
    57 </pre>
    58 </body>
    59 </html>

mercurial