Bug 1349223 - update marionette a11y test based on the new handling of aria-hidden. r=ato
authorYura Zenevich <yura.zenevich@gmail.com>
Wed, 04 Jul 2018 10:00:07 -0400
changeset 424995 6f9c801d8433778af0b2cb16b1e2e4eafcc79521
parent 424994 2ef78c36287799c24716182e487263a52f9851ad
child 424996 c4171061dc9e9489997821899826512ef45ac6a6
push id104956
push useryura.zenevich@gmail.com
push dateWed, 04 Jul 2018 14:22:31 +0000
treeherdermozilla-inbound@6f9c801d8433 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1349223
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1349223 - update marionette a11y test based on the new handling of aria-hidden. r=ato MozReview-Commit-ID: EsPY9n3vhHL
testing/marionette/accessibility.js
testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
--- a/testing/marionette/accessibility.js
+++ b/testing/marionette/accessibility.js
@@ -265,16 +265,20 @@ accessibility.Checks = class {
    *
    * @param {nsIAccessible} accessible
    *     Accessible object.
    *
    * @return {boolean}
    *     True if element is hidden from user, false otherwise.
    */
   isHidden(accessible) {
+    if (!accessible) {
+      return true;
+    }
+
     while (accessible) {
       if (this.hasHiddenAttribute(accessible)) {
         return true;
       }
       accessible = accessible.parent;
     }
     return false;
   }
@@ -290,20 +294,16 @@ accessibility.Checks = class {
    * @param {boolean} visible
    *     Visibility state of |element|.
    *
    * @throws ElementNotAccessibleError
    *     If |element|'s visibility state does not correspond to
    *     |accessible|'s.
    */
   assertVisible(accessible, element, visible) {
-    if (!accessible) {
-      return;
-    }
-
     let hiddenAccessibility = this.isHidden(accessible);
 
     let message;
     if (visible && hiddenAccessibility) {
       message = "Element is not currently visible via the accessibility API " +
           "and may not be manipulated by it";
     } else if (!visible && !hiddenAccessibility) {
       message = "Element is currently only visible via the accessibility API " +
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
@@ -71,23 +71,28 @@ class TestAccessibility(MarionetteTestCa
     falsy_elements = [
         # Element is only visible to the accessibility API and may be
         # manipulated by it
         "button9",
         # Element is not currently visible
         "button10"
     ]
 
-    displayed_elementIDs = [
-        "button1", "button2", "button3", "button4", "button5", "button6",
+    displayed_elementIDs = ["button1", "button2", "button4", "button5", "button6"]
+
+    displayed_but_have_no_accessible_elementIDs = [
+        # Button3 does not have an accessible object
+        "button3",
+        # Button 7 is hidden with aria-hidden set to true
+        "button7",
+        # Button 8 is inside an element with aria-hidden set to true
+        "button8",
         "no_accessible_but_displayed"
     ]
 
-    displayed_but_a11y_hidden_elementIDs = ["button7", "button8"]
-
     disabled_elementIDs = ["button11", "no_accessible_but_disabled"]
 
     # Elements that are enabled but otherwise disabled or not explorable
     # via the accessibility API
     aria_disabled_elementIDs = ["button12"]
 
     # pointer-events: "none", which will return
     # ElementClickInterceptedException if clicked
@@ -159,17 +164,17 @@ class TestAccessibility(MarionetteTestCa
         # Elements are invisible
         self.run_element_test(self.falsy_elements,
                               lambda button: self.assertRaises(ElementNotInteractableException,
                                                                button.click))
 
     def test_element_visible_but_not_visible_to_accessbility(self):
         self.setup_accessibility()
         # Elements are displayed but hidden from accessibility API
-        self.run_element_test(self.displayed_but_a11y_hidden_elementIDs,
+        self.run_element_test(self.displayed_but_have_no_accessible_elementIDs,
                               lambda element: self.assertRaises(ElementNotAccessibleException,
                                                                 element.is_displayed))
 
     def test_element_is_visible_to_accessibility(self):
         self.setup_accessibility()
         # No exception should be raised
         self.run_element_test(self.displayed_elementIDs, lambda element: element.is_displayed())