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

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

mercurial