1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/events/test_focus_general.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,179 @@ 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 focus event testing"> 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="../role.js" /> 1.21 + <script type="application/javascript" 1.22 + src="../states.js" /> 1.23 + <script type="application/javascript" 1.24 + src="../events.js" /> 1.25 + 1.26 + <script type="application/javascript"> 1.27 + function getColorBtn(aBtnObj) 1.28 + { 1.29 + var colorpicker = aBtnObj.colorpicker; 1.30 + var container = colorpicker.firstChild; 1.31 + var btn = container.getChildAt(aBtnObj.btnIndex); 1.32 + return btn; 1.33 + } 1.34 + 1.35 + //gA11yEventDumpID = "eventdump"; // debug stuff 1.36 + //gA11yEventDumpToConsole = true; // debug stuff 1.37 + 1.38 + var gQueue = null; 1.39 + function doTests() 1.40 + { 1.41 + // Test focus events. 1.42 + gQueue = new eventQueue(); 1.43 + 1.44 + gQueue.push(new synthFocus("textbox", 1.45 + new focusChecker(getNode("textbox").inputField))); 1.46 + gQueue.push(new synthFocus("textbox_multiline", 1.47 + new focusChecker(getNode("textbox_multiline").inputField))); 1.48 + gQueue.push(new synthFocus("scale")); 1.49 + gQueue.push(new synthFocusOnFrame("editabledoc")); 1.50 + gQueue.push(new synthFocus("radioclothes", 1.51 + new focusChecker("radiosweater"))); 1.52 + gQueue.push(new synthDownKey("radiosweater", 1.53 + new focusChecker("radiojacket"))); 1.54 + gQueue.push(new synthFocus("checkbox")); 1.55 + gQueue.push(new synthFocus("button")); 1.56 + gQueue.push(new synthFocus("checkbutton")); 1.57 + gQueue.push(new synthFocus("radiobutton")); 1.58 + 1.59 + // focus menubutton 1.60 + gQueue.push(new synthFocus("menubutton")); 1.61 + // click menubutton, open popup, focus stays on menu button 1.62 + gQueue.push(new synthClick("menubutton", new nofocusChecker())); 1.63 + // select first menu item ("item 1"), focus on menu item 1.64 + gQueue.push(new synthDownKey("menubutton", new focusChecker("mb_item1"))); 1.65 + // choose select menu item, focus gets back to menubutton 1.66 + gQueue.push(new synthEnterKey("mb_item1", new focusChecker("menubutton"))); 1.67 + // press enter to open popup, focus stays on menubutton 1.68 + gQueue.push(new synthEnterKey("menubutton", new nofocusChecker())); 1.69 + // select second menu item ("item 2"), focus on menu item 1.70 + gQueue.push(new synthUpKey("menubutton", new focusChecker("mb_item2"))); 1.71 + 1.72 + // clicking on button having associated popup doesn't change a focus 1.73 + gQueue.push(new synthClick("popupbutton", new nofocusChecker())); 1.74 + // select first menu item ("item 1"), focus on menu item 1.75 + gQueue.push(new synthDownKey("popupbutton", new focusChecker("bp_item1"))); 1.76 + // choose select menu item, focus gets back to menubutton 1.77 + gQueue.push(new synthEnterKey("bp_item1", new focusChecker("menubutton"))); 1.78 + // show popup again for the next test 1.79 + gQueue.push(new synthClick("popupbutton", new nofocusChecker())); 1.80 + 1.81 +if (!MAC) { 1.82 + // click menubutton of the 'menubutton' button while popup of button open. 1.83 + gQueue.push(new synthClick("mbb", new focusChecker("mbb"), { where: "right" })); 1.84 + // close popup, focus stays on menubutton, fire focus event 1.85 + gQueue.push(new synthEscapeKey("mbb", new focusChecker("mbb"))); 1.86 + // click menubutton, open popup, focus stays on menubutton 1.87 + gQueue.push(new synthClick("mbb", new nofocusChecker(), { where: "right" })); 1.88 + // select first menu item ("item 1"), focus on menu item 1.89 + gQueue.push(new synthDownKey("mbb", new focusChecker("mbb_item1"))); 1.90 + // choose select menu item, focus gets back to menubutton 1.91 + gQueue.push(new synthEnterKey("mbb_item1", new focusChecker("mbb"))); 1.92 + // open popup, focus stays on menubutton 1.93 + gQueue.push(new synthOpenComboboxKey("mbb", new nofocusChecker())); 1.94 + // select second menu item ("item 2"), focus on menu item 1.95 + gQueue.push(new synthUpKey("menubutton", new focusChecker("mbb_item2"))); 1.96 + // click on menu item of menubutton menu, focus menubutton 1.97 + gQueue.push(new synthClick("mbb_item2", new focusChecker("mbb"))); 1.98 +} else { 1.99 + todo(false, "mbb tests time out on OS X, fix bug 746970 and reenable!"); 1.100 +} 1.101 + 1.102 + // focus colorpicker button 1.103 + gQueue.push(new synthFocus("colorpicker")); 1.104 + // click on button, open popup, focus goes to current color button 1.105 + var btnObj = { colorpicker: getAccessible("colorpicker"), btnIndex: 0 }; 1.106 + var checker = new focusChecker(getColorBtn, btnObj); 1.107 + gQueue.push(new synthClick("colorpicker", checker)); 1.108 + // select sibling color button, focus on it 1.109 + btnObj = { colorpicker: getAccessible("colorpicker"), btnIndex: 1 }; 1.110 + var checker = new focusChecker(getColorBtn, btnObj); 1.111 + gQueue.push(new synthRightKey("colorpicker", checker)); 1.112 + // choose selected color button, close popup, focus on colorpicker button 1.113 + gQueue.push(new synthEnterKey("colorpicker", new focusChecker("colorpicker"))); 1.114 + 1.115 + gQueue.invoke(); // Will call SimpleTest.finish(); 1.116 + } 1.117 + 1.118 + SimpleTest.waitForExplicitFinish(); 1.119 + addA11yLoadEvent(doTests); 1.120 + </script> 1.121 + 1.122 + <hbox flex="1" style="overflow: auto;"> 1.123 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.124 + <a target="_blank" 1.125 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=492518" 1.126 + title="xul:slider accessible of xul:scale is accessible illegally"> 1.127 + Mozilla Bug 492518 1.128 + </a> 1.129 + <a target="_blank" 1.130 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=552368" 1.131 + title=" fire focus event on document accessible whenever the root or body element is focused"> 1.132 + Mozilla Bug 552368 1.133 + </a> 1.134 + <p id="display"></p> 1.135 + <div id="content" style="display: none"></div> 1.136 + <pre id="test"> 1.137 + </pre> 1.138 + </body> 1.139 + 1.140 + <vbox flex="1"> 1.141 + <textbox id="textbox" value="hello"/> 1.142 + <textbox id="textbox_multiline" multiline="true" value="hello"/> 1.143 + <scale id="scale" min="0" max="9" value="5"/> 1.144 + <iframe id="editabledoc" src="focus.html"/> 1.145 + <radiogroup id="radioclothes"> 1.146 + <radio id="radiosweater" label="radiosweater"/> 1.147 + <radio id="radiocap" label="radiocap" disabled="true"/> 1.148 + <radio id="radiojacket" label="radiojacket"/> 1.149 + </radiogroup> 1.150 + <checkbox id="checkbox" label="checkbox"/> 1.151 + <button id="button" label="button"/> 1.152 + <button id="checkbutton" type="checkbox" label="checkbutton"/> 1.153 + <button id="radiobutton" type="radio" group="rbgroup" label="radio1"/> 1.154 + 1.155 + <button id="menubutton" type="menu" label="menubutton"> 1.156 + <menupopup> 1.157 + <menuitem id="mb_item1" label="item1"/> 1.158 + <menuitem id="mb_item2" label="item2"/> 1.159 + </menupopup> 1.160 + </button> 1.161 + <button id="mbb" type="menu-button" label="menubutton button"> 1.162 + <menupopup> 1.163 + <menuitem id="mbb_item1" label="item1"/> 1.164 + <menuitem id="mbb_item2" label="item2"/> 1.165 + </menupopup> 1.166 + </button> 1.167 + 1.168 + <colorpicker id="colorpicker" type="button" label="color picker" 1.169 + color="#FFFFFF"/> 1.170 + 1.171 + <popupset> 1.172 + <menupopup id="backpopup" position="after_start"> 1.173 + <menuitem id="bp_item1" label="Page 1"/> 1.174 + <menuitem id="bp_item2" label="Page 2"/> 1.175 + </menupopup> 1.176 + </popupset> 1.177 + <button id="popupbutton" label="Pop Me Up" popup="backpopup"/> 1.178 + 1.179 + <vbox id="eventdump"/> 1.180 + </vbox> 1.181 + </hbox> 1.182 +</window>