test_focus_general.xhtml (4956B)
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 xmlns:html="http://www.w3.org/1999/xhtml" 8 title="Accessible focus event testing"> 9 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 12 13 <script type="application/javascript" 14 src="../common.js" /> 15 <script type="application/javascript" 16 src="../role.js" /> 17 <script type="application/javascript" 18 src="../states.js" /> 19 <script type="application/javascript" 20 src="../events.js" /> 21 22 <script type="application/javascript"> 23 //gA11yEventDumpID = "eventdump"; // debug stuff 24 //gA11yEventDumpToConsole = true; // debug stuff 25 26 var gQueue = null; 27 function doTests() 28 { 29 // Test focus events. 30 gQueue = new eventQueue(); 31 32 gQueue.push(new synthFocus("textbox", 33 new focusChecker(getNode("textbox")))); 34 gQueue.push(new synthFocusOnFrame("editabledoc")); 35 gQueue.push(new synthFocus("radioclothes", 36 new focusChecker("radiosweater"))); 37 gQueue.push(new synthDownKey("radiosweater", 38 new focusChecker("radiojacket"))); 39 gQueue.push(new synthFocus("checkbox")); 40 gQueue.push(new synthFocus("button")); 41 gQueue.push(new synthFocus("checkbutton")); 42 gQueue.push(new synthFocus("radiobutton")); 43 44 // focus menubutton 45 gQueue.push(new synthFocus("menubutton")); 46 // click menubutton, open popup, focus stays on menu button 47 gQueue.push(new synthClick("menubutton", new nofocusChecker())); 48 // select first menu item ("item 1"), focus on menu item 49 gQueue.push(new synthDownKey("menubutton", new focusChecker("mb_item1"))); 50 // choose select menu item, focus gets back to menubutton 51 gQueue.push(new synthEnterKey("mb_item1", new focusChecker("menubutton"))); 52 // press enter to open popup, focus stays on menubutton 53 gQueue.push(new synthEnterKey("menubutton", new nofocusChecker())); 54 // select second menu item ("item 2"), focus on menu item 55 gQueue.push(new synthUpKey("menubutton", new focusChecker("mb_item2"))); 56 // close the popup 57 gQueue.push(new synthEscapeKey("menubutton", new focusChecker("menubutton"))); 58 59 // clicking on button having associated popup doesn't change focus 60 gQueue.push(new synthClick("popupbutton", [ 61 new nofocusChecker(), 62 new invokerChecker("popupshown", "backpopup") 63 ])); 64 65 // select first menu item ("item 1"), focus on menu item 66 gQueue.push(new synthDownKey("popupbutton", new focusChecker("bp_item1"))); 67 // choose select menu item, focus gets back to menubutton 68 gQueue.push(new synthEnterKey("bp_item1", new focusChecker("menubutton"))); 69 // show popup again for the next test 70 gQueue.push(new synthClick("popupbutton", new nofocusChecker())); 71 72 gQueue.invoke(); // Will call SimpleTest.finish(); 73 } 74 75 SimpleTest.waitForExplicitFinish(); 76 addA11yLoadEvent(doTests); 77 </script> 78 79 <hbox flex="1" style="overflow: auto;"> 80 <body xmlns="http://www.w3.org/1999/xhtml"> 81 <a target="_blank" 82 href="https://bugzilla.mozilla.org/show_bug.cgi?id=552368" 83 title=" fire focus event on document accessible whenever the root or body element is focused"> 84 Mozilla Bug 552368 85 </a> 86 <p id="display"></p> 87 <div id="content" style="display: none"></div> 88 <pre id="test"> 89 </pre> 90 </body> 91 92 <vbox flex="1"> 93 <html:input id="textbox" value="hello"/> 94 <iframe id="editabledoc" src="focus.html"/> 95 <radiogroup id="radioclothes"> 96 <radio id="radiosweater" label="radiosweater"/> 97 <radio id="radiocap" label="radiocap" disabled="true"/> 98 <radio id="radiojacket" label="radiojacket"/> 99 </radiogroup> 100 <checkbox id="checkbox" label="checkbox"/> 101 <button id="button" label="button"/> 102 103 <button id="menubutton" type="menu" label="menubutton"> 104 <menupopup> 105 <menuitem id="mb_item1" label="item1"/> 106 <menuitem id="mb_item2" label="item2"/> 107 </menupopup> 108 </button> 109 110 <button id="checkbutton" type="checkbox" label="checkbutton"/> 111 <button id="radiobutton" type="radio" group="rbgroup" label="radio1"/> 112 113 <popupset> 114 <menupopup id="backpopup" position="after_start"> 115 <menuitem id="bp_item1" label="Page 1"/> 116 <menuitem id="bp_item2" label="Page 2"/> 117 </menupopup> 118 </popupset> 119 <button id="popupbutton" label="Pop Me Up" popup="backpopup"/> 120 121 <vbox id="eventdump"/> 122 </vbox> 123 </hbox> 124 </window>