accessible/tests/mochitest/events/test_focus_menu.xul

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     4                  type="text/css"?>
     6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     7         title="Menu focus testing">
     9   <script type="application/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    11   <script type="application/javascript"
    12           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    14   <script type="application/javascript"
    15           src="../common.js" />
    16   <script type="application/javascript"
    17           src="../role.js" />
    18   <script type="application/javascript"
    19           src="../states.js" />
    20   <script type="application/javascript"
    21           src="../events.js" />
    23   <script type="application/javascript">
    24     //gA11yEventDumpToConsole = true; // debug stuff
    26     var gQueue = null;
    27     function doTests()
    28     {
    29       // Test focus events.
    30       gQueue = new eventQueue();
    32       if (WIN) {
    33         gQueue.push(new toggleTopMenu("fruit", new focusChecker("fruit")));
    34         gQueue.push(new synthRightKey("fruit", new focusChecker("vehicle")));
    35         gQueue.push(new synthEscapeKey("vehicle", new focusChecker(document)));
    36       }
    38       // mouse move activate items but no focus event until menubar is active
    39       gQueue.push(new synthMouseMove("fruit", new nofocusChecker("apple")));
    41       // mouseover and click on menuitem makes it active before menubar is
    42       // active
    43       gQueue.push(new synthClick("fruit", new focusChecker("fruit")));
    45       // mouseover on menuitem when menubar is active
    46       gQueue.push(new synthMouseMove("apple", new focusChecker("apple")));
    48       // keydown on disabled menuitem (disabled items are skipped on linux)
    49       if (WIN)
    50         gQueue.push(new synthDownKey("apple", new focusChecker("orange")));
    52       // menu and menuitem are both active
    53       // XXX: intermitent failure because two focus events may be coalesced,
    54       // think to workaround or fix this issue, when done enable queue invoker
    55       // below and remove next two.
    56       //gQueue.push(new synthRightKey("apple",
    57       //                              [ new focusChecker("vehicle"),
    58       //                                new focusChecker("cycle")]));
    59       gQueue.push(new synthClick("vehicle", new focusChecker("vehicle")));
    60       gQueue.push(new synthDownKey("cycle", new focusChecker("cycle")));
    62       // open submenu
    63       gQueue.push(new synthRightKey("cycle", new focusChecker("tricycle")));
    65       // move to first menu in cycle, DOMMenuItemActive is fired for fruit,
    66       // cycle and apple menuitems (bug 685191)
    67       todo(false, "focus is fired for 'cycle' menuitem");
    68       //gQueue.push(new synthRightKey("vehicle", new focusChecker("apple")));
    70       // click menuitem to close menu, focus gets back to document
    71       gQueue.push(new synthClick("tricycle", new focusChecker(document)));
    73       //enableLogging("focus,DOMEvents,tree"); // logging for bug708927
    74       //gQueue.onFinish = function() { disableLogging(); }
    76       gQueue.invoke(); // Will call SimpleTest.finish();
    77     }
    79     SimpleTest.waitForExplicitFinish();
    80     addA11yLoadEvent(doTests);
    81   </script>
    83   <hbox flex="1" style="overflow: auto;">
    84     <body xmlns="http://www.w3.org/1999/xhtml">
    85       <a target="_blank"
    86          href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
    87          title="Rework accessible focus handling">
    88         Mozilla Bug 673958
    89       </a>
    90       <p id="display"></p>
    91       <div id="content" style="display: none"></div>
    92       <pre id="test">
    93       </pre>
    94     </body>
    96     <vbox flex="1">
    97       <menubar>
    98         <menu id="fruit" label="Fruit">
    99           <menupopup>
   100             <menuitem id="apple" label="Apple"/>
   101             <menuitem id="orange" label="Orange" disabled="true"/>
   102           </menupopup>
   103         </menu>
   104         <menu id="vehicle" label="Vehicle">
   105           <menupopup>
   106             <menu id="cycle" label="cycle">
   107               <menupopup>
   108                 <menuitem id="tricycle" label="tricycle"/>
   109               </menupopup>
   110             </menu>
   111             <menuitem id="car" label="Car" disabled="true"/>
   112           </menupopup>
   113         </menu>
   114       </menubar>
   116       <vbox id="eventdump"/>
   117     </vbox>
   118   </hbox>
   119 </window>

mercurial