gecko/accessible/tests/mochitest/test_nsIAccessible_selects.html

209 lines
6.8 KiB
HTML
Raw Normal View History

<html>
<head>
<title>nsIAccessible selects tests</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="common.js"></script>
<script type="application/javascript"
src="role.js"></script>
<script type="application/javascript"
src="states.js"></script>
<script type="application/javascript"
src="nsIAccessible_selects.js"></script>
<script type="application/javascript">
function doTest()
{
// Label and combo, separate tags
var names = [
"Foo:", // combobox
"Foo:", // combobox list
"item 1", // first item
"item 2" // second item
];
var roles = [
ROLE_COMBOBOX, // root
ROLE_COMBOBOX_LIST, // list accessible
ROLE_COMBOBOX_OPTION, // first option
ROLE_COMBOBOX_OPTION // second option
];
var states = [
(STATE_FOCUSABLE | STATE_HASPOPUP | STATE_COLLAPSED), // combobox
(0), // combobox_list
(STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE | STATE_FOCUSED),
(STATE_SELECTABLE | STATE_FOCUSABLE) // second item, not focused
];
var undesiredStates = [
(STATE_FOCUSED), // combobox
(STATE_FOCUSED), // combobox_list
(0), // first item
(STATE_SELECTED | STATE_FOCUSED) // second, not currently focused, item
];
testSelect("combo1", names, roles, states, undesiredStates);
// Select nested within label element.
names = [
"Search in: Newsticker", // label
"Search in:", // text leaf
"Search in:", // combobox
"Search in: Newsticker", // combobox_list
"Newsticker", // option 1
"Entire site" // Option 2
];
roles = [
ROLE_LABEL, // root
ROLE_TEXT_LEAF, // inner text
ROLE_COMBOBOX, // combobox accessible
ROLE_COMBOBOX_LIST, // list accessible
ROLE_COMBOBOX_OPTION, // first option
ROLE_COMBOBOX_OPTION // second option
];
states = [
(0), // label
(0), // text leaf
(STATE_FOCUSABLE | STATE_HASPOPUP | STATE_COLLAPSED), // combobox
(0), // combobox_list
(STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE | STATE_FOCUSED),
(STATE_SELECTABLE | STATE_FOCUSABLE) // second item, not focused
];
undesiredStates = [
(0), // label
(0), // text leaf
(STATE_FOCUSED), // combobox
(STATE_FOCUSED), // combobox_list
(0), // first item
(STATE_SELECTED | STATE_FOCUSED) // second, not currently focused, item
];
testSelect("combo2", names, roles, states, undesiredStates);
// select @size with label as separate tags.
names = [
"Component:", // list
"Build", // item 1
"Disability Access APIs", // item 2
"General", // item 3
"UI" // item 4
];
roles = [
ROLE_LISTBOX, // root
ROLE_OPTION, // item 1
ROLE_OPTION, // item 2
ROLE_OPTION, // item 4
ROLE_OPTION // item 4
];
states = [
(STATE_FOCUSABLE), // list
(STATE_SELECTABLE | STATE_FOCUSABLE | STATE_FOCUSED),
(STATE_SELECTABLE | STATE_FOCUSABLE), // second item, not focused
(STATE_SELECTABLE | STATE_FOCUSABLE), // third item, not focused
(STATE_SELECTABLE | STATE_FOCUSABLE) // fourth item, not focused
];
undesiredStates = [
(STATE_FOCUSED), // listbox
(STATE_SELECTED), // first item
(STATE_SELECTED | STATE_FOCUSED), // second, not currently focused, item
(STATE_SELECTED | STATE_FOCUSED), // third, not currently focused, item
(STATE_SELECTED | STATE_FOCUSED) // fourth, not currently focused, item
];
testSelect("list1", names, roles, states, undesiredStates);
// Select @size nested within label element.
names = [
"Version:", // label
"Version:", // text leaf
"Version:", // list
"2.0", // option 1
"3.0", // Option 2
"3.1", // Option 3
"trunk" // Option 4
];
roles = [
ROLE_LABEL, // root
ROLE_TEXT_LEAF, // inner text
ROLE_LISTBOX, // listbox accessible
ROLE_OPTION, // first option
ROLE_OPTION, // second option
ROLE_OPTION, // third option
ROLE_OPTION // fourth option
];
states = [
(0), // label
(0), // text leaf
(STATE_FOCUSABLE), // listbox
(STATE_SELECTABLE | STATE_FOCUSABLE | STATE_FOCUSED), // Option 1
(STATE_SELECTABLE | STATE_FOCUSABLE), // second item, not focused
(STATE_SELECTABLE | STATE_FOCUSABLE), // third item, not focused
(STATE_SELECTABLE | STATE_FOCUSABLE) // fourth item, not focused
];
undesiredStates = [
(0), // label
(0), // text leaf
(STATE_FOCUSED | STATE_HASPOPUP | STATE_COLLAPSED), // listbox
(STATE_SELECTED), // first item
(STATE_SELECTED | STATE_FOCUSED), // second, not currently focused, item
(STATE_SELECTED | STATE_FOCUSED), // third, not currently focused, item
(STATE_SELECTED | STATE_FOCUSED) // fourth, not currently focused, item
];
testSelect("list2", names, roles, states, undesiredStates);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=443889"
title="mochitest for selects and lists">
Mozilla Bug 443889
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<form action="post.php" method="post">
<!-- Label and select separate tags -->
<label for="combo1">Foo:</label>
<select id="combo1" name="combo1">
<option>item 1</option>
<option>item 2</option>
</select><br />
<!-- Select embedded in label -->
<label id="combo2">Search in:<select name="search">
<option>Newsticker</option>
<option>Entire site</option>
</select></label><br />
<!-- Label and select @size -->
<label for="list1">Component:</label>
<select id="list1" name="component" size="3">
<option>Build</option>
<option>Disability Access APIs</option>
<option>General</option>
<option>UI</option>
</select><br />
<!-- Select @size nested within label -->
<label id="list2">Version:<select name="version" size="3">
<option>2.0</option>
<option>3.0</option>
<option>3.1</option>
<option>trunk</option>
</select></label><br />
</form>
</body>
</html>