1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/forms/test/test_bug549170.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=549170 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 549170</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/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 +<body onload="window.setTimeout(runTests, 0);"> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=549170">Mozilla Bug 549170</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 +</div> 1.20 +<input id='i' 1.21 + onmouseup="mouseHandler(event);" 1.22 + onmousedown="mouseHandler(event);"> 1.23 +<textarea id='t' 1.24 + onmouseup="mouseHandler(event);" 1.25 + onmousedown="mouseHandler(event);"></textarea><br> 1.26 +<input id='ip' placeholder='foo' 1.27 + onmouseup="mouseHandler(event);" 1.28 + onmousedown="mouseHandler(event);"> 1.29 +<textarea id='tp' placeholder='foo' 1.30 + onmouseup="mouseHandler(event);" 1.31 + onmousedown="mouseHandler(event);"></textarea> 1.32 +<pre id="test"> 1.33 + 1.34 +<script type="application/javascript"> 1.35 + 1.36 +/** Test for Bug 549170 **/ 1.37 + 1.38 +var gNumberOfMouseEventsCatched = 0; 1.39 + 1.40 +SimpleTest.waitForExplicitFinish(); 1.41 + 1.42 +function mouseHandler(aEvent) 1.43 +{ 1.44 + gNumberOfMouseEventsCatched++; 1.45 + is(SpecialPowers.wrap(aEvent).originalTarget.nodeName, "DIV", "An inner div should be the target of the event"); 1.46 + ok(SpecialPowers.wrap(aEvent).originalTarget.classList.contains("anonymous-div"), "the target div should be the editor div"); 1.47 +} 1.48 + 1.49 +function checkMouseEvents(element) 1.50 +{ 1.51 + gNumberOfMouseEventsCatched = 0; 1.52 + 1.53 + synthesizeMouse(element, 5, 5, {type: "mousedown", button: 0}); 1.54 + synthesizeMouse(element, 5, 5, {type: "mouseup", button: 0}); 1.55 + synthesizeMouse(element, 5, 5, {type: "mousedown", button: 1}); 1.56 + // NOTE: this event is going to copy the buffer on linux, this should not be a problem 1.57 + synthesizeMouse(element, 5, 5, {type: "mouseup", button: 1}); 1.58 + synthesizeMouse(element, 5, 5, {type: "mousedown", button: 2}); 1.59 + synthesizeMouse(element, 5, 5, {type: "mouseup", button: 2}); 1.60 + 1.61 + is(gNumberOfMouseEventsCatched, 6, "Some mouse events have not been catched"); 1.62 +} 1.63 + 1.64 +function runTests() 1.65 +{ 1.66 + checkMouseEvents(document.getElementById('i')); 1.67 + checkMouseEvents(document.getElementById('t')); 1.68 + checkMouseEvents(document.getElementById('ip')); 1.69 + checkMouseEvents(document.getElementById('tp')); 1.70 + 1.71 + SimpleTest.finish(); 1.72 +} 1.73 + 1.74 +</script> 1.75 +</pre> 1.76 +</body> 1.77 +</html>