Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<title>Add and remove optgroup test</title>
<link rel="stylesheet" type="text/css"
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
async function doTest() {
const selectNode = getNode("select");
const select = getAccessible(selectNode);
const selectList = select.firstChild;
let reordered = waitForEvent(EVENT_REORDER, selectList);
const optGroup = document.createElement("optgroup");
for (let i = 0; i < 2; i++) {
const opt = document.createElement("option");
opt.value = i;
opt.text = "Option: Value " + i;
optGroup.appendChild(opt);
}
selectNode.add(optGroup, null);
const option = document.createElement("option");
selectNode.add(option, null);
await reordered;
let tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [
{ GROUPING: [
{ COMBOBOX_OPTION: [] },
{ COMBOBOX_OPTION: [] },
] },
{ COMBOBOX_OPTION: [] },
] },
] };
testAccessibleTree(select, tree);
const option1Node = selectNode.firstChild.firstChild;
reordered = waitForEvent(EVENT_REORDER, selectList);
selectNode.firstChild.remove();
await reordered;
tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [
{ COMBOBOX_OPTION: [] },
] },
] };
testAccessibleTree(select, tree);
is(
isAccessible(option1Node),
false,
"removed option shouldn't be accessible anymore!"
);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="Bug 616452 - Dynamically inserted select options aren't reflected in accessible tree">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<select id="select"></select>
<div id="debug"/>
</body>
</html>