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 focus event testing"> |
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="../states.js" /> |
michael@0 | 20 | <script type="application/javascript" |
michael@0 | 21 | src="../events.js" /> |
michael@0 | 22 | |
michael@0 | 23 | <script type="application/javascript"> |
michael@0 | 24 | function getColorBtn(aBtnObj) |
michael@0 | 25 | { |
michael@0 | 26 | var colorpicker = aBtnObj.colorpicker; |
michael@0 | 27 | var container = colorpicker.firstChild; |
michael@0 | 28 | var btn = container.getChildAt(aBtnObj.btnIndex); |
michael@0 | 29 | return btn; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | //gA11yEventDumpID = "eventdump"; // debug stuff |
michael@0 | 33 | //gA11yEventDumpToConsole = true; // debug stuff |
michael@0 | 34 | |
michael@0 | 35 | var gQueue = null; |
michael@0 | 36 | function doTests() |
michael@0 | 37 | { |
michael@0 | 38 | // Test focus events. |
michael@0 | 39 | gQueue = new eventQueue(); |
michael@0 | 40 | |
michael@0 | 41 | gQueue.push(new synthFocus("textbox", |
michael@0 | 42 | new focusChecker(getNode("textbox").inputField))); |
michael@0 | 43 | gQueue.push(new synthFocus("textbox_multiline", |
michael@0 | 44 | new focusChecker(getNode("textbox_multiline").inputField))); |
michael@0 | 45 | gQueue.push(new synthFocus("scale")); |
michael@0 | 46 | gQueue.push(new synthFocusOnFrame("editabledoc")); |
michael@0 | 47 | gQueue.push(new synthFocus("radioclothes", |
michael@0 | 48 | new focusChecker("radiosweater"))); |
michael@0 | 49 | gQueue.push(new synthDownKey("radiosweater", |
michael@0 | 50 | new focusChecker("radiojacket"))); |
michael@0 | 51 | gQueue.push(new synthFocus("checkbox")); |
michael@0 | 52 | gQueue.push(new synthFocus("button")); |
michael@0 | 53 | gQueue.push(new synthFocus("checkbutton")); |
michael@0 | 54 | gQueue.push(new synthFocus("radiobutton")); |
michael@0 | 55 | |
michael@0 | 56 | // focus menubutton |
michael@0 | 57 | gQueue.push(new synthFocus("menubutton")); |
michael@0 | 58 | // click menubutton, open popup, focus stays on menu button |
michael@0 | 59 | gQueue.push(new synthClick("menubutton", new nofocusChecker())); |
michael@0 | 60 | // select first menu item ("item 1"), focus on menu item |
michael@0 | 61 | gQueue.push(new synthDownKey("menubutton", new focusChecker("mb_item1"))); |
michael@0 | 62 | // choose select menu item, focus gets back to menubutton |
michael@0 | 63 | gQueue.push(new synthEnterKey("mb_item1", new focusChecker("menubutton"))); |
michael@0 | 64 | // press enter to open popup, focus stays on menubutton |
michael@0 | 65 | gQueue.push(new synthEnterKey("menubutton", new nofocusChecker())); |
michael@0 | 66 | // select second menu item ("item 2"), focus on menu item |
michael@0 | 67 | gQueue.push(new synthUpKey("menubutton", new focusChecker("mb_item2"))); |
michael@0 | 68 | |
michael@0 | 69 | // clicking on button having associated popup doesn't change a focus |
michael@0 | 70 | gQueue.push(new synthClick("popupbutton", new nofocusChecker())); |
michael@0 | 71 | // select first menu item ("item 1"), focus on menu item |
michael@0 | 72 | gQueue.push(new synthDownKey("popupbutton", new focusChecker("bp_item1"))); |
michael@0 | 73 | // choose select menu item, focus gets back to menubutton |
michael@0 | 74 | gQueue.push(new synthEnterKey("bp_item1", new focusChecker("menubutton"))); |
michael@0 | 75 | // show popup again for the next test |
michael@0 | 76 | gQueue.push(new synthClick("popupbutton", new nofocusChecker())); |
michael@0 | 77 | |
michael@0 | 78 | if (!MAC) { |
michael@0 | 79 | // click menubutton of the 'menubutton' button while popup of button open. |
michael@0 | 80 | gQueue.push(new synthClick("mbb", new focusChecker("mbb"), { where: "right" })); |
michael@0 | 81 | // close popup, focus stays on menubutton, fire focus event |
michael@0 | 82 | gQueue.push(new synthEscapeKey("mbb", new focusChecker("mbb"))); |
michael@0 | 83 | // click menubutton, open popup, focus stays on menubutton |
michael@0 | 84 | gQueue.push(new synthClick("mbb", new nofocusChecker(), { where: "right" })); |
michael@0 | 85 | // select first menu item ("item 1"), focus on menu item |
michael@0 | 86 | gQueue.push(new synthDownKey("mbb", new focusChecker("mbb_item1"))); |
michael@0 | 87 | // choose select menu item, focus gets back to menubutton |
michael@0 | 88 | gQueue.push(new synthEnterKey("mbb_item1", new focusChecker("mbb"))); |
michael@0 | 89 | // open popup, focus stays on menubutton |
michael@0 | 90 | gQueue.push(new synthOpenComboboxKey("mbb", new nofocusChecker())); |
michael@0 | 91 | // select second menu item ("item 2"), focus on menu item |
michael@0 | 92 | gQueue.push(new synthUpKey("menubutton", new focusChecker("mbb_item2"))); |
michael@0 | 93 | // click on menu item of menubutton menu, focus menubutton |
michael@0 | 94 | gQueue.push(new synthClick("mbb_item2", new focusChecker("mbb"))); |
michael@0 | 95 | } else { |
michael@0 | 96 | todo(false, "mbb tests time out on OS X, fix bug 746970 and reenable!"); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | // focus colorpicker button |
michael@0 | 100 | gQueue.push(new synthFocus("colorpicker")); |
michael@0 | 101 | // click on button, open popup, focus goes to current color button |
michael@0 | 102 | var btnObj = { colorpicker: getAccessible("colorpicker"), btnIndex: 0 }; |
michael@0 | 103 | var checker = new focusChecker(getColorBtn, btnObj); |
michael@0 | 104 | gQueue.push(new synthClick("colorpicker", checker)); |
michael@0 | 105 | // select sibling color button, focus on it |
michael@0 | 106 | btnObj = { colorpicker: getAccessible("colorpicker"), btnIndex: 1 }; |
michael@0 | 107 | var checker = new focusChecker(getColorBtn, btnObj); |
michael@0 | 108 | gQueue.push(new synthRightKey("colorpicker", checker)); |
michael@0 | 109 | // choose selected color button, close popup, focus on colorpicker button |
michael@0 | 110 | gQueue.push(new synthEnterKey("colorpicker", new focusChecker("colorpicker"))); |
michael@0 | 111 | |
michael@0 | 112 | gQueue.invoke(); // Will call SimpleTest.finish(); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 116 | addA11yLoadEvent(doTests); |
michael@0 | 117 | </script> |
michael@0 | 118 | |
michael@0 | 119 | <hbox flex="1" style="overflow: auto;"> |
michael@0 | 120 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 121 | <a target="_blank" |
michael@0 | 122 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=492518" |
michael@0 | 123 | title="xul:slider accessible of xul:scale is accessible illegally"> |
michael@0 | 124 | Mozilla Bug 492518 |
michael@0 | 125 | </a> |
michael@0 | 126 | <a target="_blank" |
michael@0 | 127 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=552368" |
michael@0 | 128 | title=" fire focus event on document accessible whenever the root or body element is focused"> |
michael@0 | 129 | Mozilla Bug 552368 |
michael@0 | 130 | </a> |
michael@0 | 131 | <p id="display"></p> |
michael@0 | 132 | <div id="content" style="display: none"></div> |
michael@0 | 133 | <pre id="test"> |
michael@0 | 134 | </pre> |
michael@0 | 135 | </body> |
michael@0 | 136 | |
michael@0 | 137 | <vbox flex="1"> |
michael@0 | 138 | <textbox id="textbox" value="hello"/> |
michael@0 | 139 | <textbox id="textbox_multiline" multiline="true" value="hello"/> |
michael@0 | 140 | <scale id="scale" min="0" max="9" value="5"/> |
michael@0 | 141 | <iframe id="editabledoc" src="focus.html"/> |
michael@0 | 142 | <radiogroup id="radioclothes"> |
michael@0 | 143 | <radio id="radiosweater" label="radiosweater"/> |
michael@0 | 144 | <radio id="radiocap" label="radiocap" disabled="true"/> |
michael@0 | 145 | <radio id="radiojacket" label="radiojacket"/> |
michael@0 | 146 | </radiogroup> |
michael@0 | 147 | <checkbox id="checkbox" label="checkbox"/> |
michael@0 | 148 | <button id="button" label="button"/> |
michael@0 | 149 | <button id="checkbutton" type="checkbox" label="checkbutton"/> |
michael@0 | 150 | <button id="radiobutton" type="radio" group="rbgroup" label="radio1"/> |
michael@0 | 151 | |
michael@0 | 152 | <button id="menubutton" type="menu" label="menubutton"> |
michael@0 | 153 | <menupopup> |
michael@0 | 154 | <menuitem id="mb_item1" label="item1"/> |
michael@0 | 155 | <menuitem id="mb_item2" label="item2"/> |
michael@0 | 156 | </menupopup> |
michael@0 | 157 | </button> |
michael@0 | 158 | <button id="mbb" type="menu-button" label="menubutton button"> |
michael@0 | 159 | <menupopup> |
michael@0 | 160 | <menuitem id="mbb_item1" label="item1"/> |
michael@0 | 161 | <menuitem id="mbb_item2" label="item2"/> |
michael@0 | 162 | </menupopup> |
michael@0 | 163 | </button> |
michael@0 | 164 | |
michael@0 | 165 | <colorpicker id="colorpicker" type="button" label="color picker" |
michael@0 | 166 | color="#FFFFFF"/> |
michael@0 | 167 | |
michael@0 | 168 | <popupset> |
michael@0 | 169 | <menupopup id="backpopup" position="after_start"> |
michael@0 | 170 | <menuitem id="bp_item1" label="Page 1"/> |
michael@0 | 171 | <menuitem id="bp_item2" label="Page 2"/> |
michael@0 | 172 | </menupopup> |
michael@0 | 173 | </popupset> |
michael@0 | 174 | <button id="popupbutton" label="Pop Me Up" popup="backpopup"/> |
michael@0 | 175 | |
michael@0 | 176 | <vbox id="eventdump"/> |
michael@0 | 177 | </vbox> |
michael@0 | 178 | </hbox> |
michael@0 | 179 | </window> |