Bug 1347658: Allow negative integers for Marionette pointerMove. r=maja_zf a=testonly
authorDavid Burns <dburns@mozilla.com>
Wed, 15 Mar 2017 22:28:10 +0000
changeset 355366 ba81987804c733a24d0fe4ea206647399e8c65de
parent 355365 055d03b56e147429139d37b4d7e93de0fe3d61be
child 355367 0af82b157012ae9527d6f8e5b5db65ca05314c42
push id6947
push userkwierso@gmail.com
push dateThu, 16 Mar 2017 23:43:32 +0000
treeherdermozilla-esr52@ba81987804c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, testonly
bugs1347658
milestone52.0.1
Bug 1347658: Allow negative integers for Marionette pointerMove. r=maja_zf a=testonly W3C WebDriver spec had incorrectly described that we could only have positive integers when it should have been just Integers. MozReview-Commit-ID: CttUFKiav7q
testing/marionette/action.js
testing/marionette/test_action.js
--- a/testing/marionette/action.js
+++ b/testing/marionette/action.js
@@ -693,21 +693,21 @@ action.Action = class {
         item.duration = actionItem.duration;
         if (typeof item.duration != "undefined"){
           assert.positiveInteger(item.duration,
               error.pprint`Expected 'duration' (${item.duration}) to be >= 0`);
         }
         item.origin = action.PointerOrigin.get(actionItem.origin);
         item.x = actionItem.x;
         if (typeof item.x != "undefined") {
-          assert.positiveInteger(item.x, error.pprint`Expected 'x' (${item.x}) to be >= 0`);
+          assert.integer(item.x, error.pprint`Expected 'x' (${item.x}) to be an Integer`);
         }
         item.y = actionItem.y;
         if (typeof item.y != "undefined") {
-          assert.positiveInteger(item.y, error.pprint`Expected 'y' (${item.y}) to be >= 0`);
+          assert.integer(item.y, error.pprint`Expected 'y' (${item.y}) to be an Integer`);
         }
         break;
 
       case action.PointerCancel:
         throw new UnsupportedOperationError();
         break;
 
       case action.Pause:
@@ -1328,18 +1328,18 @@ function flushEvents(container) {
 }
 
 function capitalize(str) {
   assert.string(str);
   return str.charAt(0).toUpperCase() + str.slice(1);
 }
 
 function inViewPort(x, y, win) {
-  assert.number(x);
-  assert.number(y);
+  assert.number(x, `Expected x to be finite number`);
+  assert.number(y, `Expected y to be finite number`);
   // Viewport includes scrollbars if rendered.
   return !(x < 0 || y < 0 || x > win.innerWidth || y > win.innerHeight);
 }
 
 function getElementCenter(elementReference, seenEls, container) {
   if (element.isWebElementReference(elementReference)) {
     let uuid = elementReference[element.Key] || elementReference[element.LegacyKey];
     let el = seenEls.get(uuid, container);
--- a/testing/marionette/test_action.js
+++ b/testing/marionette/test_action.js
@@ -74,30 +74,33 @@ add_test(function test_validateActionDur
         action.Action.fromJson, [actionSequence, actionItem], message);
   };
   for (let d of [-1, "a"]) {
     actionItem.duration = d;
     check("none", "pause");
     check("pointer", "pointerMove");
   }
   actionItem.duration = 5000;
-  for (let d of [-1, "a"]) {
-    for (let name of ["x", "y"]) {
-      actionItem[name] = d;
-      check("pointer", "pointerMove", `${name}: ${actionItem[name]}`);
-    }
+  for (let name of ["x", "y"]) {
+    actionItem[name] = "a";
+    actionItem.type = "pointerMove";
+    actionSequence.type = "pointer";
+    checkErrors(/Expected '.*' \(.*\) to be an Integer/,
+        action.Action.fromJson, [actionSequence, actionItem],
+        `duration: ${actionItem.duration}, subtype: pointerMove`);
   }
   run_next_test();
 });
 
 add_test(function test_processPointerMoveActionOriginValidation() {
   let actionSequence = {type: "pointer", id: "some_id"};
   let actionItem = {duration: 5000, type: "pointerMove"};
   for (let d of [-1, {a: "blah"}, []]) {
     actionItem.origin = d;
+
     checkErrors(/Expected \'origin\' to be a string or a web element reference/,
         action.Action.fromJson,
         [actionSequence, actionItem],
         `actionItem.origin: (${getTypeString(d)})`);
   }
 
   run_next_test();
 });