1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug402089.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=402089 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 402089</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.14 +</head> 1.15 +<!-- setTimeout so that the test starts after paint suppression ends --> 1.16 +<body onload="setTimeout(doTest,0);"> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=402089">Mozilla Bug 402089</a> 1.18 +<p id="display"></p> 1.19 +<div id="content"> 1.20 + <pre id="result1"></pre> 1.21 + <pre id="result2"></pre> 1.22 +</div> 1.23 +<pre id="test"> 1.24 +<script class="testbody" type="text/javascript"> 1.25 + 1.26 +/** Test for Bug 402089 **/ 1.27 + 1.28 +var cachedEvent = null; 1.29 + 1.30 +function testCachedEvent() { 1.31 + testEvent('result2'); 1.32 + ok((document.getElementById('result1').textContent == 1.33 + document.getElementById('result2').textContent), 1.34 + "Event coordinates should be the same after dispatching."); 1.35 + SimpleTest.finish(); 1.36 +} 1.37 + 1.38 +function testEvent(res) { 1.39 + var s = cachedEvent.type + "\n"; 1.40 + s += "clientX: " + cachedEvent.clientX + ", clientY: " + cachedEvent.clientY + "\n"; 1.41 + s += "screenX: " + cachedEvent.screenX + ", screenY: " + cachedEvent.screenY + "\n"; 1.42 + s += "layerX: " + cachedEvent.layerX + ", layerY: " + cachedEvent.layerY + "\n"; 1.43 + s += "pageX: " + cachedEvent.pageX + ", pageY: " + cachedEvent.pageY + "\n"; 1.44 + document.getElementById(res).textContent += s; 1.45 +} 1.46 + 1.47 +function clickHandler(e) { 1.48 + cachedEvent = e; 1.49 + testEvent('result1'); 1.50 + e.stopPropagation(); 1.51 + e.preventDefault(); 1.52 + window.removeEventListener("click", clickHandler, true); 1.53 + setTimeout(testCachedEvent, 10); 1.54 +} 1.55 + 1.56 +function doTest() { 1.57 + window.addEventListener("click", clickHandler, true); 1.58 + var utils = SpecialPowers.getDOMWindowUtils(window); 1.59 + utils.sendMouseEvent("mousedown", 1, 1, 0, 1, 0); 1.60 + utils.sendMouseEvent("mouseup", 1, 1, 0, 1, 0); 1.61 + 1.62 +} 1.63 + 1.64 +SimpleTest.waitForExplicitFinish(); 1.65 +</script> 1.66 +</pre> 1.67 +</body> 1.68 +</html> 1.69 +