gecko/accessible/tests/mochitest/states/test_aria.html
Mark Capella b9ad942064 Bug 760756 - de-ns-ify nsHTMLLinkAccessible, r=surkov
--HG--
rename : accessible/src/html/nsHTMLLinkAccessible.cpp => accessible/src/html/HTMLLinkAccessible.cpp
rename : accessible/src/html/nsHTMLLinkAccessible.h => accessible/src/html/HTMLLinkAccessible.h
2012-06-04 08:32:38 -04:00

334 lines
13 KiB
HTML

<html>
<head>
<title>ARIA based 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/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">
function testAriaDisabledTree(aAccOrElmOrID)
{
// test accessible and its subtree for propagated state.
var acc = getAccessible(aAccOrElmOrID);
if (!acc)
return;
var [state, extraState] = getStates(aAccOrElmOrID);
if (state & STATE_UNAVAILABLE) {
var role = getRole(acc);
if (role != ROLE_GROUPING) {
testStates(acc, STATE_FOCUSABLE);
}
}
// Iterate over its children to see if the state got propagated.
var children = null;
try {
children = acc.children;
} catch(e) {}
ok(children, "Could not get children for " + aAccOrElmOrID +"!");
if (children) {
for (var i = 0; i < children.length; i++) {
var childAcc = children.queryElementAt(i, nsIAccessible);
testAriaDisabledTree(childAcc);
}
}
}
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);
testStates("htmltext_autocomplete_list", STATE_HASPOPUP, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
testStates("htmltextarea_autocomplete_list", 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.
testAriaDisabledTree("group");
// aria-multiline
testStates("aria_multiline_textbox", 0, EXT_STATE_MULTI_LINE);
// aria-multiselectable
testStates("aria_multiselectable_listbox",
STATE_MULTISELECTABLE | STATE_EXTSELECTABLE);
// aria-pressed
testStates("aria_pressed_button", STATE_PRESSED | STATE_CHECKABLE);
// aria-readonly
testStates("aria_readonly_textbox", STATE_READONLY);
// aria-selectable
testStates("aria_selectable_listitem", STATE_SELECTABLE | STATE_SELECTED);
// active state caused by aria-activedescendant
testStates("as_item1", 0, EXT_STATE_ACTIVE);
testStates("as_item2", 0, 0, 0, EXT_STATE_ACTIVE);
// universal ARIA properties inherited from file input control
var fileTextField = getAccessible("fileinput").firstChild;
testStates(fileTextField,
STATE_BUSY | STATE_UNAVAILABLE | STATE_REQUIRED | STATE_HASPOPUP | STATE_INVALID);
var fileBrowseButton = getAccessible("fileinput").lastChild;
testStates(fileBrowseButton,
STATE_BUSY | STATE_UNAVAILABLE | STATE_REQUIRED | STATE_HASPOPUP | STATE_INVALID);
// offscreen test
testStates("aria_offscreen_textbox", STATE_OFFSCREEN);
//
// This section tests aria roles on links/anchors for underlying
// HTMLLinkAccessible creation. (see closed bug 494807)
//
// strong roles
testStates("aria_menuitem_link", 0, 0, STATE_LINKED);
testStates("aria_button_link", 0, 0, STATE_LINKED);
testStates("aria_checkbox_link", 0, 0, STATE_LINKED);
// strong landmark
testStates("aria_application_link", 0, 0, STATE_LINKED);
testStates("aria_application_anchor", 0, 0, STATE_SELECTABLE);
// strange cases
testStates("aria_link_link", STATE_LINKED);
testStates("aria_link_anchor", STATE_SELECTABLE);
// some weak landmarks
testStates("aria_main_link", STATE_LINKED);
testStates("aria_navigation_link", STATE_LINKED);
testStates("aria_main_anchor", STATE_SELECTABLE);
testStates("aria_navigation_anchor", STATE_SELECTABLE);
// aria-orientation (applied to scrollbar, separator, slider)
testStates("aria_scrollbar", 0, EXT_STATE_HORIZONTAL);
testStates("aria_hscrollbar", 0, EXT_STATE_HORIZONTAL);
testStates("aria_vscrollbar", 0, EXT_STATE_VERTICAL);
testStates("aria_separator", 0, EXT_STATE_HORIZONTAL);
testStates("aria_hseparator", 0, EXT_STATE_HORIZONTAL);
testStates("aria_vseparator", 0, EXT_STATE_VERTICAL);
testStates("aria_slider", 0, EXT_STATE_HORIZONTAL);
testStates("aria_hslider", 0, EXT_STATE_HORIZONTAL);
testStates("aria_vslider", 0, EXT_STATE_VERTICAL);
// indeterminate ARIA progressbars (no aria-valuenow or aria-valuetext attribute)
// should expose mixed state
testStates("aria_progressbar", STATE_MIXED);
testStates("aria_progressbar_valuenow", 0, 0, STATE_MIXED);
testStates("aria_progressbar_valuetext", 0, 0, STATE_MIXED);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(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>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=681674"
title="aria-autocomplete not supported on standard form text input controls">
Mozilla Bug 681674
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=681674"
title="aria-orientation should be applied to separator and slider roles">
Mozilla Bug 681674
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=699017"
title="File input control should be propogate states to descendants">
Mozilla Bug 699017
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=689847"
title="Expose active state on current item of selectable widgets">
Mozilla Bug 689847
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=457226"
title="Mochitests for ARIA states">
Mozilla Bug 457226
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=740851"
title="ARIA undetermined progressmeters should expose mixed state">
Mozilla Bug 740851
</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>
<input id="htmltext_autocomplete_list" type="text" aria-autocomplete="list" />
<textarea id="htmltextarea_autocomplete_list" aria-autocomplete="list"></textarea>
<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>
<div id="aria_multiline_textbox" role="textbox" aria-multiline="true"></div>
<div id="aria_multiselectable_listbox" role="listbox" aria-multiselectable="true"></div>
<div id="aria_pressed_button" role="button" aria-pressed="true">Button</div>
<div id="aria_readonly_textbox" role="textbox" aria-readonly="true">This text should be readonly</div>
<div role="listbox">
<div id="aria_selectable_listitem" role="option" aria-selected="true">Item1</div>
</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>
<!-- Test active state -->
<div id="as_listbox" tabindex="0" role="listbox"
aria-activedescendant="as_item1">
<div role="option" id="as_item1">Item 1</div>
<div role="option" id="as_item2">Item 2</div>
</div>
<!-- universal ARIA properties should be inherited by text field of file input -->
<input type="file" id="fileinput"
aria-busy="true"
aria-disabled="true"
aria-required="true"
aria-haspopup="true"
aria-invalid="true">
<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>
<a id="aria_menuitem_link" role="menuitem" href="foo">menuitem</a>
<a id="aria_button_link" role="button" href="foo">button</a>
<a id="aria_checkbox_link" role="checkbox" href="foo">checkbox</a>
<!-- strange edge case: please don't do this in the wild -->
<a id="aria_link_link" role="link" href="foo">link</a>
<a id="aria_link_anchor" role="link" name="link_anchor">link</a>
<!-- landmarks: links -->
<a id="aria_application_link" role="application" href="foo">app</a>
<a id="aria_main_link" role="main" href="foo">main</a>
<a id="aria_navigation_link" role="navigation" href="foo">nav</a>
<!-- landmarks: anchors -->
<a id="aria_application_anchor" role="application" name="app_anchor">app</a>
<a id="aria_main_anchor" role="main" name="main_anchor">main</a>
<a id="aria_navigation_anchor" role="navigation" name="nav_anchor">nav</a>
<!-- aria-orientation -->
<div id="aria_scrollbar" role="scrollbar">scrollbar</div>
<div id="aria_hscrollbar" role="scrollbar" aria-orientation="horizontal">horizontal scrollbar</div>
<div id="aria_vscrollbar" role="scrollbar" aria-orientation="vertical">vertical scrollbar</div>
<div id="aria_separator" role="separator">separator</div>
<div id="aria_hseparator" role="separator" aria-orientation="horizontal">horizontal separator</div>
<div id="aria_vseparator" role="separator" aria-orientation="vertical">vertical separator</div>
<div id="aria_slider" role="slider">slider</div>
<div id="aria_hslider" role="slider" aria-orientation="horizontal">horizontal slider</div>
<div id="aria_vslider" role="slider" aria-orientation="vertical">vertical slider</div>
<!-- indeterminate ARIA progressbars should expose mixed state -->
<div id="aria_progressbar" role="progressbar"></div>
<div id="aria_progressbar_valuenow" role="progressbar" aria-valuenow="1"></div>
<div id="aria_progressbar_valuetext" role="progressbar" aria-valuetext="value"></div>
</body>
</html>