Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<!DOCTYPE html>
<html>
<head>
<title>HTML select options 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);
for (let i = 0; i < 2; i++) {
const opt = document.createElement("option");
opt.value = i;
opt.text = "Option: Value " + i;
selectNode.add(opt, null);
}
await reordered;
let tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [
{ COMBOBOX_OPTION: [] },
{ COMBOBOX_OPTION: [] },
] },
] };
testAccessibleTree(select, tree);
reordered = waitForEvent(EVENT_REORDER, selectList);
while (selectNode.length) {
selectNode.remove(0);
}
await reordered;
tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [] },
] };
testAccessibleTree(select, tree);
let p = waitForEvents([[EVENT_HIDE, "s2_o"], [EVENT_SHOW, "s2_o"]]);
getNode("s2_o").setAttribute("role", "option");
await p;
tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [
{ COMBOBOX_OPTION: [] },
] },
] };
testAccessibleTree("s2", tree);
p = waitForEvents([[EVENT_HIDE, "s3"], [EVENT_SHOW, "s3"]]);
getNode("s3").multiple = true;
await p;
tree =
{ LISTBOX: [
{ OPTION: [] },
] };
testAccessibleTree("s3", tree);
p = waitForEvents([[EVENT_HIDE, "s4"], [EVENT_SHOW, "s4"]]);
getNode("s4").removeAttribute("size");
await p;
tree =
{ COMBOBOX: [
{ COMBOBOX_LIST: [
{ COMBOBOX_OPTION: [] },
] },
] };
testAccessibleTree("s4", tree);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<select id="select"></select>
<select id="s2"><option id="s2_o"></option></select>
<select id="s3"><option></option></select>
<select id="s4" size="3"><option></option></select>
</body>
</html>