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