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">
function addOptGroup(aID) {
this.selectNode = getNode(aID);
this.select = getAccessible(this.selectNode);
this.selectList = this.select.firstChild;
this.invoke = function addOptGroup_invoke() {
var optGroup = document.createElement("optgroup");
for (let i = 0; i < 2; i++) {
var opt = document.createElement("option");
opt.value = i;
opt.text = "Option: Value " + i;
optGroup.appendChild(opt);
}
this.selectNode.add(optGroup, null);
var option = document.createElement("option");
this.selectNode.add(option, null);
};
this.eventSeq = [
new invokerChecker(EVENT_REORDER, this.selectList),
];
this.finalCheck = function addOptGroup_finalCheck() {
var tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [
{ GROUPING: [
{ COMBOBOX_OPTION: [ ] },
{ COMBOBOX_OPTION: [ ] },
]},
{ COMBOBOX_OPTION: [] },
] },
] };
testAccessibleTree(this.select, tree);
};
this.getID = function addOptGroup_getID() {
return "test optgroup's insertion into a select";
};
}
function removeOptGroup(aID) {
this.selectNode = getNode(aID);
this.select = getAccessible(this.selectNode);
this.selectList = this.select.firstChild;
this.invoke = function removeOptGroup_invoke() {
this.option1Node = this.selectNode.firstChild.firstChild;
this.selectNode.firstChild.remove();
};
this.eventSeq = [
new invokerChecker(EVENT_REORDER, this.selectList),
];
this.finalCheck = function removeOptGroup_finalCheck() {
var tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [
{ COMBOBOX_OPTION: [] },
] },
] };
testAccessibleTree(this.select, tree);
is(isAccessible(this.option1Node), false, "removed option shouldn't be accessible anymore!");
};
this.getID = function removeOptGroup_getID() {
return "test optgroup's removal from a select";
};
}
// gA11yEventDumpToConsole = true;
function doTest() {
const gQueue = new eventQueue();
gQueue.push(new addOptGroup("select"));
gQueue.push(new removeOptGroup("select"));
gQueue.invoke(); // Will call 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>