gecko/accessible/tests/mochitest/test_states.html

145 lines
5.1 KiB
HTML

<html>
<head>
<title>nsIAccessible states testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style type="text/css">
.offscreen {
position: absolute;
left: -5000px;
top: -5000px;
height: 100px;
width: 100px;
}
</style>
<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="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
<script type="application/javascript">
function doTest()
{
// aria_autocomplete
testStates("textbox_autocomplete_inline", 0, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
testStates("textbox_autocomplete_list", STATE_HASPOPUP, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
testStates("textbox_autocomplete_both", STATE_HASPOPUP, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
testStates("combobox_autocomplete_inline", STATE_HASPOPUP, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
testStates("combobox_autocomplete_list", STATE_HASPOPUP, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
testStates("combobox_autocomplete_both", STATE_HASPOPUP, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
// aria-busy
testStates("textbox_busy_false", 0, 0, STATE_BUSY);
testStates("textbox_busy_true", STATE_BUSY);
testStates("textbox_busy_error", STATE_INVALID);
// aria-expanded
testStates("combobox", STATE_COLLAPSED);
testStates("combobox_expanded", STATE_EXPANDED);
// tri-state checkbox
var checkboxElem = getNode("check1");
if (checkboxElem) {
testStates(checkboxElem, STATE_CHECKED);
checkboxElem.checked = false;
testStates(checkboxElem, 0, 0, STATE_CHECKED);
checkboxElem.indeterminate = true;
testStates(checkboxElem, STATE_MIXED, 0);
}
// aria-checked
testStates("aria_checked_checkbox", STATE_CHECKED);
testStates("aria_mixed_checkbox", STATE_MIXED);
// test disabled group and all its descendants to see if they are
// disabled, too. See bug 429285.
testStatesInSubtree("group", STATE_UNAVAILABLE);
// offscreen test
testStates("aria_offscreen_textbox", STATE_OFFSCREEN);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=457219"
title="nsIAccessible states testing">
Mozilla Bug 457219
</a><br />
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=429285"
title="Propagate aria-disabled to descendants">
Mozilla Bug 429285
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=499653"
title="Unify ARIA state attributes mapping rules">
Mozilla Bug 499653
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="textbox_autocomplete_inline" role="textbox" aria-autocomplete="inline"></div>
<div id="textbox_autocomplete_list" role="textbox" aria-autocomplete="list"></div>
<div id="textbox_autocomplete_both" role="textbox" aria-autocomplete="both"></div>
<div id="combobox_autocomplete_inline" role="combobox" aria-autocomplete="inline"></div>
<div id="combobox_autocomplete_list" role="combobox" aria-autocomplete="list"></div>
<div id="combobox_autocomplete_both" role="combobox" aria-autocomplete="both"></div>
<div id="textbox_busy_false" role="textbox" aria-busy="false"></div>
<div id="textbox_busy_true" role="textbox" aria-busy="true"></div>
<div id="textbox_busy_error" role="textbox" aria-busy="error"></div>
<div id="combobox" role="combobox">combobox</div>
<div id="combobox_expanded" role="combobox"
aria-expanded="true">combobox</div>
<input type="checkbox" id="check1" value="I agree" checked="true"/>
<div id="aria_checked_checkbox" role="checkbox" aria-checked="true">
I agree
</div>
<div id="aria_mixed_checkbox" role="checkbox" aria-checked="mixed">
I might agree
</div>
<!-- Test that aria-disabled state gets propagated to all descendants -->
<div id="group" role="group" aria-disabled="true">
<button>hi</button>
<div tabindex="0" role="listbox" aria-activedescendant="item1">
<div role="option" id="item1">Item 1</div>
<div role="option" id="item2">Item 2</div>
<div role="option" id="item3">Item 3</div>
<div role="option" id="item4">Item 4</div>
</div>
<div role="slider" tabindex="0">A slider</div>
</div>
<div id="offscreen_log" role="log" class="offscreen">
<div id="aria_offscreen_textbox" role="textbox" aria-readonly="true">This text should be offscreen</div>
</div>
</body>
</html>