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