Bug 1255955 - Rename a11y functions check* to assert*; r=automatedtester, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 05 Aug 2016 11:43:40 +0100
changeset 347768 6b1c452bd581489d196104419e6b90cee1a9c4f4
parent 347767 fc55305fb268a9bc21654175e17df5118bed007d
child 347769 4371df1f298aaf24ea09459e9df22bea04fdef91
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1255955
milestone50.0a2
Bug 1255955 - Rename a11y functions check* to assert*; r=automatedtester, a=test-only "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
@@ -658,18 +658,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);