accessible/tests/mochitest/table/test_sels_listbox.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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="nsIAccessibleTable selection methods on xul:listbox test.">
michael@0 8
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 11
michael@0 12 <script type="application/javascript"
michael@0 13 src="../common.js"></script>
michael@0 14 <script type="application/javascript"
michael@0 15 src="../table.js"></script>
michael@0 16
michael@0 17 <script type="application/javascript">
michael@0 18 <![CDATA[
michael@0 19 function doTest()
michael@0 20 {
michael@0 21 var id = "listbox3";
michael@0 22 var acc = getAccessible(id, [nsIAccessibleTable]);
michael@0 23
michael@0 24 var rowCount = acc.rows;
michael@0 25 var colsCount = acc.columns;
michael@0 26
michael@0 27 // columns selection
michael@0 28 testColumnSelection(id, acc, colsCount, 0, null);
michael@0 29 acc.selectColumn(0);
michael@0 30 testColumnSelection(id, acc, colsCount, 0, null);
michael@0 31
michael@0 32 // rows selection
michael@0 33 testRowSelection(id, acc, rowCount, 0, null);
michael@0 34 acc.selectRow(0);
michael@0 35 testRowSelection(id, acc, rowCount, 1, [0]);
michael@0 36 acc.selectRow(1);
michael@0 37 testRowSelection(id, acc, rowCount, 1, [1]);
michael@0 38 acc.unselectRow(1);
michael@0 39 testRowSelection(id, acc, rowCount, 0, null);
michael@0 40
michael@0 41 // cells selection
michael@0 42 testCellSelection(id, acc, rowCount, colsCount, 0, null);
michael@0 43 acc.selectRow(2);
michael@0 44 testCellSelection(id, acc, rowCount, colsCount, 3, [6, 7, 8]);
michael@0 45 acc.unselectRow(2);
michael@0 46 testCellSelection(id, acc, rowCount, colsCount, 0, null);
michael@0 47
michael@0 48 SimpleTest.finish();
michael@0 49 }
michael@0 50
michael@0 51 /**
michael@0 52 * Helper function to test isColumnSelected(), selectedColumnCount and
michael@0 53 * getSelectedColumn() methods.
michael@0 54 */
michael@0 55 function testColumnSelection(aId, aAcc, aCount, aSelCount, aSelIndexesArray)
michael@0 56 {
michael@0 57 // isColumnSelected
michael@0 58 for (var col = 0; col < aCount; col++) {
michael@0 59 if (aSelIndexesArray && aSelIndexesArray.indexOf(col) != -1) {
michael@0 60 is(aAcc.isColumnSelected(col), true,
michael@0 61 aId + ": column " + col + " should be selected");
michael@0 62 } else {
michael@0 63 is(aAcc.isColumnSelected(col), false,
michael@0 64 aId + ": column " + col + " shouldn't be selected");
michael@0 65 }
michael@0 66 }
michael@0 67
michael@0 68 // selectedColumnCount
michael@0 69 is(aAcc.selectedColumnCount, aSelCount,
michael@0 70 aId + ": wrong number of selected columns");
michael@0 71
michael@0 72 // getSelectedColumns
michael@0 73 var selColsCount = {}, selCols = {};
michael@0 74 aAcc.getSelectedColumnIndices(selColsCount, selCols);
michael@0 75
michael@0 76 is(selColsCount.value, aSelCount,
michael@0 77 aId + ": wrong number of selected columns");
michael@0 78
michael@0 79 if (!aSelIndexesArray) {
michael@0 80 is(selCols.value, null,
michael@0 81 aId + ": no columns should be selected");
michael@0 82 } else {
michael@0 83 for (var i = 0; i < selCols.length; i++) {
michael@0 84 is(selCols[i], aSelIndexesArray[i],
michael@0 85 aId + ": wrong selected column index " + i);
michael@0 86 }
michael@0 87 }
michael@0 88 }
michael@0 89
michael@0 90 /**
michael@0 91 * Helper function to test isRowSelected(), selectedRowCount() and
michael@0 92 * getSelectedRow() methods.
michael@0 93 */
michael@0 94 function testRowSelection(aId, aAcc, aCount, aSelCount, aSelIndexesArray)
michael@0 95 {
michael@0 96 // isRowSelected
michael@0 97 for (var row = 0; row < aCount; row++) {
michael@0 98 if (aSelIndexesArray && aSelIndexesArray.indexOf(row) != -1) {
michael@0 99 is(aAcc.isRowSelected(row), true,
michael@0 100 aId + ": row " + row + " should be selected");
michael@0 101 } else {
michael@0 102 is(aAcc.isRowSelected(row), false,
michael@0 103 aId + ": row " + row + " shouldn't be selected");
michael@0 104 }
michael@0 105 }
michael@0 106
michael@0 107 // selectedRowCount
michael@0 108 is(aAcc.selectedRowCount, aSelCount,
michael@0 109 aId + ": wrong number of selected rows");
michael@0 110
michael@0 111 // getSelectedRows
michael@0 112 var selColsCount = {}, selCols = {};
michael@0 113 aAcc.getSelectedRowIndices(selColsCount, selCols);
michael@0 114
michael@0 115 is(selColsCount.value, aSelCount,
michael@0 116 aId + ": wrong number of selected rows");
michael@0 117
michael@0 118 if (!aSelIndexesArray) {
michael@0 119 is(selCols.value, null,
michael@0 120 aId + ": no row should be selected");
michael@0 121 } else {
michael@0 122 for (var i = 0; i < selCols.length; i++) {
michael@0 123 is(selCols[i], aSelIndexesArray[i],
michael@0 124 aId + ": wrong selected row index " + i);
michael@0 125 }
michael@0 126 }
michael@0 127 }
michael@0 128
michael@0 129 /**
michael@0 130 * Helper function to test isCellSelected(), selectedCellCount() and
michael@0 131 * getSelectedCells() methods.
michael@0 132 */
michael@0 133 function testCellSelection(aId, aAcc, aRowCount, aColCount,
michael@0 134 aSelCount, aSelIndexesArray)
michael@0 135 {
michael@0 136 // isCellSelected
michael@0 137 for (var row = 0; row < aRowCount; row++) {
michael@0 138 for (var col = 0; col < aColCount; col++) {
michael@0 139 var index = aAcc.getIndexAt(row, col);
michael@0 140 if (aSelIndexesArray && aSelIndexesArray.indexOf(index) != -1) {
michael@0 141 is(aAcc.isCellSelected(row, col), true,
michael@0 142 aId + ": cell (" + row + ", " + col + ") should be selected");
michael@0 143 } else {
michael@0 144 is(aAcc.isCellSelected(row, col), false,
michael@0 145 aId + ": cell (" + row + ", " + col + ") shouldn't be selected");
michael@0 146 }
michael@0 147 }
michael@0 148 }
michael@0 149
michael@0 150 // selectedCellCount
michael@0 151 is(aAcc.selectedCellCount, aSelCount,
michael@0 152 aId + ": wrong number of selected cells");
michael@0 153
michael@0 154 // getSelectedCells
michael@0 155 var selColsCount = {}, selCols = {};
michael@0 156 aAcc.getSelectedCellIndices(selColsCount, selCols);
michael@0 157
michael@0 158 is(selColsCount.value, aSelCount,
michael@0 159 aId + ": wrong number of selected cells");
michael@0 160
michael@0 161 if (!aSelIndexesArray) {
michael@0 162 is(selCols.value, null,
michael@0 163 aId + ": no cells should be selected");
michael@0 164 } else {
michael@0 165 for (var i = 0; i < selCols.length; i++) {
michael@0 166 is(selCols[i], aSelIndexesArray[i],
michael@0 167 aId + ": wrong selected cell index " + i);
michael@0 168 }
michael@0 169 }
michael@0 170 }
michael@0 171
michael@0 172 SimpleTest.waitForExplicitFinish();
michael@0 173 addA11yLoadEvent(doTest);
michael@0 174 ]]>
michael@0 175 </script>
michael@0 176
michael@0 177 <hbox style="overflow: auto;">
michael@0 178 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 179 <a target="_blank"
michael@0 180 href="https://bugzilla.mozilla.org/show_bug.cgi?id=418371"
michael@0 181 title="implement the rest of methods of nsIAccessibleTable on xul:listbox">
michael@0 182 Mozilla Bug 418371
michael@0 183 </a>
michael@0 184 <a target="_blank"
michael@0 185 href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424"
michael@0 186 title="implement IAccessibleTable2">
michael@0 187 Mozilla Bug 512424
michael@0 188 </a>
michael@0 189
michael@0 190 <p id="display"></p>
michael@0 191 <div id="content" style="display: none">
michael@0 192 </div>
michael@0 193 <pre id="test">
michael@0 194 </pre>
michael@0 195 </body>
michael@0 196
michael@0 197 <vbox flex="1">
michael@0 198
michael@0 199 <label control="listbox2" value="multicolumn listbox: "/>
michael@0 200 <listbox id="listbox2">
michael@0 201 <listcols>
michael@0 202 <listcol flex="1"/>
michael@0 203 <listcol flex="1"/>
michael@0 204 </listcols>
michael@0 205 <listitem>
michael@0 206 <listcell label="cell1"/>
michael@0 207 <listcell label="cell2"/>
michael@0 208 </listitem>
michael@0 209 <listitem>
michael@0 210 <listcell label="cell1"/>
michael@0 211 <listcell label="cell2"/>
michael@0 212 </listitem>
michael@0 213 </listbox>
michael@0 214
michael@0 215 <label control="listbox3" value="multicolumn listbox with header"/>
michael@0 216 <listbox id="listbox3">
michael@0 217 <listhead>
michael@0 218 <listheader label="header1"/>
michael@0 219 <listheader label="header2"/>
michael@0 220 <listheader label="header3"/>
michael@0 221 </listhead>
michael@0 222 <listcols>
michael@0 223 <listcol flex="1"/>
michael@0 224 <listcol flex="1"/>
michael@0 225 <listcol flex="1"/>
michael@0 226 </listcols>
michael@0 227 <listitem>
michael@0 228 <listcell label="cell0"/>
michael@0 229 <listcell label="cell1"/>
michael@0 230 <listcell label="cell2"/>
michael@0 231 </listitem>
michael@0 232 <listitem>
michael@0 233 <listcell label="cell3"/>
michael@0 234 <listcell label="cell4"/>
michael@0 235 <listcell label="cell5"/>
michael@0 236 </listitem>
michael@0 237 <listitem>
michael@0 238 <listcell label="cell6"/>
michael@0 239 <listcell label="cell7"/>
michael@0 240 <listcell label="cell8"/>
michael@0 241 </listitem>
michael@0 242 </listbox>
michael@0 243 </vbox>
michael@0 244 </hbox>
michael@0 245
michael@0 246 </window>
michael@0 247

mercurial