2008-03-05 20:14:10 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
|
|
|
type="text/css"?>
|
|
|
|
|
|
|
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
2009-09-10 18:07:56 -07:00
|
|
|
title="nsIAccessibleTable selection methods on xul:listbox test.">
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
2009-03-07 03:23:25 -08:00
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
|
|
|
|
<script type="application/javascript"
|
2009-09-10 18:07:56 -07:00
|
|
|
src="chrome://mochikit/content/a11y/accessible/table.js"></script>
|
2009-03-07 03:23:25 -08:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
<script type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
function doTest()
|
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
var id = "listbox3";
|
|
|
|
var acc = getAccessible(id, [nsIAccessibleTable]);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
var rowCount = acc.rows;
|
2008-03-05 20:14:10 -08:00
|
|
|
var colsCount = acc.columns;
|
|
|
|
|
|
|
|
// columns selection
|
|
|
|
testColumnSelection(id, acc, colsCount, 0, null);
|
|
|
|
acc.selectColumn(0);
|
|
|
|
testColumnSelection(id, acc, colsCount, 0, null);
|
|
|
|
|
|
|
|
// rows selection
|
2009-09-10 18:07:56 -07:00
|
|
|
testRowSelection(id, acc, rowCount, 0, null);
|
2008-03-05 20:14:10 -08:00
|
|
|
acc.selectRow(0);
|
2009-09-10 18:07:56 -07:00
|
|
|
testRowSelection(id, acc, rowCount, 1, [0]);
|
2008-03-05 20:14:10 -08:00
|
|
|
acc.selectRow(1);
|
2009-09-10 18:07:56 -07:00
|
|
|
testRowSelection(id, acc, rowCount, 1, [1]);
|
2008-03-05 20:14:10 -08:00
|
|
|
acc.unselectRow(1);
|
2009-09-10 18:07:56 -07:00
|
|
|
testRowSelection(id, acc, rowCount, 0, null);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
// cells selection
|
2009-09-10 18:07:56 -07:00
|
|
|
testCellSelection(id, acc, rowCount, colsCount, 0, null);
|
2008-03-05 20:14:10 -08:00
|
|
|
acc.selectRow(2);
|
2009-09-10 18:07:56 -07:00
|
|
|
testCellSelection(id, acc, rowCount, colsCount, 3, [6, 7, 8]);
|
2008-03-05 20:14:10 -08:00
|
|
|
acc.unselectRow(2);
|
2009-09-10 18:07:56 -07:00
|
|
|
testCellSelection(id, acc, rowCount, colsCount, 0, null);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-09-10 20:31:19 -07:00
|
|
|
* Helper function to test isColumnSelected(), selectedColumnCount and
|
2008-03-05 20:14:10 -08:00
|
|
|
* getSelectedColumn() methods.
|
|
|
|
*/
|
|
|
|
function testColumnSelection(aId, aAcc, aCount, aSelCount, aSelIndexesArray)
|
|
|
|
{
|
|
|
|
// isColumnSelected
|
|
|
|
for (var col = 0; col < aCount; col++) {
|
|
|
|
if (aSelIndexesArray && aSelIndexesArray.indexOf(col) != -1) {
|
|
|
|
is(aAcc.isColumnSelected(col), true,
|
|
|
|
aId + ": column " + col + " should be selected");
|
|
|
|
} else {
|
|
|
|
is(aAcc.isColumnSelected(col), false,
|
|
|
|
aId + ": column " + col + " shouldn't be selected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-10 20:31:19 -07:00
|
|
|
// selectedColumnCount
|
|
|
|
is(aAcc.selectedColumnCount, aSelCount,
|
2008-03-05 20:14:10 -08:00
|
|
|
aId + ": wrong number of selected columns");
|
|
|
|
|
|
|
|
// getSelectedColumns
|
|
|
|
var selColsCount = {}, selCols = {};
|
2009-09-10 18:07:56 -07:00
|
|
|
aAcc.getSelectedColumnIndices(selColsCount, selCols);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
is(selColsCount.value, aSelCount,
|
|
|
|
aId + ": wrong number of selected columns");
|
|
|
|
|
|
|
|
if (!aSelIndexesArray) {
|
|
|
|
is(selCols.value, null,
|
|
|
|
aId + ": no columns should be selected");
|
|
|
|
} else {
|
|
|
|
for (var i = 0; i < selCols.length; i++) {
|
|
|
|
is(selCols[i], aSelIndexesArray[i],
|
|
|
|
aId + ": wrong selected column index " + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to test isRowSelected(), selectedRowCount() and
|
|
|
|
* getSelectedRow() methods.
|
|
|
|
*/
|
|
|
|
function testRowSelection(aId, aAcc, aCount, aSelCount, aSelIndexesArray)
|
|
|
|
{
|
|
|
|
// isRowSelected
|
|
|
|
for (var row = 0; row < aCount; row++) {
|
|
|
|
if (aSelIndexesArray && aSelIndexesArray.indexOf(row) != -1) {
|
|
|
|
is(aAcc.isRowSelected(row), true,
|
|
|
|
aId + ": row " + row + " should be selected");
|
|
|
|
} else {
|
|
|
|
is(aAcc.isRowSelected(row), false,
|
|
|
|
aId + ": row " + row + " shouldn't be selected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-10 20:31:19 -07:00
|
|
|
// selectedRowCount
|
|
|
|
is(aAcc.selectedRowCount, aSelCount,
|
2008-03-05 20:14:10 -08:00
|
|
|
aId + ": wrong number of selected rows");
|
|
|
|
|
|
|
|
// getSelectedRows
|
|
|
|
var selColsCount = {}, selCols = {};
|
2009-09-10 18:07:56 -07:00
|
|
|
aAcc.getSelectedRowIndices(selColsCount, selCols);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
is(selColsCount.value, aSelCount,
|
|
|
|
aId + ": wrong number of selected rows");
|
|
|
|
|
|
|
|
if (!aSelIndexesArray) {
|
|
|
|
is(selCols.value, null,
|
|
|
|
aId + ": no row should be selected");
|
|
|
|
} else {
|
|
|
|
for (var i = 0; i < selCols.length; i++) {
|
|
|
|
is(selCols[i], aSelIndexesArray[i],
|
|
|
|
aId + ": wrong selected row index " + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to test isCellSelected(), selectedCellCount() and
|
|
|
|
* getSelectedCells() methods.
|
|
|
|
*/
|
|
|
|
function testCellSelection(aId, aAcc, aRowCount, aColCount,
|
|
|
|
aSelCount, aSelIndexesArray)
|
|
|
|
{
|
|
|
|
// isCellSelected
|
|
|
|
for (var row = 0; row < aRowCount; row++) {
|
|
|
|
for (var col = 0; col < aColCount; col++) {
|
|
|
|
var index = aAcc.getIndexAt(row, col);
|
|
|
|
if (aSelIndexesArray && aSelIndexesArray.indexOf(index) != -1) {
|
|
|
|
is(aAcc.isCellSelected(row, col), true,
|
|
|
|
aId + ": cell (" + row + ", " + col + ") should be selected");
|
|
|
|
} else {
|
|
|
|
is(aAcc.isCellSelected(row, col), false,
|
|
|
|
aId + ": cell (" + row + ", " + col + ") shouldn't be selected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// selectedCellCount
|
2009-09-10 18:07:56 -07:00
|
|
|
is(aAcc.selectedCellCount, aSelCount,
|
2008-03-05 20:14:10 -08:00
|
|
|
aId + ": wrong number of selected cells");
|
|
|
|
|
|
|
|
// getSelectedCells
|
|
|
|
var selColsCount = {}, selCols = {};
|
2009-09-10 18:07:56 -07:00
|
|
|
aAcc.getSelectedCellIndices(selColsCount, selCols);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
is(selColsCount.value, aSelCount,
|
|
|
|
aId + ": wrong number of selected cells");
|
|
|
|
|
|
|
|
if (!aSelIndexesArray) {
|
|
|
|
is(selCols.value, null,
|
|
|
|
aId + ": no cells should be selected");
|
|
|
|
} else {
|
|
|
|
for (var i = 0; i < selCols.length; i++) {
|
|
|
|
is(selCols[i], aSelIndexesArray[i],
|
|
|
|
aId + ": wrong selected cell index " + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2009-09-23 07:21:47 -07:00
|
|
|
addA11yLoadEvent(doTest);
|
2008-03-05 20:14:10 -08:00
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<hbox style="overflow: auto;">
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=418371"
|
|
|
|
title="implement the rest of methods of nsIAccessibleTable on xul:listbox">
|
|
|
|
Mozilla Bug 418371
|
|
|
|
</a>
|
2009-09-10 18:07:56 -07:00
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424"
|
|
|
|
title="implement IAccessibleTable2">
|
|
|
|
Mozilla Bug 512424
|
|
|
|
</a>
|
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
<vbox flex="1">
|
|
|
|
|
|
|
|
<label control="listbox2" value="multicolumn listbox: "/>
|
|
|
|
<listbox id="listbox2">
|
|
|
|
<listcols>
|
|
|
|
<listcol flex="1"/>
|
|
|
|
<listcol flex="1"/>
|
|
|
|
</listcols>
|
|
|
|
<listitem>
|
|
|
|
<listcell label="cell1"/>
|
|
|
|
<listcell label="cell2"/>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<listcell label="cell1"/>
|
|
|
|
<listcell label="cell2"/>
|
|
|
|
</listitem>
|
|
|
|
</listbox>
|
|
|
|
|
|
|
|
<label control="listbox3" value="multicolumn listbox with header"/>
|
|
|
|
<listbox id="listbox3">
|
|
|
|
<listhead>
|
|
|
|
<listheader label="header1"/>
|
|
|
|
<listheader label="header2"/>
|
|
|
|
<listheader label="header3"/>
|
|
|
|
</listhead>
|
|
|
|
<listcols>
|
|
|
|
<listcol flex="1"/>
|
|
|
|
<listcol flex="1"/>
|
|
|
|
<listcol flex="1"/>
|
|
|
|
</listcols>
|
|
|
|
<listitem>
|
|
|
|
<listcell label="cell0"/>
|
|
|
|
<listcell label="cell1"/>
|
|
|
|
<listcell label="cell2"/>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<listcell label="cell3"/>
|
|
|
|
<listcell label="cell4"/>
|
|
|
|
<listcell label="cell5"/>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<listcell label="cell6"/>
|
|
|
|
<listcell label="cell7"/>
|
|
|
|
<listcell label="cell8"/>
|
|
|
|
</listitem>
|
|
|
|
</listbox>
|
|
|
|
</vbox>
|
|
|
|
</hbox>
|
|
|
|
|
|
|
|
</window>
|
|
|
|
|