adding testcases for the nsIAccessibleTable interface r=marcoz bug 415730

This commit is contained in:
bmlk%gmx.de 2008-02-23 11:34:39 +00:00
Родитель 9fda5a550e
Коммит 57c43348f5
4 изменённых файлов: 361 добавлений и 0 удалений

Просмотреть файл

@ -48,6 +48,9 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_bug368835.xul \
test_groupattrs.xul \
test_nsIAccessibleTable_1.html \
test_nsIAccessibleTable_2.html \
test_nsIAccessibleTable_3.html \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,144 @@
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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="application/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);
var caption = accTable.caption;
is(caption.firstChild.name, "Test Table", "wrong text inside caption");
const nsIAccessNode = Components.interfaces.nsIAccessible;
is(caption.children.queryElementAt(0, nsIAccessNode).name, "Test Table",
"wrong text inside caption");
is(accTable.summary, "this is a test table for nsIAccessibleTable",
"wrong summary on table");
is(accTable.columns, 4,"wrong number of columns");
is(accTable.rows, 3, "wrong number of rows");
var s = window.getSelection();
if (s.rangeCount > 0)
s.removeAllRanges();
var cell = document.getElementById("col2b");
var range = document.createRange();
range.selectNode(cell);
s.addRange(range);
is(accTable.selectedCellsCount, 1,"only one cell selected");
cell = document.getElementById("col2a");
range.selectNode(cell);
s.addRange(range);
cell = document.getElementById("col2c");
range.selectNode(cell);
s.addRange(range);
is(accTable.selectedColumnsCount, 1, "only one column selected");
cell = document.getElementById("row2a");
range.selectNode(cell);
s.addRange(range);
cell = document.getElementById("row2b");
range.selectNode(cell);
s.addRange(range);
cell = document.getElementById("row2c");
range.selectNode(cell);
s.addRange(range);
is(accTable.selectedRowsCount, 1, "no cells selected");
var rowheader;
var works;
works = true;
try {
rowheader = accTable.rowHeader;
}
catch (e) {
works = false;
}
todo(works, "rowHeader should not throw");
var columnHeader;
works = true;
try {
columnHeader = accTable.columnHeader;
columnHeaderIndex =columnHeader.getIndexAt(0,2);
is(columnHeaderIndex, 2, "columnheaderindex is wrong");
}
catch (e) {
works = false;
}
todo(works, "columnHeader should not throw");
var columnDescription;
works = true;
try{
columnDescription = accTable.getColumnDescription(1);
}
catch (e) {
works = false;
}
todo(works, "columnDescription should not throw");
var rowDescription;
works = true;
try {
rowDescription = accTable.getRowDescription(1);
}
catch (e) {
works = false;
}
todo(works, "rowDescription should not throw");
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 id="table" border="1"
summary="this is a test table for nsIAccessibleTable" >
<caption>Test Table</caption>
<thead>
<tr>
<th></th>
<th>columnHeader_1</th>
<th id ="col2a">columnHeader_2</th>
<th>columnHeader_3</th>
</tr>
</thead>
<tr>
<th id="row2a">rowHeader_1</th>
<td id="row2b">row1_column1</td>
<td id ="col2b">row1_column2</td>
<td id="row2c">row1_column3</td>
</tr>
<tr>
<th>rowHeader_2</th>
<td>row2_column1</td>
<td id ="col2c">row2_column2</td>
<td>row2_column3</td>
</tr>
</table>
</center>
</body>
</html>

Просмотреть файл

@ -0,0 +1,87 @@
<!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.getIndexAt(2,4), 17, "wrong index returned");
is(accTable.getColumnAtIndex(18), 5,"got wrong column");
is(accTable.getRowAtIndex(10), 1, "wrong row");
is(accTable.getColumnExtentAt(2,2), 2, "colspan wrong");
is(accTable.getColumnExtentAt(0,3), 2, "colspan wrong");
is(accTable.getColumnExtentAt(3,5), 1, "colspan");
is(accTable.getRowExtentAt(0,7), 4, "rowspan wrong");
is(accTable.getRowExtentAt(2,7), 4,"rowspan wrong");
is(accTable.getColumnExtentAt(2,3), 1, "colspan wrong");
is(accTable.cellRefAt(2,1).firstChild.name, "c1", "wrong cell");
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>

Просмотреть файл

@ -0,0 +1,127 @@
<!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>