Bug 1255955 - Rename a11y functions check* to assert*; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 05 Aug 2016 11:43:40 +0100
changeset 400453 31bec20e5a6cb0aaeb9f6f41d4e65673e05f49f1
parent 400452 10185712aacc7250748ca5b4b044a895c42dc7be
child 400454 7ff15853131bb796277e2843a4f56ad26973a615
push id26147
push userbmo:ato@mozilla.com
push dateSat, 13 Aug 2016 19:00:38 +0000
reviewersautomatedtester
bugs1255955
milestone51.0a1
Bug 1255955 - Rename a11y functions check* to assert*; r?automatedtester "Check" is a fine word but with functions which primary purpose is to throw an error internally we should use "assert" to make the reprecussions of using them crystal clear. MozReview-Commit-ID: Kef4R8y8fiV
testing/marionette/accessibility.js
testing/marionette/interaction.js
testing/marionette/listener.js
--- a/testing/marionette/accessibility.js
+++ b/testing/marionette/accessibility.js
@@ -261,17 +261,17 @@ accessibility.Checks = class {
    *     Element associated with |accessible|.
    * @param {boolean} visible
    *     Visibility state of |element|.
    *
    * @throws ElementNotAccessibleError
    *     If |element|'s visibility state does not correspond to
    *     |accessible|'s.
    */
-  checkVisible(accessible, element, visible) {
+  assertVisible(accessible, element, visible) {
     if (!accessible) {
       return;
     }
 
     let hiddenAccessibility = this.isHidden(accessible);
 
     let message;
     if (visible && hiddenAccessibility) {
@@ -293,17 +293,17 @@ accessibility.Checks = class {
    * @param {DOMElement|XULElement} element
    *     Element associated with |accessible|.
    * @param {boolean} enabled
    *     Enabled state of |element|.
    *
    * @throws ElementNotAccessibleError
    *     If |element|'s enabled state does not match |accessible|'s.
    */
-  checkEnabled(accessible, element, enabled) {
+  assertEnabled(accessible, element, enabled) {
     if (!accessible) {
       return;
     }
 
     let win = element.ownerDocument.defaultView;
     let disabledAccessibility = this.matchState(
         accessible, accessibility.State.Unavailable);
     let explorable = win.getComputedStyle(element)
@@ -328,17 +328,17 @@ accessibility.Checks = class {
    * @param {nsIAccessible} accessible
    *     Accessible object.
    * @param {DOMElement|XULElement} element
    *     Element associated with |accessible|.
    *
    * @throws ElementNotAccessibleError
    *     If it is impossible to activate |element| with |accessible|.
    */
-  checkActionable(accessible, element) {
+  assertActionable(accessible, element) {
     if (!accessible) {
       return;
     }
 
     let message;
     if (!this.hasActionCount(accessible)) {
       message = "Element does not support any accessible actions";
     } else if (!this.isActionableRole(accessible)) {
@@ -363,17 +363,17 @@ accessibility.Checks = class {
    *     Element associated with |accessible|.
    * @param {boolean} selected
    *     The |element|s selected state.
    *
    * @throws ElementNotAccessibleError
    *     If |element|'s selected state does not correspond to
    *     |accessible|'s.
    */
-  checkSelected(accessible, element, selected) {
+  assertSelected(accessible, element, selected) {
     if (!accessible) {
       return;
     }
 
     // element is not selectable via the accessibility API
     if (!this.matchState(accessible, accessibility.State.Selectable)) {
       return;
     }
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.js
@@ -100,22 +100,22 @@ interaction.clickElement = function(el, 
       visible = element.isInteractable(el);
     } else {
       visible = element.isVisible(el);
     }
 
     if (!visible) {
       throw new ElementNotVisibleError("Element is not visible");
     }
-    a11y.checkVisible(acc, el, visible);
+    a11y.assertVisible(acc, el, visible);
     if (!atom.isElementEnabled(el)) {
       throw new InvalidElementStateError("Element is not enabled");
     }
-    a11y.checkEnabled(acc, el, true);
-    a11y.checkActionable(acc, el);
+    a11y.assertEnabled(acc, el, true);
+    a11y.assertActionable(acc, el);
 
     if (element.isXULElement(el)) {
       el.click();
     } else {
       let rects = el.getClientRects();
       let coords = {
         x: rects[0].left + rects[0].width / 2.0,
         y: rects[0].top + rects[0].height / 2.0,
@@ -136,17 +136,17 @@ interaction.clickElement = function(el, 
  *     Flag to enable or disable element visibility tests.
  * @param {boolean=} strict
  *     Enforce strict accessibility tests.
  */
 interaction.sendKeysToElement = function(el, value, ignoreVisibility, strict = false) {
   let win = getWindow(el);
   let a11y = accessibility.get(strict);
   return a11y.getAccessible(el, true).then(acc => {
-    a11y.checkActionable(acc, el);
+    a11y.assertActionable(acc, el);
     event.sendKeysToElement(value, el, {ignoreVisibility: false}, win);
   });
 };
 
 /**
  * Determine the element displayedness of an element.
  *
  * @param {DOMElement|XULElement} el
@@ -158,17 +158,17 @@ interaction.sendKeysToElement = function
  *     True if element is displayed, false otherwise.
  */
 interaction.isElementDisplayed = function(el, strict = false) {
   let win = getWindow(el);
   let displayed = atom.isElementDisplayed(el, win);
 
   let a11y = accessibility.get(strict);
   return a11y.getAccessible(el).then(acc => {
-    a11y.checkVisible(acc, el, displayed);
+    a11y.assertVisible(acc, el, displayed);
     return displayed;
   });
 };
 
 /**
  * Check if element is enabled.
  *
  * @param {DOMElement|XULElement} el
@@ -190,17 +190,17 @@ interaction.isElementEnabled = function(
       }
     }
   } else {
     enabled = atom.isElementEnabled(el, {frame: win});
   }
 
   let a11y = accessibility.get(strict);
   return a11y.getAccessible(el).then(acc => {
-    a11y.checkEnabled(acc, el, enabled);
+    a11y.assertEnabled(acc, el, enabled);
     return enabled;
   });
 };
 
 /**
  * Determines if the referenced element is selected or not.
  *
  * This operation only makes sense on input elements of the Checkbox-
@@ -227,16 +227,16 @@ interaction.isElementSelected = function
       selected = el.selected;
     }
   } else {
     selected = atom.isElementSelected(el, win);
   }
 
   let a11y = accessibility.get(strict);
   return a11y.getAccessible(el).then(acc => {
-    a11y.checkSelected(acc, el, selected);
+    a11y.assertSelected(acc, el, selected);
     return selected;
   });
 };
 
 function getWindow(el) {
   return el.ownerDocument.defaultView;
 }
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -659,18 +659,18 @@ function singleTap(id, corx, cory) {
   // after this block, the element will be scrolled into view
   let visible = element.isVisible(el, corx, cory);
   if (!visible) {
     throw new ElementNotVisibleError("Element is not currently visible and may not be manipulated");
   }
 
   let a11y = accessibility.get(capabilities.raisesAccessibilityExceptions);
   return a11y.getAccessible(el, true).then(acc => {
-    a11y.checkVisible(acc, el, visible);
-    a11y.checkActionable(acc, el);
+    a11y.assertVisible(acc, el, visible);
+    a11y.assertActionable(acc, el);
     if (!curContainer.frame.document.createTouch) {
       actions.mouseEventsOnly = true;
     }
     let c = element.coordinates(el, corx, cory);
     if (!actions.mouseEventsOnly) {
       let touchId = actions.nextTouchId++;
       let touch = createATouch(el, c.x, c.y, touchId);
       emitTouchEvent('touchstart', touch);