1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug930374-chrome.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=930374 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 930374</title> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script> 1.14 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.15 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> 1.16 +</head> 1.17 +<body> 1.18 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=930374">Mozilla Bug 930374</a> 1.19 +<div id="display"> 1.20 + <input id="input-text"> 1.21 +</div> 1.22 +<div id="content" style="display: none"> 1.23 +</div> 1.24 +<pre id="test"> 1.25 + <script type="application/javascript"> 1.26 + SimpleTest.waitForExplicitFinish(); 1.27 + 1.28 + var gKeyPress = null; 1.29 + function onKeyPress(aEvent) 1.30 + { 1.31 + gKeyPress = aEvent; 1.32 + is(aEvent.target, document.getElementById("input-text"), "input element should have focus"); 1.33 + ok(!aEvent.defaultPrevented, "keypress event should be consumed before keypress event handler"); 1.34 + } 1.35 + 1.36 + function runTests() 1.37 + { 1.38 + document.addEventListener("keypress", onKeyPress, false); 1.39 + var input = document.getElementById("input-text"); 1.40 + input.focus(); 1.41 + 1.42 + input.addEventListener("input", function (aEvent) { 1.43 + input.removeEventListener("input", arguments.callee, false); 1.44 + ok(gKeyPress, 1.45 + "Test1: keypress event must be fired before an input event"); 1.46 + ok(gKeyPress.defaultPrevented, 1.47 + "Test1: keypress event's defaultPrevented should be true in chrome even if it's consumed by default action handler of editor"); 1.48 + setTimeout(function () { 1.49 + ok(gKeyPress.defaultPrevented, 1.50 + "Test2: keypress event's defaultPrevented should be true after event dispatching finished"); 1.51 + SimpleTest.finish(); 1.52 + }, 0); 1.53 + }, false); 1.54 + 1.55 + sendChar("a"); 1.56 + } 1.57 + 1.58 + SimpleTest.waitForFocus(runTests); 1.59 + </script> 1.60 +</pre> 1.61 +</body> 1.62 +</html>