|
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="Accessible menu events testing for XUL menu"> |
|
8 |
|
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"/> |
|
13 |
|
14 <script type="application/javascript" |
|
15 src="../common.js" /> |
|
16 <script type="application/javascript" |
|
17 src="../events.js" /> |
|
18 |
|
19 <script type="application/javascript"> |
|
20 function openFileMenu() |
|
21 { |
|
22 this.eventSeq = [ |
|
23 new invokerChecker(EVENT_MENU_START, getNode("menubar")), |
|
24 new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-file")) |
|
25 // new invokerChecker(EVENT_FOCUS, getNode("menuitem-newtab")) intermitent failure |
|
26 ]; |
|
27 |
|
28 this.invoke = function openFileMenu_invoke() |
|
29 { |
|
30 synthesizeKey("F", { altKey: true, shiftKey: true }); |
|
31 } |
|
32 |
|
33 this.getID = function openFileMenu_getID() |
|
34 { |
|
35 return "open file menu by alt+F press"; |
|
36 } |
|
37 } |
|
38 |
|
39 function openEditMenu() |
|
40 { |
|
41 this.eventSeq = [ |
|
42 new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-file")), |
|
43 new invokerChecker(EVENT_MENUPOPUP_START, getNode("menupopup-edit")) |
|
44 // new invokerChecker(EVENT_FOCUS, getNode("menuitem-undo")) intermitent failure |
|
45 ]; |
|
46 |
|
47 this.invoke = function openEditMenu_invoke() |
|
48 { |
|
49 synthesizeKey("VK_RIGHT", { }); |
|
50 } |
|
51 |
|
52 this.getID = function openEditMenu_getID() |
|
53 { |
|
54 return "open edit menu by lef arrow press"; |
|
55 } |
|
56 } |
|
57 |
|
58 function closeEditMenu() |
|
59 { |
|
60 this.eventSeq = [ |
|
61 //new invokerChecker(EVENT_FOCUS, document), intermitent failure |
|
62 new invokerChecker(EVENT_MENUPOPUP_END, getNode("menupopup-edit")), |
|
63 new invokerChecker(EVENT_MENU_END, getNode("menubar")) |
|
64 ]; |
|
65 |
|
66 this.invoke = function closeEditMenu_invoke() |
|
67 { |
|
68 synthesizeKey("VK_ESCAPE", { }); |
|
69 } |
|
70 |
|
71 this.getID = function closeEditMenu_getID() |
|
72 { |
|
73 return "close edit menu, leave menubar"; |
|
74 } |
|
75 } |
|
76 |
|
77 function focusFileMenu() |
|
78 { |
|
79 this.eventSeq = [ |
|
80 new invokerChecker(EVENT_MENU_START, getNode("menubar")) |
|
81 // new invokerChecker(EVENT_FOCUS, getNode("menuitem-file")) //intermitent failure |
|
82 ]; |
|
83 |
|
84 this.invoke = function focusFileMenu_invoke() |
|
85 { |
|
86 synthesizeKey("VK_ALT", { }); |
|
87 } |
|
88 |
|
89 this.getID = function focusFileMenu_getID() |
|
90 { |
|
91 return "activate menubar, focus file menu (atl press)"; |
|
92 } |
|
93 } |
|
94 |
|
95 function focusEditMenu() |
|
96 { |
|
97 this.eventSeq = [ |
|
98 new invokerChecker(EVENT_FOCUS, getNode("menuitem-edit")) |
|
99 ]; |
|
100 |
|
101 this.invoke = function focusEditMenu_invoke() |
|
102 { |
|
103 synthesizeKey("VK_RIGHT", { }); |
|
104 } |
|
105 |
|
106 this.getID = function focusEditMenu_getID() |
|
107 { |
|
108 return "focus edit menu"; |
|
109 } |
|
110 } |
|
111 |
|
112 function leaveMenubar() |
|
113 { |
|
114 this.eventSeq = [ |
|
115 //new invokerChecker(EVENT_FOCUS, document), intermitent failure |
|
116 new invokerChecker(EVENT_MENU_END, getNode("menubar")) |
|
117 ]; |
|
118 |
|
119 this.invoke = function leaveMenubar_invoke() |
|
120 { |
|
121 synthesizeKey("VK_ESCAPE", { }); |
|
122 } |
|
123 |
|
124 this.getID = function leaveMenubar_getID() |
|
125 { |
|
126 return "leave menubar"; |
|
127 } |
|
128 } |
|
129 |
|
130 /** |
|
131 * Do tests. |
|
132 */ |
|
133 |
|
134 //gA11yEventDumpID = "eventdump"; |
|
135 //gA11yEventDumpToConsole = true; |
|
136 |
|
137 var gQueue = null; |
|
138 |
|
139 function doTests() |
|
140 { |
|
141 if (!WIN) { |
|
142 todo(false, "Enable this test on other platforms."); |
|
143 SimpleTest.finish(); |
|
144 return; |
|
145 } |
|
146 |
|
147 todo(false, |
|
148 "Fix intermitent failures. Focus may randomly occur before or after menupopup events!"); |
|
149 |
|
150 gQueue = new eventQueue(); |
|
151 |
|
152 gQueue.push(new openFileMenu()); |
|
153 gQueue.push(new openEditMenu()); |
|
154 gQueue.push(new closeEditMenu()); |
|
155 |
|
156 // Alt key is used to active menubar and focus menu item on Windows, |
|
157 // other platforms requires setting a ui.key.menuAccessKeyFocuses |
|
158 // preference. |
|
159 if (WIN || LINUX) { |
|
160 gQueue.push(new focusFileMenu()); |
|
161 gQueue.push(new focusEditMenu()); |
|
162 gQueue.push(new leaveMenubar()); |
|
163 } |
|
164 |
|
165 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
166 } |
|
167 |
|
168 SimpleTest.waitForExplicitFinish(); |
|
169 addA11yLoadEvent(doTests); |
|
170 </script> |
|
171 |
|
172 <hbox flex="1" style="overflow: auto;"> |
|
173 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
174 <a target="_blank" |
|
175 href="https://bugzilla.mozilla.org/show_bug.cgi?id=615189" |
|
176 title="Clean up FireAccessibleFocusEvent"> |
|
177 Mozilla Bug 615189 |
|
178 </a> |
|
179 <p id="display"></p> |
|
180 <div id="content" style="display: none"></div> |
|
181 <pre id="test"> |
|
182 </pre> |
|
183 </body> |
|
184 |
|
185 <vbox flex="1"> |
|
186 <menubar id="menubar"> |
|
187 <menu id="menuitem-file" label="File" accesskey="F"> |
|
188 <menupopup id="menupopup-file"> |
|
189 <menuitem id="menuitem-newtab" label="New Tab"/> |
|
190 </menupopup> |
|
191 </menu> |
|
192 <menu id="menuitem-edit" label="Edit" accesskey="E"> |
|
193 <menupopup id="menupopup-edit"> |
|
194 <menuitem id="menuitem-undo" label="Undo"/> |
|
195 </menupopup> |
|
196 </menu> |
|
197 </menubar> |
|
198 |
|
199 <vbox id="eventdump" role="log"/> |
|
200 </vbox> |
|
201 </hbox> |
|
202 </window> |