test_listbox.xhtml (4645B)
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 <?xml-stylesheet href="../treeview.css" type="text/css"?> 6 7 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 8 title="XUL tree selectable tests"> 9 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.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="../selectable.js" /> 20 21 <script type="application/javascript"> 22 <![CDATA[ 23 24 //////////////////////////////////////////////////////////////////////////// 25 // Test 26 27 //gA11yEventDumpID = "debug"; 28 29 var gQueue = null; 30 31 function doTest() 32 { 33 ////////////////////////////////////////////////////////////////////////// 34 // single selectable listbox, the first item is selected by default 35 36 var id = "listbox"; 37 ok(isAccessible(id, [nsIAccessibleSelectable]), 38 "No selectable accessible for list of " + id); 39 40 var select = getAccessible(id, [nsIAccessibleSelectable]); 41 select.removeItemFromSelection(0); 42 testSelectableSelection(select, [ ]); 43 44 select.addItemToSelection(1); 45 testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelect(1): "); 46 47 select.removeItemFromSelection(1); 48 testSelectableSelection(select, [ ], 49 "removeItemFromSelection(1): "); 50 51 todo(!select.selectAll(), 52 "No way to select all items in listbox '" + id + "'"); 53 testSelectableSelection(select, [ "lb1_item1" ], "selectAll: "); 54 55 select.addItemToSelection(1); 56 select.unselectAll(); 57 testSelectableSelection(select, [ ], "unselectAll: "); 58 59 ////////////////////////////////////////////////////////////////////////// 60 // multiple selectable listbox 61 62 id = "listbox2"; 63 ok(isAccessible(id, [nsIAccessibleSelectable]), 64 "No selectable accessible for list of " + id); 65 66 select = getAccessible(id, [nsIAccessibleSelectable]); 67 testSelectableSelection(select, [ ]); 68 69 select.addItemToSelection(1); 70 testSelectableSelection(select, [ "lb2_item2" ], "addItemToSelect(1): "); 71 72 select.removeItemFromSelection(1); 73 testSelectableSelection(select, [ ], 74 "removeItemFromSelection(1): "); 75 76 is(select.selectAll(), true, 77 "All items should be selected in listbox '" + id + "'"); 78 testSelectableSelection(select, [ "lb2_item1", "lb2_item2" ], 79 "selectAll: "); 80 81 select.unselectAll(); 82 testSelectableSelection(select, [ ], "unselectAll: "); 83 84 ////////////////////////////////////////////////////////////////////////// 85 // listbox with headers 86 87 // XXX: addItemToSelection/removeItemFromSelection don't work correctly 88 // on listboxes with headers because header is inserted into hierarchy 89 // and child indexes that are used in these methods are shifted (see bug 90 // 591939). 91 todo(false, 92 "Fix addItemToSelection/removeItemFromSelection on listboxes with headers."); 93 94 SimpleTest.finish(); 95 } 96 97 SimpleTest.waitForExplicitFinish(); 98 addA11yLoadEvent(doTest); 99 ]]> 100 </script> 101 102 <hbox flex="1" style="overflow: auto;"> 103 <body xmlns="http://www.w3.org/1999/xhtml"> 104 <a target="_blank" 105 href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" 106 title="add pseudo SelectAccessible interface"> 107 Mozilla Bug 590176 108 </a><br/> 109 <p id="display"></p> 110 <div id="content" style="display: none"> 111 </div> 112 <pre id="test"> 113 </pre> 114 </body> 115 116 <vbox flex="1"> 117 <richlistbox id="listbox"> 118 <richlistitem id="lb1_item1"> 119 <label value="cell0"/> 120 <label value="cell1"/> 121 </richlistitem> 122 <richlistitem id="lb1_item2"> 123 <label value="cell3"/> 124 <label value="cell4"/> 125 </richlistitem> 126 </richlistbox> 127 128 <richlistbox id="listbox2" seltype="multiple"> 129 <richlistitem id="lb2_item1"> 130 <label value="cell0"/> 131 <label value="cell1"/> 132 </richlistitem> 133 <richlistitem id="lb2_item2"> 134 <label value="cell3"/> 135 <label value="cell4"/> 136 </richlistitem> 137 </richlistbox> 138 139 <vbox id="debug"/> 140 </vbox> 141 </hbox> 142 143 </window>