Bug 1337133 - Remove primary pointer attribute; r?ato draft
authorMaja Frydrychowicz <mjzffr@gmail.com>
Mon, 06 Feb 2017 14:40:13 -0500
changeset 489992 85d4c2390c10897c52cda16f7a16467ad8063470
parent 489991 36955d0c6da4ab7b6dee80c84506caed9abf2981
child 489993 bdbfab2ea83932e5aacf7c725972c176f73d2ee6
push id46964
push userbmo:mjzffr@gmail.com
push dateMon, 27 Feb 2017 13:49:06 +0000
reviewersato
bugs1337133
milestone54.0a1
Bug 1337133 - Remove primary pointer attribute; r?ato Sync pointer parameters implementation with Webdriver spec. MozReview-Commit-ID: 4DMoUxo648N
testing/marionette/action.js
testing/marionette/test_action.js
--- a/testing/marionette/action.js
+++ b/testing/marionette/action.js
@@ -505,25 +505,22 @@ action.InputState.Null = class Null exte
   }
 };
 
 /**
  * Input state associated with a pointer-type input device.
  *
  * @param {string} subtype
  *     Kind of pointing device: mouse, pen, touch.
- * @param {boolean} primary
- *     Whether the pointing device is primary.
  */
 action.InputState.Pointer = class Pointer extends InputState {
-  constructor(subtype, primary) {
+  constructor(subtype) {
     super();
     this.pressed = new Set();
     this.subtype = subtype;
-    this.primary = primary;
     this.x = 0;
     this.y = 0;
   }
 };
 
 /**
  * Repesents an action for dispatch. Used in |action.Chain| and |action.Sequence|.
  *
@@ -734,49 +731,44 @@ action.Sequence = class extends Array {
   }
 };
 
 /**
  * Represents parameters in an action for a pointer input source.
  *
  * @param {string=} pointerType
  *     Type of pointing device. If the parameter is undefined, "mouse" is used.
- * @param {boolean=} primary
- *     Whether the input source is the primary pointing device.
- *     If the parameter is undefined, true is used.
  */
 action.PointerParameters = class {
-  constructor(pointerType = "mouse", primary = true) {
+  constructor(pointerType = "mouse") {
     this.pointerType = action.PointerType.get(pointerType);
-    assert.boolean(primary);
-    this.primary = primary;
   }
 
   toString() {
-    return `[pointerParameters ${this.pointerType}, primary=${this.primary}]`;
+    return `[pointerParameters ${this.pointerType}]`;
   }
 
   /**
    * @param {?} parametersData
    *     Object that represents pointer parameters.
    *
    * @return {action.PointerParameters}
    *     Validated pointer paramters.
    */
   static fromJson(parametersData) {
     if (typeof parametersData == "undefined") {
       return new action.PointerParameters();
     } else {
-      return new action.PointerParameters(parametersData.pointerType, parametersData.primary);
+      return new action.PointerParameters(parametersData.pointerType);
     }
   }
 };
 
 /**
- * Adds |pointerType| and |primary| attributes to Action |act|. Helper function
+ * Adds |pointerType| attribute to Action |act|. Helper function
  * for |action.Action.fromJson|.
  *
  * @param {string} id
  *     Input source ID.
  * @param {action.PointerParams} pointerParams
  *     Input source pointer parameters.
  * @param {action.Action} act
  *     Action to be updated.
@@ -788,17 +780,16 @@ action.PointerParameters = class {
 action.processPointerAction = function processPointerAction(id, pointerParams, act) {
   let subtype = act.subtype;
   if (action.inputStateMap.has(id) && action.inputStateMap.get(id).subtype !== subtype) {
     throw new InvalidArgumentError(
         `Expected 'id' ${id} to be mapped to InputState whose subtype is ` +
         `${action.inputStateMap.get(id).subtype}, got: ${subtype}`);
   }
   act.pointerType = pointerParams.pointerType;
-  act.primary = pointerParams.primary;
 };
 
 /** Collect properties associated with KeyboardEvent */
 action.Key = class {
   constructor(rawKey) {
     this.key = NORMALIZED_KEY_LOOKUP[rawKey] || rawKey;
     this.code =  KEY_CODE_LOOKUP[rawKey];
     this.location = KEY_LOCATION_LOOKUP[rawKey] || 0;
--- a/testing/marionette/test_action.js
+++ b/testing/marionette/test_action.js
@@ -20,35 +20,31 @@ add_test(function test_createAction() {
   Assert.throws(
       () => new action.Action(1, 2, "sometype"), /Expected string/, "Non-string arguments.");
   ok(new action.Action("id", "sometype", "sometype"));
 
   run_next_test();
 });
 
 add_test(function test_defaultPointerParameters() {
-  let defaultParameters = {pointerType: action.PointerType.Mouse, primary: true};
+  let defaultParameters = {pointerType: action.PointerType.Mouse};
   deepEqual(action.PointerParameters.fromJson(), defaultParameters);
 
   run_next_test();
 });
 
 add_test(function test_processPointerParameters() {
   let check = (regex, message, arg) => checkErrors(
       regex, action.PointerParameters.fromJson, [arg], message);
-  let parametersData = {pointerType: "foo", primary: undefined};
-  let message = `parametersData: [pointerType: ${parametersData.pointerType}, ` +
-      `primary: ${parametersData.primary}]`;
+  let parametersData = {pointerType: "foo"};
+  let message = `parametersData: [pointerType: ${parametersData.pointerType}]`;
   check(/Unknown pointerType/, message, parametersData);
   parametersData.pointerType = "pen";
-  parametersData.primary = "a";
-  check(/Expected \[object String\] "a" to be boolean/, message, parametersData);
-  parametersData.primary = false;
   deepEqual(action.PointerParameters.fromJson(parametersData),
-      {pointerType: action.PointerType.Pen, primary: false});
+      {pointerType: action.PointerType.Pen});
 
   run_next_test();
 });
 
 add_test(function test_processPointerUpDownAction() {
   let actionItem = {type: "pointerDown"};
   let actionSequence = {type: "pointer", id: "some_id"};
   for (let d of [-1, "a"]) {
@@ -149,18 +145,17 @@ add_test(function test_processPointerMov
   run_next_test();
 });
 
 add_test(function test_processPointerAction() {
   let actionSequence = {
     type: "pointer",
     id: "some_id",
     parameters: {
-      pointerType: "touch",
-      primary: false,
+      pointerType: "touch"
     },
   };
   let actionItems = [
     {
       duration: 2000,
       type: "pause",
     },
     {
@@ -178,17 +173,16 @@ add_test(function test_processPointerAct
     equal(actual.subtype, expected.type);
     equal(actual.id, actionSequence.id);
     if (expected.type === "pointerUp") {
       equal(actual.button, expected.button);
     } else {
       equal(actual.duration, expected.duration);
     }
     if (expected.type !== "pause") {
-      equal(actual.primary, actionSequence.parameters.primary);
       equal(actual.pointerType, actionSequence.parameters.pointerType);
     }
   }
 
   run_next_test();
 });
 
 add_test(function test_processPauseAction() {
@@ -288,24 +282,22 @@ add_test(function test_processInputSourc
 
 add_test(function test_processInputSourceActionSequencePointer() {
   let actionItem = {type: "pointerDown", button: 1};
   let actionSequence = {
     type: "pointer",
     id: "9",
     actions: [actionItem],
     parameters: {
-      pointerType: "pen",
-      primary: false,
+      pointerType: "pen"
     },
   };
   let expectedAction = new action.Action(
       actionSequence.id, actionSequence.type, actionItem.type);
   expectedAction.pointerType = actionSequence.parameters.pointerType;
-  expectedAction.primary = actionSequence.parameters.primary;
   expectedAction.button = actionItem.button;
   let actions = action.Sequence.fromJson(actionSequence);
   equal(actions.length, 1);
   deepEqual(actions[0], expectedAction);
   run_next_test();
 });
 
 add_test(function test_processInputSourceActionSequenceKey() {
@@ -344,29 +336,28 @@ add_test(function test_processInputSourc
   equal(acts.length, 1);
   action.inputStateMap.clear();
   run_next_test();
 });
 
 add_test(function test_processPointerActionInputStateMap() {
   let actionItem = {type: "pointerDown"};
   let id = "1";
-  let parameters = {pointerType: "mouse", primary: false};
+  let parameters = {pointerType: "mouse"};
   let a = new action.Action(id, "pointer", actionItem.type);
   let wrongInputState = new action.InputState.Pointer("pause", true);
   action.inputStateMap.set(id, wrongInputState);
   checkErrors(
       /to be mapped to InputState whose subtype is/, action.processPointerAction,
       [id, parameters, a],
       `$subtype ${actionItem.type} with ${wrongInputState.subtype} in inputState`);
   action.inputStateMap.clear();
   let rightInputState = new action.InputState.Pointer("pointerDown", false);
   action.inputStateMap.set(id, rightInputState);
   action.processPointerAction(id, parameters, a);
-  equal(a.primary, parameters.primary);
   action.inputStateMap.clear();
   run_next_test();
 });
 
 add_test(function test_createInputState() {
   for (let kind in action.InputState) {
     let state = new action.InputState[kind]();
     ok(state);
@@ -422,18 +413,17 @@ add_test(function test_extractActionChai
       button: 2,
     },
   ];
   let mouseActionSequence = {
     type: "pointer",
     id: "7",
     actions: mouseActionItems,
     parameters: {
-      pointerType: "touch",
-      primary: false,
+      pointerType: "touch"
     },
   };
   let keyActionItems = [
     {
       type: "keyDown",
       value: "a",
     },
     {