gecko/accessible/tests/mochitest/test_nsIAccessibleTable_3.html

128 lines
3.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> nsIAccessibleTable Interface Test Case </title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript">
function doTest()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var table = document.getElementById("table");
var accService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
getService(Components.interfaces.nsIAccessibleRetrieval);
var accTable = accService.getAccessibleFor(table).
QueryInterface(Components.interfaces.nsIAccessibleTable);
is(accTable.getSelectedCells({}).length, 0, "no cell selected");
for (var i = 0; i < 4; i++) {
accTable.selectRow(i);
for (var j = 0; j < 4; j++) {
if (i == j) {
ok(accTable.isRowSelected(i),"row not selected");
}
else {
todo(!accTable.isRowSelected(i),"row selected");
}
}
}
todo_is(accTable.selectedRowsCount, 1, "only one row should be selected");
todo_is(accTable.getSelectedRows({}).length, 1,
"only one row should be selected");
for (var i = 0; i < 4; i++) {
accTable.unselectRow(i);
ok(!accTable.isRowSelected(i), "row still selected");
}
todo_is(accTable.getSelectedCells({}).length, 0, "no cell selected");
todo_is(accTable.selectedCellsCount, 0, "no cell selected");
var s = window.getSelection();
if (s.rangeCount > 0)
s.removeAllRanges();
is(accTable.getSelectedCells({}).length, 0, "no cell selected");
is(accTable.selectedCellsCount, 0, "no cell selected");
for (var i = 0; i < 8; i++) {
accTable.selectColumn(i);
for (var j = 0; j < 8; j++) {
if (i ==j) {
ok(accTable.isColumnSelected(i),"column not selected");
}
else {
todo(!accTable.isColumnSelected(i),"column is selected");
}
}
}
todo_is(accTable.selectedColumnsCount, 1,
"only one column should be selected");
todo_is(accTable.getSelectedColumns({}).length, 1,
"only one column should be selected");
for (var i = 0; i < 8; i++) {
accTable.unselectColumn(i);
ok(!accTable.isColumnSelected(i),"column still selected");
}
is(accTable.selectedColumnsCount, 0, "no column should be selected");
ok(!accTable.isProbablyForLayout(), "table is not for layout");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<!-- Test Table -->
<br><br><b> Testing Table:</b><br><br>
<center>
<table cellpadding="2" cellspacing="2" border="1" width="50%" id="table">
<tbody>
<tr>
<td><br></td>
<td><br></td>
<td rowspan="1" colspan="2"><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td rowspan="4" colspan="1"><br></td>
</tr>
<tr>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
</tr>
<tr>
<td><br></td>
<td rowspan="2" colspan="2">c1</td>
<td><br></td>
<td><br></td>
<td rowspan="2" colspan="1"><br></td>
<td><br></td>
</tr>
<tr>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
</tr>
</tbody>
</table>
</center>
</body>
</html>