Bug 829566 - have marionette client send right tap event depending on shim, r=jgriffin
authorMalini Das <mdas@mozilla.com>
Wed, 16 Jan 2013 11:40:06 -0500
changeset 128926 43391698ce5e19e62172c4ee5c748e1a4d117644
parent 128916 f2912b7e727a627e0f9fe327e857efd8e0bbe144
child 128927 abd216c2ded312961abb828844980d474768f46b
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs829566
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 829566 - have marionette client send right tap event depending on shim, r=jgriffin
testing/marionette/client/marionette/marionette_touch.py
testing/marionette/client/marionette/touch/synthetic_gestures.js
testing/marionette/client/setup.py
--- a/testing/marionette/client/marionette/marionette_touch.py
+++ b/testing/marionette/client/marionette/marionette_touch.py
@@ -13,17 +13,20 @@ class MarionetteTouchMixin(object):
     Can specify another library with a path and the name of the library.
     """
     def setup_touch(self, library=None, library_name=None):
         self.library = library or os.path.abspath(os.path.join(__file__, os.pardir, "touch", "synthetic_gestures.js"))
         self.library_name = library_name or "SyntheticGestures"
         self.import_script(self.library)
 
     def tap(self, element):
-        self.execute_script("%s.tap(arguments[0]);" % self.library_name, [element])
+        # we pass in touch/mouse/click events if mouse_event_shim.js isn't included in the gaia app
+        # otherwise, we just send touch events. See Bug 829566
+        send_all = self.execute_script("return typeof window.wrappedJSObject.MouseEventShim === 'undefined';") 
+        self.execute_script("%s.tap(arguments[0], null, null, null, null, arguments[1]);" % self.library_name, [element, send_all])
 
     def double_tap(self, element):
         self.execute_script("%s.dbltap(arguments[0]);" % self.library_name, [element])
 
     def long_press(self, element, holdtime=2000):
         #I'm adding holdtime, since we have support for this, and we don't have chaining yet
         self.execute_script("%s.hold.apply(this, arguments);" % self.library_name, [element, holdtime, 0, 0, 0, 0, 0])
         
--- a/testing/marionette/client/marionette/touch/synthetic_gestures.js
+++ b/testing/marionette/client/marionette/touch/synthetic_gestures.js
@@ -280,32 +280,37 @@ var SyntheticGestures = (function() {
 
 
 
   // Dispatch touchstart and touchend events over the specified target
   // and then invoke the then() callback.
   // x and y are the relative to the viewport.
   // If not specified then the center of the target is used. t is the
   // optional amount of time between touchstart and touchend event.
-  function tap(target, then, x, y, t) {
+  function tap(target, then, x, y, t, sendAll) {
     if (!SyntheticGestures.touchSupported) {
       console.warn('tap: touch events not supported; using mouse instead');
       return mousetap(target, then, x, y, t);
     }
 
     if (x == null)
       x = '50%';
     if (y == null)
       y = '50%';
 
     var c = coordinates(target, x, y);
 
-    touch(target, t || 50, [c.x0, c.x0], [c.y0, c.y0],  function() {
-      mousetap(target, then, x, y, t, true);
-    });
+    if (sendAll) {
+      touch(target, t || 50, [c.x0, c.x0], [c.y0, c.y0],  function() {
+        mousetap(target, then, x, y, t, true);
+      });
+    }
+    else {
+      touch(target, t || 50, [c.x0, c.x0], [c.y0, c.y0], then);
+    }
   }
 
   // Dispatch a dbltap gesture. The arguments are like those to tap()
   // except that interval is the time between taps rather than the time between
   // touchstart and touchend
   function dbltap(target, then, x, y, interval) {
     if (!SyntheticGestures.touchSupported) {
       console.warn('dbltap: touch events not supported; using mouse instead');
--- a/testing/marionette/client/setup.py
+++ b/testing/marionette/client/setup.py
@@ -1,12 +1,12 @@
 import os
 from setuptools import setup, find_packages
 
-version = '0.5.15'
+version = '0.5.16'
 
 # get documentation from the README
 try:
     here = os.path.dirname(os.path.abspath(__file__))
     description = file(os.path.join(here, 'README.md')).read()
 except (OSError, IOError):
     description = ''