test_takeFocus.xhtml (3100B)
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 title="Accessible focus testing"> 8 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 10 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 11 12 <script type="application/javascript" 13 src="../common.js" /> 14 <script type="application/javascript" 15 src="../role.js" /> 16 <script type="application/javascript" 17 src="../states.js" /> 18 <script type="application/javascript" 19 src="../events.js" /> 20 21 <script type="application/javascript" 22 src="../treeview.js" /> 23 24 <script type="application/javascript"> 25 <![CDATA[ 26 //////////////////////////////////////////////////////////////////////////// 27 // Invokers 28 29 function takeFocusInvoker(aID, aArgConverterFunc) 30 { 31 this.targetFunc = aArgConverterFunc ? aArgConverterFunc : getAccessible; 32 33 this.eventSeq = [ new focusChecker(this.targetFunc, aID) ]; 34 35 this.invoke = function takeFocusInvoker_invoke() 36 { 37 this.targetFunc.call(null, aID).takeFocus(); 38 } 39 40 this.getID = function takeFocusInvoker_getID() 41 { 42 return "takeFocus for " + prettyName(aID); 43 } 44 } 45 46 function getLastChild(aID) 47 { 48 return getAccessible(aID).lastChild; 49 } 50 51 //////////////////////////////////////////////////////////////////////////// 52 // Tests 53 54 //gA11yEventDumpID = "eventdump"; // debug stuff 55 //gA11yEventDumpToConsole = true; // debug stuff 56 57 var gQueue = null; 58 function doTests() 59 { 60 // Test focus events. 61 gQueue = new eventQueue(); 62 63 gQueue.push(new takeFocusInvoker("tree", getLastChild)); 64 gQueue.push(new takeFocusInvoker("listitem2")); 65 66 gQueue.invoke(); // Will call SimpleTest.finish(); 67 } 68 69 SimpleTest.waitForExplicitFinish(); 70 addA11yXULTreeLoadEvent(doTests, "tree", new nsTableTreeView(5)); 71 ]]> 72 </script> 73 74 <hbox flex="1" style="overflow: auto;"> 75 <body xmlns="http://www.w3.org/1999/xhtml"> 76 <a target="_blank" 77 href="https://bugzilla.mozilla.org/show_bug.cgi?id=706067" 78 title="Make takeFocus work on widget items"> 79 Mozilla Bug 706067 80 </a> 81 <p id="display"></p> 82 <div id="content" style="display: none"></div> 83 <pre id="test"> 84 </pre> 85 </body> 86 87 <vbox flex="1"> 88 <tree id="tree" flex="1"> 89 <treecols> 90 <treecol id="col1" flex="1" primary="true" label="column"/> 91 <treecol id="col2" flex="1" label="column 2"/> 92 </treecols> 93 <treechildren id="treechildren"/> 94 </tree> 95 96 <richlistbox id="listbox"> 97 <richlistitem id="listitem1"><label value="item1"/></richlistitem> 98 <richlistitem id="listitem2"><label value="item2"/></richlistitem> 99 </richlistbox> 100 101 <vbox id="eventdump"/> 102 </vbox> 103 </hbox> 104 </window>