/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Test tables for both local and remote Accessibles. There is more extensive
* coverage in ../../mochitest/table. These tests are primarily to ensure that
* the cache works as expected and that there is consistency between local and
* remote.
*/
"use strict";
/* import-globals-from ../../mochitest/table.js */
/* import-globals-from ../../mochitest/attributes.js */
loadScripts(
{ name: "table.js", dir: MOCHITESTS_DIR },
{ name: "attributes.js", dir: MOCHITESTS_DIR }
);
/**
* Test table counts, indexes, extents and implicit headers.
*/
addAccessibleTask(
`
`,
async function (browser, docAcc) {
const table = findAccessibleChildByID(docAcc, "table", [
nsIAccessibleTable,
]);
is(table.rowCount, 1, "table rowCount correct");
is(table.columnCount, 1, "table columnCount correct");
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
/**
* Test a broken ARIA table with an invalid cell.
*/
addAccessibleTask(
`
a
`,
async function (browser, docAcc) {
const table = findAccessibleChildByID(docAcc, "table", [
nsIAccessibleTable,
]);
is(table.rowCount, 0, "table rowCount correct");
is(table.columnCount, 0, "table columnCount correct");
const cell = findAccessibleChildByID(docAcc, "cell");
let queryOk = false;
try {
cell.QueryInterface(nsIAccessibleTableCell);
queryOk = true;
} catch (e) {}
ok(!queryOk, "Got nsIAccessibleTableCell on an invalid cell");
},
{
chrome: true,
topLevel: true,
iframe: true,
remoteIframe: true,
}
);
/**
* Test that building the cache for a malformed table with an iframe inside a
* row doesn't crash (bug 1800780).
*/
addAccessibleTask(
`
`,
async function (browser, docAcc) {
let reordered = waitForEvent(EVENT_REORDER, "tr");
await invokeContentTask(browser, [], () => {
const iframe = content.document.createElement("iframe");
content.document.getElementById("tr").append(iframe);
});
await reordered;
},
{ topLevel: true }
);
/**
* Verify that table row and column information is correct when there are
* intervening generics between the table and a rowgroup.
*/
addAccessibleTask(
`
a
b
`,
async function (browser, docAcc) {
const table = findAccessibleChildByID(docAcc, "table", [
nsIAccessibleTable,
]);
info("Verifying that the table row and column counts are correct.");
is(table.rowCount, 2, "table rowCount correct");
is(table.columnCount, 1, "table columnCount correct");
info("Verifying that the cell row and column extents are correct.");
const cell = findAccessibleChildByID(docAcc, "cell", [
nsIAccessibleTableCell,
]);
is(cell.rowExtent, 1, "cell rowExtent correct");
is(cell.columnExtent, 1, "cell colExtent correct");
is(cell.rowIndex, 1, "cell rowIndex correct");
is(cell.columnIndex, 0, "cell columnIndex correct");
},
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
);
/**
* Verify that table row and column information is correct when there are
* intervening generics between rows and cells.
*/
addAccessibleTask(
`
a
b
`,
async function (browser, docAcc) {
const table = findAccessibleChildByID(docAcc, "table", [
nsIAccessibleTable,
]);
info("Verifying that the table row and column counts are correct.");
is(table.rowCount, 2, "table rowCount correct");
is(table.columnCount, 1, "table columnCount correct");
info("Verifying that the cell row and column extents are correct.");
const cell = findAccessibleChildByID(docAcc, "cell", [
nsIAccessibleTableCell,
]);
is(cell.rowExtent, 1, "cell rowExtent correct");
is(cell.columnExtent, 1, "cell colExtent correct");
is(cell.rowIndex, 1, "cell rowIndex correct");
is(cell.columnIndex, 0, "cell columnIndex correct");
},
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
);
/**
* Verify that we don't crash for authoring error like