Bug 535893 - [SeaMonkey 2.1] mochitest-a11y: test_combobox.xul fails; (Av1a) Add support for XPFE autocomplete popup and differently ordered children, Add explicit "no children" checks.
authorSerge Gautherie <sgautherie.bz@free.fr>
Thu, 17 Mar 2011 13:01:25 +0100
changeset 63431 40d2d7bcc30a
parent 63430 e273946b74c8
child 63432 d0e5ba1e0bbb
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
bugs535893
milestone2.0b13pre
Bug 535893 - [SeaMonkey 2.1] mochitest-a11y: test_combobox.xul fails; (Av1a) Add support for XPFE autocomplete popup and differently ordered children, Add explicit "no children" checks. f=neil r=surkov.alexander (a=test-only).
accessible/tests/mochitest/tree/test_combobox.xul
--- a/accessible/tests/mochitest/tree/test_combobox.xul
+++ b/accessible/tests/mochitest/tree/test_combobox.xul
@@ -1,17 +1,17 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL menulist and textbox @autocomplete hierarchy tests">
 
-  <script type="application/javascript" 
+  <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
@@ -28,110 +28,213 @@
 
       var accTree = {
         role: ROLE_COMBOBOX,
         children: [
           {
             role: ROLE_COMBOBOX_LIST,
             children: [
               {
-                role: ROLE_COMBOBOX_OPTION
+                role: ROLE_COMBOBOX_OPTION,
+                children: []
               },
               {
-                role: ROLE_COMBOBOX_OPTION
+                role: ROLE_COMBOBOX_OPTION,
+                children: []
               }
             ]
           }
         ]
       };
+
       testAccessibleTree("menulist", accTree);
 
       //////////////////////////////////////////////////////////////////////////
       // editable menulist
 
       accTree = {
         role: ROLE_COMBOBOX,
         children: [
           {
             role: ROLE_ENTRY,
-            children: [ ] // no text leaf accessible for text node
+            children: [
+              // no text leaf accessible for text node
+            ]
           },
           {
             role: ROLE_COMBOBOX_LIST, // context menu
             children: []
           },
           {
             role: ROLE_PUSHBUTTON, // dropmarker
+            children: []
           },
           {
             role: ROLE_COMBOBOX_LIST, // option list
             children: [
               {
-                role: ROLE_COMBOBOX_OPTION
+                role: ROLE_COMBOBOX_OPTION,
+                children: []
               },
               {
-                role: ROLE_COMBOBOX_OPTION
+                role: ROLE_COMBOBOX_OPTION,
+                children: []
               }
             ]
           }
         ]
       };
 
       // XXX Bug 551957
       if (!MAC) {
         testAccessibleTree("menulist2", accTree);
       }
 
       //////////////////////////////////////////////////////////////////////////
       // textbox@type=autocomplete #1 (history)
 
       accTree = {
+        // textbox
         role: ROLE_AUTOCOMPLETE,
         children: [
           {
+            // html:input
             role: ROLE_ENTRY,
             children: [
               {
+                // #text
                 role: ROLE_TEXT_LEAF,
-                name: "http://mochi.test:8888/redirect-a11y.html"
+                name: "http://mochi.test:8888/redirect-a11y.html",
+                children: []
               }
             ]
           },
           {
+            // xul:menupopup
             role: ROLE_COMBOBOX_LIST, // context menu popup
-            children: [ ]
+            children: []
           }
         ]
       };
+
+      // XPFE and Toolkit autocomplete widgets differ.
+      var ac1h = document.getElementById("autocomplete");
+      if ("clearResults" in ac1h) {
+        SimpleTest.ok(true, "Testing (Old) XPFE autocomplete widget. (ac1h)");
+
+        // Popup is always created.
+        accTree.children.push(
+          {
+            // xul:panel
+            role: ROLE_COMBOBOX_LIST,
+            children: [
+              {
+                // xul:tree
+                role: ROLE_TABLE,
+                children: [
+                  {
+                    // xul:treecols
+                    role: ROLE_LIST,
+                    children: [
+                      {
+                        // xul:treecol
+                        role: ROLE_COLUMNHEADER,
+                        children: []
+                      }
+                    ]
+                  }
+                ]
+              }
+            ]
+          }
+          );
+      } else {
+        SimpleTest.ok(true, "Testing (New) Toolkit autocomplete widget. (ac1h)");
+
+        // Popup is lazily created, so not present in this case.
+      }
+
       testAccessibleTree("autocomplete", accTree);
 
       //////////////////////////////////////////////////////////////////////////
       // textbox@type=autocomplete #2 (child menupoup)
 
       accTree = {
+        // textbox
         role: ROLE_AUTOCOMPLETE,
         children: [
           {
+            // menupopup
             role: ROLE_COMBOBOX_LIST, // autocomplete menu popup
             children: [
               {
-                role: ROLE_COMBOBOX_OPTION
+                // menuitem
+                role: ROLE_COMBOBOX_OPTION,
+                children: []
               }
             ]
           },
           {
+            // html:input
             role: ROLE_ENTRY,
-            children: [ ] // no text leaf accessible for text node
+            children: [
+              // no text leaf accessible for text node
+            ]
           },
           {
+            // xul:menupopup
             role: ROLE_COMBOBOX_LIST, // context menu popup
-            children: [ ]
+            children: []
           }
         ]
       };
+
+      // XPFE and Toolkit autocomplete widgets differ.
+      var ac2cmp = document.getElementById("autocomplete2");
+      if ("clearResults" in ac2cmp) {
+        SimpleTest.ok(true, "Testing (Old) XPFE autocomplete widget. (ac2mp)");
+
+        // Toolkit has the menupopup first ...
+        var mp = accTree.children.splice(0, 1);
+
+        // Popup is always created.
+        accTree.children.push(
+          {
+            // xul:panel
+            role: ROLE_COMBOBOX_LIST,
+            children: [
+              {
+                // xul:tree
+                role: ROLE_TABLE,
+                children: [
+                  {
+                    // xul:treecols
+                    role: ROLE_LIST,
+                    children: [
+                      {
+                        // xul:treecol
+                        role: ROLE_COLUMNHEADER,
+                        children: []
+                      }
+                    ]
+                  }
+                ]
+              }
+            ]
+          }
+          );
+
+        // ... whereas XPFE has it last.
+        accTree.children.push(mp[0]);
+      } else {
+        SimpleTest.ok(true, "Testing (New) Toolkit autocomplete widget. (ac2mp)");
+
+        // Popup is lazily created, so not present in this case.
+      }
+
       testAccessibleTree("autocomplete2", accTree);
 
       SimpleTest.finish()
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
@@ -179,9 +282,8 @@
         <menupopup>
           <menuitem label="item1"/>
         </menupopup>
       </textbox>
     </vbox>
   </hbox>
 
 </window>
-