Bug 1003836 - Don't use createEvent("TouchEvent") to check if TouchEvents are supported r=smaug
authorFabrice Desré <fabrice@mozilla.com>
Fri, 02 May 2014 14:56:18 -0700
changeset 181826 d81fe3476f864d32dc3d13301e500400bfa69ff4
parent 181825 de2fb191111871a47d0912835e4ed42e2403bffc
child 181827 4c45132da6f36ef45c3c3fe6bb09eb76ba9cac9c
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerssmaug
bugs1003836
milestone32.0a1
Bug 1003836 - Don't use createEvent("TouchEvent") to check if TouchEvents are supported r=smaug
dom/browser-element/BrowserElementPanning.js
--- a/dom/browser-element/BrowserElementPanning.js
+++ b/dom/browser-element/BrowserElementPanning.js
@@ -45,32 +45,32 @@ const ContentPanning = {
     addMessageListener("Gesture:DoubleTap", this._recvDoubleTap.bind(this));
     addEventListener("visibilitychange", this._handleVisibilityChange.bind(this));
     kObservedEvents.forEach((topic) => {
       Services.obs.addObserver(this, topic, false);
     });
   },
 
   _setupListenersForPanning: function cp_setupListenersForPanning() {
-    var events;
-    try {
-      content.document.createEvent('TouchEvent');
+    let events;
+
+    if (content.TouchEvent) {
       events = ['touchstart', 'touchend', 'touchmove'];
       this.watchedEventsType = 'touch';
 #ifdef MOZ_WIDGET_GONK
       // The gonk widget backend does not deliver mouse events per
       // spec.  Third-party content isn't exposed to this behavior,
       // but that behavior creates some extra work for us here.
       let appInfo = Cc["@mozilla.org/xre/app-info;1"];
       let isParentProcess =
         !appInfo || appInfo.getService(Ci.nsIXULRuntime)
                            .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
       this.hybridEvents = isParentProcess;
 #endif
-    } catch(e) {
+    } else {
       // Touch events aren't supported, so fall back on mouse.
       events = ['mousedown', 'mouseup', 'mousemove'];
       this.watchedEventsType = 'mouse';
     }
 
     let els = Cc["@mozilla.org/eventlistenerservice;1"]
                 .getService(Ci.nsIEventListenerService);