Bug 1467743 - [marionette] Handle errors for nested promise in dispatchPointerMove. draft
authorHenrik Skupin <mail@hskupin.info>
Fri, 08 Jun 2018 13:11:30 +0200
changeset 805803 9bec994462f4fd8b258dd98b6e19696b97719a4c
parent 805786 e0595117ff5bda3a63a72ad7b3b8754fec4fb4f0
push id112764
push userbmo:hskupin@gmail.com
push dateFri, 08 Jun 2018 14:00:29 +0000
bugs1467743
milestone62.0a1
Bug 1467743 - [marionette] Handle errors for nested promise in dispatchPointerMove. Because the nested promise doesn't use the "catch()" method a possible raised error by its code is not handled, and will cause the outer promise never to resolve, which results in an infinite hang. MozReview-Commit-ID: 1MFyKpmOjYz
testing/marionette/action.js
--- a/testing/marionette/action.js
+++ b/testing/marionette/action.js
@@ -1315,17 +1315,17 @@ function dispatchPointerUp(a, inputState
  *     Promise to dispatch at least one pointermove event, as well as
  *     mousemove events as appropriate.
  */
 function dispatchPointerMove(a, inputState, tickDuration, window) {
   const timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   // interval between pointermove increments in ms, based on common vsync
   const fps60 = 17;
 
-  return new Promise(resolve => {
+  return new Promise((resolve, reject) => {
     const start = Date.now();
     const [startX, startY] = [inputState.x, inputState.y];
 
     let coords = getElementCenter(a.origin, window);
     let target = action.computePointerDestination(a, inputState, coords);
     const [targetX, targetY] = [target.x, target.y];
 
     if (!inViewPort(targetX, targetY, window)) {
@@ -1365,18 +1365,19 @@ function dispatchPointerMove(a, inputSta
       }
     })();
 
     // perform last pointer move after all incremental moves are resolved and
     // durationRatio is close enough to 1
     intermediatePointerEvents.then(() => {
       performOnePointerMove(inputState, targetX, targetY, window);
       resolve();
+    }).catch(err => {
+      reject(err);
     });
-
   });
 }
 
 function performOnePointerMove(inputState, targetX, targetY, win) {
   if (targetX == inputState.x && targetY == inputState.y) {
     return;
   }