Bug 469818 - Refactor test_textboxes.* files, r=surkov

This commit is contained in:
Marco Zehe 2009-01-06 15:04:28 +01:00
parent c9f82e3f86
commit 49b5bfd706
5 changed files with 95 additions and 112 deletions

View File

@ -43,10 +43,12 @@ const ROLE_COMBOBOX = nsIAccessibleRole.ROLE_COMBOBOX;
const ROLE_COMBOBOX_LIST = nsIAccessibleRole.ROLE_COMBOBOX_LIST;
const ROLE_COMBOBOX_OPTION = nsIAccessibleRole.ROLE_COMBOBOX_OPTION;
const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT;
const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY;
const ROLE_FLAT_EQUATION = nsIAccessibleRole.ROLE_FLAT_EQUATION;
const ROLE_LABEL = nsIAccessibleRole.ROLE_LABEL;
const ROLE_LIST = nsIAccessibleRole.ROLE_LIST;
const ROLE_OPTION = nsIAccessibleRole.ROLE_OPTION;
const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF;
////////////////////////////////////////////////////////////////////////////////
@ -65,6 +67,11 @@ const STATE_SELECTED = nsIAccessibleStates.STATE_SELECTED;
const EXT_STATE_EDITABLE = nsIAccessibleStates.EXT_STATE_EDITABLE;
const EXT_STATE_EXPANDABLE = nsIAccessibleStates.EXT_STATE_EXPANDABLE;
const EXT_STATE_INVALID = nsIAccessibleStates.STATE_INVALID;
const EXT_STATE_MULTI_LINE = nsIAccessibleStates.EXT_STATE_MULTI_LINE;
const EXT_STATE_REQUIRED = nsIAccessibleStates.STATE_REQUIRED;
const EXT_STATE_SUPPORTS_AUTOCOMPLETION =
nsIAccessibleStates.EXT_STATE_SUPPORTS_AUTOCOMPLETION;
////////////////////////////////////////////////////////////////////////////////
// Accessible general

View File

@ -1,4 +1,5 @@
function testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState)
function testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState,
aAbsentExtraState)
{
var [state, extraState] = getStates(aAccOrElmOrID);
@ -13,6 +14,10 @@ function testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState)
is(state & aAbsentState, 0,
"state bits should not be present in ID " + aAccOrElmOrID + "!");
if (aAbsentExtraState)
is(extraState & aAbsentExtraState, 0,
"extraState bits should not be present in ID " + aAccOrElmOrID + "!");
if (state & STATE_READONLY)
is(extraState & EXT_STATE_EDITABLE, 0,
"Read-only " + aAccOrElmOrID + " cannot be editable!");

View File

@ -1,20 +1,6 @@
// Mapping needed state flags for easier handling.
const state_focusable = nsIAccessibleStates.STATE_FOCUSABLE;
const state_focused = nsIAccessibleStates.STATE_FOCUSED;
const state_readonly = nsIAccessibleStates.STATE_READONLY;
const ext_state_multi_line = nsIAccessibleStates.EXT_STATE_MULTI_LINE;
const ext_state_editable = nsIAccessibleStates.EXT_STATE_EDITABLE;
const ext_state_required = nsIAccessibleStates.STATE_REQUIRED;
const ext_state_invalid = nsIAccessibleStates.STATE_INVALID;
// Mapping needed final roles
const role_entry = nsIAccessibleRole.ROLE_ENTRY;
const role_password_text = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
function testValue(aID, aAcc, aValue, aRole)
{
if (aRole == role_password_text) {
if (aRole == ROLE_PASSWORD_TEXT) {
var value;
try {
value = aAcc.value;
@ -27,22 +13,6 @@ function testValue(aID, aAcc, aValue, aRole)
is(aAcc.value, aValue, "Wrong value for " + aID + "!");
}
function testStates(aID, aAcc, aState, aExtraState, aAbsentState)
{
var state = {}, extraState = {};
aAcc.getState(state, extraState);
is(state.value & aState, aState, "wrong state bits for " + aID + "!");
is(extraState.value & aExtraState, aExtraState,
"wrong extraState bits for " + aID + "!");
if (aAbsentState != 0)
is(state.value & aAbsentState, 0, "state bits should not be present in ID "
+ aID + "!");
if (state.value & state_readonly)
// if state is readonly, ext state must not be ext_state_editable.
is(extraState.value & ext_state_editable, 0,
"Read-only " + aID + " cannot be editable!");
}
function testAction(aID, aAcc, aNumActions, aActionName, aActionDescription)
{
var numActions = aAcc.numActions;
@ -61,21 +31,16 @@ function testThis(aID, aName, aValue, aDescription, aRole, aState,
aExtraState, aAbsentState, aNumActions, aActionName,
aActionDescription)
{
var elem = document.getElementById(aID);
var acc = null;
try {
acc = gAccRetrieval.getAccessibleFor(elem);
} catch(e) {}
ok(acc, "No accessible for " + aID + "!");
var acc = getAccessible(aID);
if (!acc)
return;
if (acc) {
is(acc.name, aName, "Wrong name for " + aID + "!");
testValue(aID, acc, aValue, aRole);
is(acc.description, aDescription, "Wrong description for " + aID + "!");
is(acc.role, aRole, "Wrong role for " + aID + "!");
is(acc.name, aName, "Wrong name for " + aID + "!");
testValue(aID, acc, aValue, aRole);
is(acc.description, aDescription, "Wrong description for " + aID + "!");
is(acc.role, aRole, "Wrong role for " + aID + "!");
testStates(aID, acc, aState, aExtraState, aAbsentState);
testStates(acc, aState, aExtraState, aAbsentState);
testAction(aID, acc, aNumActions, aActionName, aActionDescription);
}
testAction(aID, acc, aNumActions, aActionName, aActionDescription);
}

View File

@ -14,6 +14,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_states.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/testTextboxes.js"></script>
@ -26,10 +29,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
null, // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -40,10 +43,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
"Second textbox:", // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -54,10 +57,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
"Textbox with predefined value:", // name
"I have some text", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -68,10 +71,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
"Enter some password here:", // name
"", // value
"", // description
role_password_text, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_PASSWORD_TEXT, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -82,10 +85,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
null, // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable | ext_state_multi_line), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -96,10 +99,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
"Labelled textarea:", // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable | ext_state_multi_line), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -110,10 +113,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
"Pre-filled textarea:", // name
" I also have some text.\n ", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable | ext_state_multi_line), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -124,8 +127,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
"The following is a read-only textbox:", // name
"You cannot change me.", // value
"", // description
role_entry, // role
(state_focusable | state_readonly), // state
ROLE_ENTRY, // role
(STATE_FOCUSABLE | STATE_READONLY), // state
(0), // extState
(0), // absentState
1, // numActions
@ -138,9 +141,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
"This textarea is readonly, too:", // name
" You cannot change me, either.\n ", // value
"", // description
role_entry, // role
(state_focusable | state_readonly), // state
(ext_state_multi_line), // extState
ROLE_ENTRY, // role
(STATE_FOCUSABLE | STATE_READONLY), // state
(EXT_STATE_MULTI_LINE), // extState
(0), // absentState
1, // numActions
"activate", // ActionName

View File

@ -13,6 +13,9 @@
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_states.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/testTextboxes.js" />
@ -26,10 +29,10 @@
"", // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -40,10 +43,10 @@
"Second textbox:", // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -54,10 +57,10 @@
"Textbox with predefined value:", // name
"I have some text", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -68,10 +71,10 @@
"Enter some password here:", // name
"", // value
"", // description
role_password_text, // role
(state_focusable), // state
(ext_state_editable), // extState
(state_readonly), // absentState
ROLE_PASSWORD_TEXT, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -82,10 +85,10 @@
"", // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable | ext_state_multi_line), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -96,10 +99,10 @@
"Labelled textarea:", // name
"", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable | ext_state_multi_line), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -110,10 +113,10 @@
"Pre-filled textarea:", // name
"I also have some text.", // value
"", // description
role_entry, // role
(state_focusable), // state
(ext_state_editable | ext_state_multi_line), // extState
(state_readonly), // absentState
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
@ -124,8 +127,8 @@
"The following is a read-only textbox:", // name
"You cannot change me.", // value
"", // description
role_entry, // role
(state_focusable | state_readonly), // state
ROLE_ENTRY, // role
(STATE_FOCUSABLE | STATE_READONLY), // state
(0), // extState
(0), // absentState
1, // numActions
@ -138,9 +141,9 @@
"This textarea is readonly, too:", // name
"You cannot change me, either.", // value
"", // description
role_entry, // role
(state_focusable | state_readonly), // state
(ext_state_multi_line), // extState
ROLE_ENTRY, // role
(STATE_FOCUSABLE | STATE_READONLY), // state
(EXT_STATE_MULTI_LINE), // extState
(0), // absentState
1, // numActions
"activate", // ActionName