test_bug549170.html (2457B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=549170 5 --> 6 <head> 7 <title>Test for Bug 549170</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body onload="window.setTimeout(runTests, 0);"> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=549170">Mozilla Bug 549170</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 </div> 17 <input id='i' 18 onmouseup="mouseHandler(event);" 19 onmousedown="mouseHandler(event);"> 20 <textarea id='t' 21 onmouseup="mouseHandler(event);" 22 onmousedown="mouseHandler(event);"></textarea><br> 23 <input id='ip' placeholder='foo' 24 onmouseup="mouseHandler(event);" 25 onmousedown="mouseHandler(event);"> 26 <textarea id='tp' placeholder='foo' 27 onmouseup="mouseHandler(event);" 28 onmousedown="mouseHandler(event);"></textarea> 29 <pre id="test"> 30 31 <script type="application/javascript"> 32 33 /** Test for Bug 549170 */ 34 35 var gNumberOfMouseEventsCaught = 0; 36 37 SimpleTest.waitForExplicitFinish(); 38 39 function mouseHandler(aEvent) 40 { 41 gNumberOfMouseEventsCaught++; 42 is(SpecialPowers.wrap(aEvent).originalTarget.nodeName, "DIV", "An inner div should be the target of the event"); 43 ok(SpecialPowers.wrap(aEvent).originalTarget.implementedPseudoElement == "::-moz-text-control-editing-root", "the target div should be the editor div"); 44 } 45 46 function checkMouseEvents(element) 47 { 48 gNumberOfMouseEventsCaught = 0; 49 50 let x = element.offsetWidth / 2; 51 let y = element.offsetHeight / 2; 52 53 synthesizeMouse(element, x, y, {type: "mousedown", button: 0}); 54 synthesizeMouse(element, x, y, {type: "mouseup", button: 0}); 55 synthesizeMouse(element, x, y, {type: "mousedown", button: 1}); 56 // NOTE: this event is going to copy the buffer on linux, this should not be a problem 57 synthesizeMouse(element, x, y, {type: "mouseup", button: 1}); 58 synthesizeMouse(element, x, y, {type: "mousedown", button: 2}); 59 synthesizeMouse(element, x, y, {type: "mouseup", button: 2}); 60 61 is(gNumberOfMouseEventsCaught, 6, "Some mouse events have not been caught"); 62 } 63 64 function runTests() 65 { 66 checkMouseEvents(document.getElementById('i')); 67 checkMouseEvents(document.getElementById('t')); 68 checkMouseEvents(document.getElementById('ip')); 69 checkMouseEvents(document.getElementById('tp')); 70 71 SimpleTest.finish(); 72 } 73 74 </script> 75 </pre> 76 </body> 77 </html>