<!DOCTYPE HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<table id="table1">
</table>
<script>
function axElementById(id) {
return accessibilityController.accessibleElementById(id);
}
test(function(t) {
// Check beginning row and column count.
var axTable = axElementById("table1");
assert_equals(axTable.rowCount, 0);
assert_equals(axTable.columnCount, 0);
// Insert initial table contents.
document.getElementById('table1').innerHTML = '<tr id="row1"><td>foo</td><td>bar</td></tr>';
assert_equals(axTable.rowCount, 1);
assert_equals(axTable.columnCount, 2);
// Insert a row.
var rowElem1 = document.getElementById('row1');
var newRowElem = document.createElement('tr');
newRowElem.innerHTML = '<td>a</td><td>b</td><td>c</td>';
rowElem1.parentNode.insertBefore(newRowElem, rowElem1);
assert_equals(axTable.rowCount, 2);
assert_equals(axTable.columnCount, 3);
// Insert a cell.
newRowElem.appendChild(document.createElement('td'));
assert_equals(axTable.columnCount, 4);
// Remove the new row.
newRowElem.remove();
assert_equals(axTable.rowCount, 1);
assert_equals(axTable.columnCount, 2);
}, "Row/col count before and after insertion/removal should be correct");
</script>