Bug 722144 - Allow dblclick on EventUtils.sendMouseEvent. r=smaug
authorReuben Morais <reuben.morais@gmail.com>
Sun, 29 Jan 2012 05:01:00 -0800
changeset 86919 847a2d676b67d0a413101a5164e8a30afad45685
parent 86918 ab27cd7968454471d5d3947d9e5a7c0d8ab38a97
child 86920 4d85f4ff71450cef362b44d0a7bca94270b78043
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs722144
milestone12.0a1
Bug 722144 - Allow dblclick on EventUtils.sendMouseEvent. r=smaug
testing/mochitest/tests/SimpleTest/EventUtils.js
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -27,17 +27,17 @@
 function getElement(id) {
   return ((typeof(id) == "string") ?
     document.getElementById(id) : id); 
 };   
 
 this.$ = this.getElement;
 
 function sendMouseEvent(aEvent, aTarget, aWindow) {
-  if (['click', 'mousedown', 'mouseup', 'mouseover', 'mouseout'].indexOf(aEvent.type) == -1) {
+  if (['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout'].indexOf(aEvent.type) == -1) {
     throw new Error("sendMouseEvent doesn't know about event type '" + aEvent.type + "'");
   }
 
   if (!aWindow) {
     aWindow = window;
   }
 
   if (!(aTarget instanceof Element)) {
@@ -47,17 +47,18 @@ function sendMouseEvent(aEvent, aTarget,
   var event = aWindow.document.createEvent('MouseEvent');
 
   var typeArg          = aEvent.type;
   var canBubbleArg     = true;
   var cancelableArg    = true;
   var viewArg          = aWindow;
   var detailArg        = aEvent.detail        || (aEvent.type == 'click'     ||
                                                   aEvent.type == 'mousedown' ||
-                                                  aEvent.type == 'mouseup' ? 1 : 0);
+                                                  aEvent.type == 'mouseup' ? 1 :
+                                                  aEvent.type == 'dblclick'? 2 : 0);
   var screenXArg       = aEvent.screenX       || 0;
   var screenYArg       = aEvent.screenY       || 0;
   var clientXArg       = aEvent.clientX       || 0;
   var clientYArg       = aEvent.clientY       || 0;
   var ctrlKeyArg       = aEvent.ctrlKey       || false;
   var altKeyArg        = aEvent.altKey        || false;
   var shiftKeyArg      = aEvent.shiftKey      || false;
   var metaKeyArg       = aEvent.metaKey       || false;