зеркало из https://github.com/mozilla/pjs.git
188 строки
5.5 KiB
HTML
188 строки
5.5 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">
|
|
<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 accService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
|
getService(Components.interfaces.nsIAccessibleRetrieval);
|
|
var Ci = Components.interfaces;
|
|
|
|
// Test table with display:inline. We shouldn't create table accessible and
|
|
// table cell accessible in this case
|
|
var table1 = document.getElementById("table1");
|
|
var accNotCreated = false;
|
|
try {
|
|
var accTable1 = accService.getAccessibleFor(table1);
|
|
} catch (e) {
|
|
accNotCreated = true;
|
|
}
|
|
ok(accNotCreated, "wrongly created table accessible");
|
|
|
|
if (accNotCreated) {
|
|
var div = document.getElementById("div");
|
|
var accDiv = accService.getAccessibleFor(div);
|
|
is(accDiv.firstChild.name, "cell", "wrongly created table cell accessible");
|
|
}
|
|
|
|
// Test table with display:inline and have an another outside table
|
|
var table2 = document.getElementById("table2");
|
|
accNotCreated = false;
|
|
try {
|
|
var accTable2 = accService.getAccessibleFor(table2);
|
|
} catch (e) {
|
|
accNotCreated = true;
|
|
}
|
|
ok(accNotCreated, "wrongly created table accessible");
|
|
|
|
var cell = document.getElementById("cell");
|
|
accNotCreated = false;
|
|
try {
|
|
var accCell = accService.getAccessibleFor(cell);
|
|
} catch (e) {
|
|
accNotCreated = true;
|
|
}
|
|
ok(accNotCreated, "wrongly created table cell accessible");
|
|
|
|
// Test table with role=alert.
|
|
var table3 = document.getElementById("table3");
|
|
var accTable3;
|
|
var tableInterfaceExposed = true;
|
|
try {
|
|
accTable3 = accService.getAccessibleFor(table3).
|
|
QueryInterface(Components.interfaces.nsIAccessibleTable);
|
|
} catch (e) {
|
|
tableInterfaceExposed = false;
|
|
}
|
|
ok(tableInterfaceExposed, "table interface is not exposed");
|
|
|
|
if (tableInterfaceExposed) {
|
|
is(accTable3.finalRole, Ci.nsIAccessibleRole.ROLE_ALERT, "wrong role");
|
|
|
|
is(accTable3.cellRefAt(0,0).firstChild.name, "cell0", "wrong cell");
|
|
is(accTable3.cellRefAt(0,1).firstChild.name, "cell1", "wrong cell");
|
|
}
|
|
|
|
// Test table with role=log and aria property in tr. We create accessible for
|
|
// tr in this case.
|
|
var table4 = document.getElementById("table4");
|
|
var accTable4;
|
|
tableInterfaceExposed = true;
|
|
try {
|
|
accTable4 = accService.getAccessibleFor(table4).
|
|
QueryInterface(Components.interfaces.nsIAccessibleTable);
|
|
} catch (e) {
|
|
tableInterfaceExposed = false;
|
|
}
|
|
ok(tableInterfaceExposed, "table interface is not exposed");
|
|
|
|
if (tableInterfaceExposed) {
|
|
var tr = document.getElementById("tr");
|
|
accNotCreated = false;
|
|
try {
|
|
var accTr = accService.getAccessibleFor(tr);
|
|
} catch (e) {
|
|
accNotCreated = true;
|
|
}
|
|
ok(!accNotCreated, "missed tr accessible");
|
|
|
|
is(accTable4.role, Ci.nsIAccessibleRole.ROLE_TABLE, "wrong role");
|
|
|
|
is(accTable4.cellRefAt(0,0).firstChild.name, "cell0", "wrong cell");
|
|
is(accTable4.cellRefAt(0,1).firstChild.name, "cell1", "wrong cell");
|
|
is(accTable4.cellRefAt(1,0).firstChild.name, "cell2", "wrong cell");
|
|
is(accTable4.cellRefAt(1,1).firstChild.name, "cell3", "wrong cell");
|
|
}
|
|
|
|
// Test table with display:inline and an outside table. We shouldn't be fooled
|
|
// by the outside table and shouldn't create table accessible and table cell
|
|
// accessible in this case
|
|
var table5 = document.getElementById("table5");
|
|
accNotCreated = false;
|
|
try {
|
|
var accTable1 = accService.getAccessibleFor(table1);
|
|
} catch (e) {
|
|
accNotCreated = true;
|
|
}
|
|
ok(accNotCreated, "wrongly created table accessible");
|
|
var t5Cell = document.getElementById("t5_cell");
|
|
accNotCreated = false;
|
|
try {
|
|
var accCell = accService.getAccessibleFor(t5Cell);
|
|
} catch (e) {
|
|
accNotCreated = true;
|
|
}
|
|
ok(accNotCreated, "wrongly created table cell accessible");
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(doTest);
|
|
</script>
|
|
</head>
|
|
|
|
<body >
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=419811">Mozilla Bug 419811</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>
|
|
<div id="div">
|
|
<table id="table1" border="1" style="display:inline">
|
|
<tr>
|
|
<td>cell</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<table><tr><td>
|
|
<table id="table2" border="1" style="display:inline">
|
|
<tr>
|
|
<td id="cell">cell</td>
|
|
</tr>
|
|
</table>
|
|
</td></tr></table>
|
|
|
|
<table id="table3" border="1" role="alert">
|
|
<tr>
|
|
<td>cell0</td>
|
|
<td>cell1</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<table id="table4" border="1" role="log">
|
|
<tr aria-live="polite" id="tr">
|
|
<td>cell0</td>
|
|
<td>cell1</td>
|
|
</tr>
|
|
<tr>
|
|
<td>cell2</td>
|
|
<td>cell3</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<table>
|
|
<tr>
|
|
<td style="display:block">
|
|
<table style="display:inline" id="table5">
|
|
<tr><td id="t5_cell">cell0</td></tr>
|
|
</table>
|
|
</td>
|
|
<td>cell1</td>
|
|
</tr>
|
|
</table>
|
|
|
|
</center>
|
|
</body>
|
|
</html>
|