Bug 1792802 - Fix accessible tests after previous change. r=Jamie
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 05 Oct 2022 06:59:14 +0000
changeset 636915 c14f7934269f333be9e65958c7a012899b3123bd
parent 636914 df75f29cded6429029ac41e936e25acf3bc82b56
child 636916 19a7766ef397b43751218e6380638e6216e8ecfa
push id40288
push userctuns@mozilla.com
push dateWed, 05 Oct 2022 09:42:33 +0000
treeherdermozilla-central@c14f7934269f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1792802
milestone107.0a1
first release with
nightly linux32
c14f7934269f / 107.0a1 / 20221005094233 / files
nightly linux64
c14f7934269f / 107.0a1 / 20221005094233 / files
nightly mac
c14f7934269f / 107.0a1 / 20221005094233 / files
nightly win32
c14f7934269f / 107.0a1 / 20221005094233 / files
nightly win64
c14f7934269f / 107.0a1 / 20221005094233 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1792802 - Fix accessible tests after previous change. r=Jamie After the previous change, the treecolpicker element only wraps a button and a menu, which are siblings rather than parent/child. I think that's probably fine but it changes the shape of the a11y tree. This patch updates the relevant tests, but let me know if you'd rather keep the behavior. I could do that by either keeping the treecolpicker entry listed in XULMap (I think), or via other means. Suggestions welcome if you think this is not the right fix. Differential Revision: https://phabricator.services.mozilla.com/D158640
accessible/tests/mochitest/table.js
accessible/tests/mochitest/tree/test_tree.xhtml
accessible/tests/mochitest/treeupdate/test_menubutton.xhtml
--- a/accessible/tests/mochitest/table.js
+++ b/accessible/tests/mochitest/table.js
@@ -109,21 +109,22 @@ function testTableStruct(
     for (let idx = 0; idx < colsCount; idx++) {
       var headerCellObj = {
         role: ROLE_COLUMNHEADER,
       };
       headersObj.children.push(headerCellObj);
     }
 
     if (aColHeaderType == kTreeColumnHeader) {
-      var columnPickerObj = {
+      headersObj.children.push({
         role: ROLE_PUSHBUTTON,
-      };
-
-      headersObj.children.push(columnPickerObj);
+      });
+      headersObj.children.push({
+        role: ROLE_MENUPOPUP,
+      });
     }
 
     tableObj.children.push(headersObj);
   }
 
   // rows and cells accessibles
   for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {
     let rowObj = {
--- a/accessible/tests/mochitest/tree/test_tree.xhtml
+++ b/accessible/tests/mochitest/tree/test_tree.xhtml
@@ -70,18 +70,20 @@
         ]
       };
 
       var view = aTree.view;
       var columnCount = aTree.columns.count;
 
       for (let idx = 0; idx < columnCount; idx++)
         accTreeForColumns.children.push({ COLUMNHEADER: [ ] });
-      if (!aTree.hasAttribute("hidecolumnpicker"))
-        accTreeForColumns.children.push({ PUSHBUTTON: [ { MENUPOPUP: [] } ] });
+      if (!aTree.hasAttribute("hidecolumnpicker")) {
+        accTreeForColumns.children.push({ PUSHBUTTON: [ ] });
+        accTreeForColumns.children.push({ MENUPOPUP: [ ] });
+      }
 
       for (let idx = 0; idx < view.rowCount; idx++)
         accTreeForTree.children.push(getTreeItemAccTree(aRole, columnCount));
 
       testAccessibleTree(aTree, accTreeForTree);
     }
 
     /**
--- a/accessible/tests/mochitest/treeupdate/test_menubutton.xhtml
+++ b/accessible/tests/mochitest/treeupdate/test_menubutton.xhtml
@@ -17,46 +17,47 @@
           src="../events.js" />
 
   <script type="application/javascript">
   <![CDATA[
 
     ////////////////////////////////////////////////////////////////////////////
     // Invokers
 
-    function openMenu(aButtonID, aMenuItemRole)
+    function openMenu(aButtonID, aIsTree)
     {
-      var menuItemRole = aMenuItemRole || ROLE_MENUITEM;
+      var menuItemRole = aIsTree ? ROLE_CHECK_MENU_ITEM : ROLE_MENUITEM;
       this.button = getAccessible(aButtonID);
-      this.menupopup = this.button.firstChild;
+      this.menupopup = aIsTree ? this.button.nextSibling : this.button.firstChild;
 
       var checker = new invokerChecker(EVENT_REORDER, this.menupopup);
       this.__proto__ = new synthClick(aButtonID, checker);
 
+      let testButton = popup => {
+        var children = [];
+        if (!aIsTree) {
+          children.push(popup);
+        }
+        var tree = { PUSHBUTTON: children };
+        testAccessibleTree(this.button, tree);
+        testAccessibleTree(this.menupop, popup);
+      }
+
       this.invoke = function openMenu_invoke()
       {
-        var tree =
-          { PUSHBUTTON: [
-            { MENUPOPUP: [ ] }
-          ] };
-        testAccessibleTree(this.button, tree);
-
+        testButton({ MENUPOPUP: [ ] });
         this.__proto__.invoke();
       }
 
       this.finalCheck = function openMenu_finalCheck()
       {
-        var tree =
-          { PUSHBUTTON: [
-            { MENUPOPUP: [
-              { role: menuItemRole, children: [ ] },
-              { role: menuItemRole, children: [ ] }
-            ] }
-          ] };
-        testAccessibleTree(this.button, tree);
+        testButton({ MENUPOPUP: [
+          { role: menuItemRole, children: [ ] },
+          { role: menuItemRole, children: [ ] }
+        ] });
 
         synthesizeKey("KEY_Escape");
       }
 
       this.getID = function openMenu_getID()
       {
         return "open menu of the button " + prettyName(aButtonID);
       }
@@ -71,18 +72,18 @@
 
     function doTest()
     {
       gQueue = new eventQueue();
 
       gQueue.push(new openMenu("button1"));
       gQueue.push(new openMenu("button3"));
 
-      var columnPickerBtn = getAccessible("tree").firstChild.lastChild;
-      gQueue.push(new openMenu(columnPickerBtn, ROLE_CHECK_MENU_ITEM));
+      var columnPickerBtn = getAccessible("tree").firstChild.lastChild.previousSibling;
+      gQueue.push(new openMenu(columnPickerBtn, true));
       gQueue.invoke(); // SimpleTest.finish()
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>