accessible/tests/mochitest/test_nsIAccessibleTable_2.html
author Jason Evans <jasone@canonware.com>
Fri, 20 Jun 2008 10:29:43 -0700
changeset 15456 38972d94e6312cca26dc09bb1d8ac4a9bec84b1c
parent 12645 dd9876675fbd553875b744c8f01370ce4a480414
permissions -rw-r--r--
Bug 431743: Upstream jemalloc fixes, r=benjamin Incorporate upstream jemalloc fixes from FreeBSD: * Detect overflow for huge allocations via sbrk(2). * Fix deadlock for base (internal) allocations in OOM case. * Fix bitmap vector initialization for small allocation runs.

<!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 accService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
                   getService(Components.interfaces.nsIAccessibleRetrieval);

  // bug 410052
  var table = document.getElementById("table");
  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");

  // bug 417912
  var table2 = document.getElementById("table2");
  var accTable2 = accService.getAccessibleFor(table2).
                  QueryInterface(Components.interfaces.nsIAccessibleTable);
  testCellAt(accTable2, 0, 0, true);
  testCellAt(accTable2, 0, 1, true);
  testCellAt(accTable2, 0, 2, true);
  testCellAt(accTable2, 1, 0, true);
  testCellAt(accTable2, 1, 1, false);
  testCellAt(accTable2, 1, 2, true);
  testCellAt(accTable2, 2, 0, true);
  testCellAt(accTable2, 2, 1, true);
  testCellAt(accTable2, 2, 2, true);

  SimpleTest.finish();
}

function testCellAt(aTable, aRow, aColumn, aSucceeded)
{
  try {
    aTable.cellRefAt(aRow, aColumn);
    ok(aSucceeded, "cell is available at (" + aRow + ", " + aColumn + ").");
  } catch (e) {
    ok(!aSucceeded, "cell is not available at (" + aRow + ", " + aColumn + ").");
  }
}

SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
  </script>
 </head>
 <body>
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
  <br>
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417912"
                     title="GetCellDataAt callers that expect an error if no cell is found are wrong">
    Mozilla Bug 417912
  </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>

  <br><br><b>Testing Table 2:</b><br><br>
  <center>
    <table cellpadding="2" cellspacing="2" border="1" width="50%" id="table2">
      <tr><td>1</td><td>2</td><td rowspan=3>3</td>
      <tr><td>4</td>
      <tr><td>5</td><td>6</td>
    </table>
  </center>
 </body>
</html>