1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/events/test_menu.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,202 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.7 + type="text/css"?> 1.8 + 1.9 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.10 + title="Accessible menu events testing for XUL menu"> 1.11 + 1.12 + <script type="application/javascript" 1.13 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 1.16 + 1.17 + <script type="application/javascript" 1.18 + src="../common.js" /> 1.19 + <script type="application/javascript" 1.20 + src="../events.js" /> 1.21 + 1.22 + <script type="application/javascript"> 1.23 + function openFileMenu() 1.24 + { 1.25 + this.eventSeq = [ 1.26 + new invokerChecker(EVENT_MENU_START, getNode("menubar")), 1.27 + new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-file")) 1.28 + // new invokerChecker(EVENT_FOCUS, getNode("menuitem-newtab")) intermitent failure 1.29 + ]; 1.30 + 1.31 + this.invoke = function openFileMenu_invoke() 1.32 + { 1.33 + synthesizeKey("F", { altKey: true, shiftKey: true }); 1.34 + } 1.35 + 1.36 + this.getID = function openFileMenu_getID() 1.37 + { 1.38 + return "open file menu by alt+F press"; 1.39 + } 1.40 + } 1.41 + 1.42 + function openEditMenu() 1.43 + { 1.44 + this.eventSeq = [ 1.45 + new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-file")), 1.46 + new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-edit")) 1.47 + // new invokerChecker(EVENT_FOCUS, getNode("menuitem-undo")) intermitent failure 1.48 + ]; 1.49 + 1.50 + this.invoke = function openEditMenu_invoke() 1.51 + { 1.52 + synthesizeKey("VK_RIGHT", { }); 1.53 + } 1.54 + 1.55 + this.getID = function openEditMenu_getID() 1.56 + { 1.57 + return "open edit menu by lef arrow press"; 1.58 + } 1.59 + } 1.60 + 1.61 + function closeEditMenu() 1.62 + { 1.63 + this.eventSeq = [ 1.64 + //new invokerChecker(EVENT_FOCUS, document), intermitent failure 1.65 + new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-edit")), 1.66 + new invokerChecker(EVENT_MENU_END, getNode("menubar")) 1.67 + ]; 1.68 + 1.69 + this.invoke = function closeEditMenu_invoke() 1.70 + { 1.71 + synthesizeKey("VK_ESCAPE", { }); 1.72 + } 1.73 + 1.74 + this.getID = function closeEditMenu_getID() 1.75 + { 1.76 + return "close edit menu, leave menubar"; 1.77 + } 1.78 + } 1.79 + 1.80 + function focusFileMenu() 1.81 + { 1.82 + this.eventSeq = [ 1.83 + new invokerChecker(EVENT_MENU_START, getNode("menubar")) 1.84 + // new invokerChecker(EVENT_FOCUS, getNode("menuitem-file")) //intermitent failure 1.85 + ]; 1.86 + 1.87 + this.invoke = function focusFileMenu_invoke() 1.88 + { 1.89 + synthesizeKey("VK_ALT", { }); 1.90 + } 1.91 + 1.92 + this.getID = function focusFileMenu_getID() 1.93 + { 1.94 + return "activate menubar, focus file menu (atl press)"; 1.95 + } 1.96 + } 1.97 + 1.98 + function focusEditMenu() 1.99 + { 1.100 + this.eventSeq = [ 1.101 + new invokerChecker(EVENT_FOCUS, getNode("menuitem-edit")) 1.102 + ]; 1.103 + 1.104 + this.invoke = function focusEditMenu_invoke() 1.105 + { 1.106 + synthesizeKey("VK_RIGHT", { }); 1.107 + } 1.108 + 1.109 + this.getID = function focusEditMenu_getID() 1.110 + { 1.111 + return "focus edit menu"; 1.112 + } 1.113 + } 1.114 + 1.115 + function leaveMenubar() 1.116 + { 1.117 + this.eventSeq = [ 1.118 + //new invokerChecker(EVENT_FOCUS, document), intermitent failure 1.119 + new invokerChecker(EVENT_MENU_END, getNode("menubar")) 1.120 + ]; 1.121 + 1.122 + this.invoke = function leaveMenubar_invoke() 1.123 + { 1.124 + synthesizeKey("VK_ESCAPE", { }); 1.125 + } 1.126 + 1.127 + this.getID = function leaveMenubar_getID() 1.128 + { 1.129 + return "leave menubar"; 1.130 + } 1.131 + } 1.132 + 1.133 + /** 1.134 + * Do tests. 1.135 + */ 1.136 + 1.137 + //gA11yEventDumpID = "eventdump"; 1.138 + //gA11yEventDumpToConsole = true; 1.139 + 1.140 + var gQueue = null; 1.141 + 1.142 + function doTests() 1.143 + { 1.144 + if (!WIN) { 1.145 + todo(false, "Enable this test on other platforms."); 1.146 + SimpleTest.finish(); 1.147 + return; 1.148 + } 1.149 + 1.150 + todo(false, 1.151 + "Fix intermitent failures. Focus may randomly occur before or after menupopup events!"); 1.152 + 1.153 + gQueue = new eventQueue(); 1.154 + 1.155 + gQueue.push(new openFileMenu()); 1.156 + gQueue.push(new openEditMenu()); 1.157 + gQueue.push(new closeEditMenu()); 1.158 + 1.159 + // Alt key is used to active menubar and focus menu item on Windows, 1.160 + // other platforms requires setting a ui.key.menuAccessKeyFocuses 1.161 + // preference. 1.162 + if (WIN || LINUX) { 1.163 + gQueue.push(new focusFileMenu()); 1.164 + gQueue.push(new focusEditMenu()); 1.165 + gQueue.push(new leaveMenubar()); 1.166 + } 1.167 + 1.168 + gQueue.invoke(); // Will call SimpleTest.finish(); 1.169 + } 1.170 + 1.171 + SimpleTest.waitForExplicitFinish(); 1.172 + addA11yLoadEvent(doTests); 1.173 + </script> 1.174 + 1.175 + <hbox flex="1" style="overflow: auto;"> 1.176 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.177 + <a target="_blank" 1.178 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=615189" 1.179 + title="Clean up FireAccessibleFocusEvent"> 1.180 + Mozilla Bug 615189 1.181 + </a> 1.182 + <p id="display"></p> 1.183 + <div id="content" style="display: none"></div> 1.184 + <pre id="test"> 1.185 + </pre> 1.186 + </body> 1.187 + 1.188 + <vbox flex="1"> 1.189 + <menubar id="menubar"> 1.190 + <menu id="menuitem-file" label="File" accesskey="F"> 1.191 + <menupopup id="menupopup-file"> 1.192 + <menuitem id="menuitem-newtab" label="New Tab"/> 1.193 + </menupopup> 1.194 + </menu> 1.195 + <menu id="menuitem-edit" label="Edit" accesskey="E"> 1.196 + <menupopup id="menupopup-edit"> 1.197 + <menuitem id="menuitem-undo" label="Undo"/> 1.198 + </menupopup> 1.199 + </menu> 1.200 + </menubar> 1.201 + 1.202 + <vbox id="eventdump" role="log"/> 1.203 + </vbox> 1.204 + </hbox> 1.205 +</window>