1 const nsIAccessibleRetrieval
= Components
.interfaces
.nsIAccessibleRetrieval
;
3 // Mapping needed state flags for easier handling.
4 const state_focusable
=
5 Components
.interfaces
.nsIAccessibleStates
.STATE_FOCUSABLE
;
7 Components
.interfaces
.nsIAccessibleStates
.STATE_FOCUSED
;
9 Components
.interfaces
.nsIAccessibleStates
.STATE_READONLY
;
11 const ext_state_multi_line
=
12 Components
.interfaces
.nsIAccessibleStates
.EXT_STATE_MULTI_LINE
;
13 const ext_state_editable
=
14 Components
.interfaces
.nsIAccessibleStates
.EXT_STATE_EDITABLE
;
15 const ext_state_required
=
16 Components
.interfaces
.nsIAccessibleStates
.STATE_REQUIRED
;
17 const ext_state_invalid
=
18 Components
.interfaces
.nsIAccessibleStates
.STATE_INVALID
;
20 // Mapping needed final roles
21 const role_entry
= Components
.interfaces
.nsIAccessibleRole
.ROLE_ENTRY
;
22 const role_password_text
=
23 Components
.interfaces
.nsIAccessibleRole
.ROLE_PASSWORD_TEXT
;
25 var gAccRetrieval
= null;
27 function testValue(aID
, aAcc
, aValue
, aRole
)
29 if (aRole
== role_password_text
) {
33 do_throw("We do not want a value on " + aID
+ "!");
35 is(e
.result
, Components
.results
.NS_ERROR_FAILURE
,
36 "Wrong return value for getValue on " + aID
+ "!");
39 is(aAcc
.value
, aValue
, "Wrong value for " + aID
+ "!");
42 function testStates(aID
, aAcc
, aState
, aExtraState
, aAbsentState
)
44 var state
= {}, extraState
= {};
45 aAcc
.getFinalState(state
, extraState
);
46 is(state
.value
& aState
, aState
, "wrong state bits for " + aID
+ "!");
47 is(extraState
.value
& aExtraState
, aExtraState
,
48 "wrong extraState bits for " + aID
+ "!");
49 if (aAbsentState
!= 0)
50 is(state
.value
& aAbsentState
, 0, "state bits should not be present in ID "
52 if (state
.value
& state_readonly
)
53 // if state is readonly, ext state must not be ext_state_editable.
54 is(extraState
.value
& ext_state_editable
, 0,
55 "Read-only " + aID
+ " cannot be editable!");
58 function testAction(aID
, aAcc
, aNumActions
, aActionName
, aActionDescription
)
60 var numActions
= aAcc
.numActions
;
61 is(numActions
, aNumActions
, "Wrong number of actions for " + aID
+ "!");
63 if (numActions
!= 0) {
64 // Test first action. Normally only 1 should be present.
65 is(aAcc
.getActionName(0), aActionName
,
66 "Wrong name of action for " + aID
+ "!");
67 is(aAcc
.getActionDescription(0), aActionDescription
,
68 "Wrong description of action for " + aID
+ "!");
72 function testThis(aID
, aName
, aValue
, aDescription
, aRole
, aState
,
73 aExtraState
, aAbsentState
, aNumActions
, aActionName
,
76 var elem
= document
.getElementById(aID
);
79 acc
= gAccRetrieval
.getAccessibleFor(elem
);
81 ok(acc
, "No accessible for " + aID
+ "!");
84 is(acc
.name
, aName
, "Wrong name for " + aID
+ "!");
85 testValue(aID
, acc
, aValue
, aRole
);
86 is(acc
.description
, aDescription
, "Wrong description for " + aID
+ "!");
87 is(acc
.role
, aRole
, "Wrong role for " + aID
+ "!");
89 testStates(aID
, acc
, aState
, aExtraState
, aAbsentState
);
91 testAction(aID
, acc
, aNumActions
, aActionName
, aActionDescription
);