blob: 77a4a2870de9121028b2f0314455ca36c4c6240e [file] [log] [blame] [edit]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/accessibility-helper.js"></script>
<script src="../resources/js-test.js"></script>
<style>
td, th {
border: 1px solid black;
}
</style>
</head>
<body>
<table id="table">
<thead id="thead">
<tr id="r0">
<th id="r0c0">Header 0</th>
<th id="r0c1">Header 1</th>
</tr>
</thead>
<tbody id="tbody">
<tr id="r1">
<td id="r1c0">R1C0</td>
<td id="r1c1">R1C1</td>
<td id="r1c2">R1C2</td>
</tr>
<tr id="r2">
<td id="r2c0">R2C0</td>
<td id="r2c1">R2C1</td>
<td id="r2c1">R2C2</td>
</tr>
</tbody>
</table>
<script>
var output = "This test ensures that the 'cell for column and row' API works correctly after dynamic colspan changes.\n\n";
if (window.accessibilityController) {
window.jsTestIsAsync = true;
var table = accessibilityController.accessibleElementById("table");
output += expect("table.cellForColumnAndRow(0, 0).domIdentifier", "'r0c0'");
output += expect("table.cellForColumnAndRow(1, 0).domIdentifier", "'r0c1'");
output += expect("table.cellForColumnAndRow(2, 0) === null", "true");
output += expect("accessibilityController.accessibleElementById('r0c1').columnIndexRange()", "'{1, 1}'");
output += evalAndReturn("document.getElementById('r0c1').setAttribute('colspan', '2')");
setTimeout(async function() {
await waitFor(() => table.cellForColumnAndRow(2, 0) !== null);
output += expect("table.cellForColumnAndRow(2, 0).domIdentifier", "'r0c1'");
output += expect("accessibilityController.accessibleElementById('r0c1').columnIndexRange()", "'{1, 2}'");
output += evalAndReturn("document.getElementById('r0c1').removeAttribute('colspan')");
output += await expectAsync("table.cellForColumnAndRow(2, 0) === null", "true");
output += expect("accessibilityController.accessibleElementById('r0c1').columnIndexRange()", "'{1, 1}'");
output += evalAndReturn("document.getElementById('r0c1').setAttribute('aria-colspan', '2')");
await waitFor(() => table.cellForColumnAndRow(2, 0) !== null);
output += expect("table.cellForColumnAndRow(2, 0).domIdentifier", "'r0c1'");
output += expect("accessibilityController.accessibleElementById('r0c1').columnIndexRange()", "'{1, 2}'");
debug(output);
finishJSTest();
}, 0);
}
</script>
</body>
</html>