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 XUL button hierarchy tests"> |
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="../role.js" /> |
michael@0 | 18 | <script type="application/javascript" |
michael@0 | 19 | src="../events.js" /> |
michael@0 | 20 | |
michael@0 | 21 | <script type="application/javascript"> |
michael@0 | 22 | <![CDATA[ |
michael@0 | 23 | |
michael@0 | 24 | //////////////////////////////////////////////////////////////////////////// |
michael@0 | 25 | // Invokers |
michael@0 | 26 | |
michael@0 | 27 | function openMenu(aButtonID, aMenuItemRole) |
michael@0 | 28 | { |
michael@0 | 29 | var menuItemRole = aMenuItemRole || ROLE_MENUITEM; |
michael@0 | 30 | this.button = getAccessible(aButtonID); |
michael@0 | 31 | this.menupopup = this.button.firstChild; |
michael@0 | 32 | |
michael@0 | 33 | var checker = new invokerChecker(EVENT_REORDER, this.menupopup); |
michael@0 | 34 | this.__proto__ = new synthClick(aButtonID, checker); |
michael@0 | 35 | |
michael@0 | 36 | this.invoke = function openMenu_invoke() |
michael@0 | 37 | { |
michael@0 | 38 | var tree = |
michael@0 | 39 | { PUSHBUTTON: [ |
michael@0 | 40 | { MENUPOPUP: [ ] } |
michael@0 | 41 | ] }; |
michael@0 | 42 | testAccessibleTree(this.button, tree); |
michael@0 | 43 | |
michael@0 | 44 | this.__proto__.invoke(); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | this.finalCheck = function openMenu_finalCheck() |
michael@0 | 48 | { |
michael@0 | 49 | var tree = |
michael@0 | 50 | { PUSHBUTTON: [ |
michael@0 | 51 | { MENUPOPUP: [ |
michael@0 | 52 | { role: menuItemRole, children: [ ] }, |
michael@0 | 53 | { role: menuItemRole, children: [ ] } |
michael@0 | 54 | ] } |
michael@0 | 55 | ] }; |
michael@0 | 56 | testAccessibleTree(this.button, tree); |
michael@0 | 57 | |
michael@0 | 58 | synthesizeKey("VK_ESCAPE", { }); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | this.getID = function openMenu_getID() |
michael@0 | 62 | { |
michael@0 | 63 | return "open menu of the button " + prettyName(aButtonID); |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function openMenuButton(aButtonID) |
michael@0 | 68 | { |
michael@0 | 69 | this.buttonNode = getNode(aButtonID); |
michael@0 | 70 | this.menupoupNode = this.buttonNode.firstChild; |
michael@0 | 71 | |
michael@0 | 72 | this.eventSeq = [ |
michael@0 | 73 | new invokerChecker(EVENT_REORDER, this.menupoupNode) |
michael@0 | 74 | ]; |
michael@0 | 75 | |
michael@0 | 76 | this.invoke = function openMenu_invoke() |
michael@0 | 77 | { |
michael@0 | 78 | var tree = |
michael@0 | 79 | { PUSHBUTTON: [ |
michael@0 | 80 | { MENUPOPUP: [ ] }, |
michael@0 | 81 | { PUSHBUTTON: [ ] } |
michael@0 | 82 | ] }; |
michael@0 | 83 | testAccessibleTree(this.buttonNode, tree); |
michael@0 | 84 | |
michael@0 | 85 | this.buttonNode.open = true; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | this.finalCheck = function openMenu_finalCheck() |
michael@0 | 89 | { |
michael@0 | 90 | var tree = |
michael@0 | 91 | { PUSHBUTTON: [ |
michael@0 | 92 | { MENUPOPUP: [ |
michael@0 | 93 | { MENUITEM: [ ] }, |
michael@0 | 94 | { MENUITEM: [ ] } |
michael@0 | 95 | ] }, |
michael@0 | 96 | { PUSHBUTTON: [ ] } |
michael@0 | 97 | ] }; |
michael@0 | 98 | testAccessibleTree(this.buttonNode, tree); |
michael@0 | 99 | |
michael@0 | 100 | this.buttonNode.open = false; |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | this.getID = function openMenu_getID() |
michael@0 | 104 | { |
michael@0 | 105 | return "open menu for menu button " + prettyName(aButtonID); |
michael@0 | 106 | } |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | //////////////////////////////////////////////////////////////////////////// |
michael@0 | 110 | // Do test |
michael@0 | 111 | |
michael@0 | 112 | gA11yEventDumpToConsole = true; // debug stuff |
michael@0 | 113 | |
michael@0 | 114 | var gQueue = null; |
michael@0 | 115 | |
michael@0 | 116 | function doTest() |
michael@0 | 117 | { |
michael@0 | 118 | gQueue = new eventQueue(); |
michael@0 | 119 | |
michael@0 | 120 | gQueue.push(new openMenu("button1")); |
michael@0 | 121 | gQueue.push(new openMenuButton("button2")); |
michael@0 | 122 | gQueue.push(new openMenu("button3")); |
michael@0 | 123 | gQueue.push(new openMenuButton("button4")); |
michael@0 | 124 | |
michael@0 | 125 | var columnPickerBtn = getAccessible("tree").firstChild.lastChild; |
michael@0 | 126 | gQueue.push(new openMenu(columnPickerBtn, ROLE_CHECK_MENU_ITEM)); |
michael@0 | 127 | gQueue.invoke(); // SimpleTest.finish() |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 131 | addA11yLoadEvent(doTest); |
michael@0 | 132 | ]]> |
michael@0 | 133 | </script> |
michael@0 | 134 | |
michael@0 | 135 | <hbox flex="1" style="overflow: auto;"> |
michael@0 | 136 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 137 | <a target="_blank" |
michael@0 | 138 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=249292" |
michael@0 | 139 | title="Ensure accessible children for toolbarbutton types 'menu' and 'menu-button'"> |
michael@0 | 140 | Bug 249292 |
michael@0 | 141 | </a> |
michael@0 | 142 | <a target="_blank" |
michael@0 | 143 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=630486" |
michael@0 | 144 | title="Don't force accessible creation for popup children"> |
michael@0 | 145 | Bug 630486 |
michael@0 | 146 | </a> |
michael@0 | 147 | <a target="_blank" |
michael@0 | 148 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=722265" |
michael@0 | 149 | title="Column header selection popup no longer exposed to accessibility APIs"> |
michael@0 | 150 | Bug 722265 |
michael@0 | 151 | </a> |
michael@0 | 152 | <br/> |
michael@0 | 153 | <p id="display"></p> |
michael@0 | 154 | <div id="content" style="display: none"> |
michael@0 | 155 | </div> |
michael@0 | 156 | <pre id="test"> |
michael@0 | 157 | </pre> |
michael@0 | 158 | </body> |
michael@0 | 159 | |
michael@0 | 160 | <vbox flex="1"> |
michael@0 | 161 | <button id="button1" type="menu" label="button"> |
michael@0 | 162 | <menupopup> |
michael@0 | 163 | <menuitem label="menuitem"/> |
michael@0 | 164 | <menuitem label="menuitem"/> |
michael@0 | 165 | </menupopup> |
michael@0 | 166 | </button> |
michael@0 | 167 | <button id="button2" type="menu-button" label="menu button"> |
michael@0 | 168 | <menupopup> |
michael@0 | 169 | <menuitem label="menuitem"/> |
michael@0 | 170 | <menuitem label="menuitem"/> |
michael@0 | 171 | </menupopup> |
michael@0 | 172 | </button> |
michael@0 | 173 | |
michael@0 | 174 | <toolbarbutton id="button3" type="menu" label="toolbarbutton"> |
michael@0 | 175 | <menupopup> |
michael@0 | 176 | <menuitem label="menuitem"/> |
michael@0 | 177 | <menuitem label="menuitem"/> |
michael@0 | 178 | </menupopup> |
michael@0 | 179 | </toolbarbutton> |
michael@0 | 180 | <toolbarbutton id="button4" type="menu-button" label="menu toolbarbutton"> |
michael@0 | 181 | <menupopup> |
michael@0 | 182 | <menuitem label="menuitem"/> |
michael@0 | 183 | <menuitem label="menuitem"/> |
michael@0 | 184 | </menupopup> |
michael@0 | 185 | </toolbarbutton> |
michael@0 | 186 | |
michael@0 | 187 | <tree id="tree" flex="1"> |
michael@0 | 188 | <treecols> |
michael@0 | 189 | <treecol id="col" flex="1" primary="true" label="column"/> |
michael@0 | 190 | <treecol id="col2" flex="1" label="another column"/> |
michael@0 | 191 | </treecols> |
michael@0 | 192 | <treechildren/> |
michael@0 | 193 | </tree> |
michael@0 | 194 | </vbox> |
michael@0 | 195 | </hbox> |
michael@0 | 196 | |
michael@0 | 197 | </window> |
michael@0 | 198 |