2009-03-07 11:23:25 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Role constants
|
|
|
|
|
|
|
|
const ROLE_ALERT = nsIAccessibleRole.ROLE_ALERT;
|
2010-01-13 02:18:24 +00:00
|
|
|
const ROLE_ANIMATION = nsIAccessibleRole.ROLE_ANIMATION;
|
2009-06-11 18:18:24 +00:00
|
|
|
const ROLE_APPLICATION = nsIAccessibleRole.ROLE_APPLICATION;
|
2009-07-28 02:28:06 +00:00
|
|
|
const ROLE_APP_ROOT = nsIAccessibleRole.ROLE_APP_ROOT;
|
2009-11-10 05:58:52 +00:00
|
|
|
const ROLE_AUTOCOMPLETE = nsIAccessibleRole.ROLE_AUTOCOMPLETE;
|
|
|
|
const ROLE_BUTTONDROPDOWNGRID = nsIAccessibleRole.ROLE_BUTTONDROPDOWNGRID;
|
2011-11-25 16:58:34 +00:00
|
|
|
const ROLE_CANVAS = nsIAccessibleRole.ROLE_CANVAS;
|
2009-09-11 01:07:56 +00:00
|
|
|
const ROLE_CAPTION = nsIAccessibleRole.ROLE_CAPTION;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_CELL = nsIAccessibleRole.ROLE_CELL;
|
2009-12-10 19:12:19 +00:00
|
|
|
const ROLE_CHECKBUTTON = nsIAccessibleRole.ROLE_CHECKBUTTON;
|
2012-06-10 23:44:50 +00:00
|
|
|
const ROLE_CHECK_MENU_ITEM = nsIAccessibleRole.ROLE_CHECK_MENU_ITEM;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_CHROME_WINDOW = nsIAccessibleRole.ROLE_CHROME_WINDOW;
|
|
|
|
const ROLE_COMBOBOX = nsIAccessibleRole.ROLE_COMBOBOX;
|
|
|
|
const ROLE_COMBOBOX_LIST = nsIAccessibleRole.ROLE_COMBOBOX_LIST;
|
|
|
|
const ROLE_COMBOBOX_OPTION = nsIAccessibleRole.ROLE_COMBOBOX_OPTION;
|
2009-05-07 05:59:49 +00:00
|
|
|
const ROLE_COLUMNHEADER = nsIAccessibleRole.ROLE_COLUMNHEADER;
|
2012-04-24 18:35:23 +00:00
|
|
|
const ROLE_DEFINITION = nsIAccessibleRole.ROLE_DEFINITION;
|
|
|
|
const ROLE_DEFINITION_LIST = nsIAccessibleRole.ROLE_DEFINITION_LIST;
|
2013-01-04 04:26:00 +00:00
|
|
|
const ROLE_DIAGRAM = nsIAccessibleRole.ROLE_DIAGRAM;
|
2010-10-21 04:16:10 +00:00
|
|
|
const ROLE_DIALOG = nsIAccessibleRole.ROLE_DIALOG;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT;
|
2009-10-15 03:53:08 +00:00
|
|
|
const ROLE_EMBEDDED_OBJECT = nsIAccessibleRole.ROLE_EMBEDDED_OBJECT;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY;
|
2013-08-19 22:50:14 +00:00
|
|
|
const ROLE_EQUATION = nsIAccessibleRole.ROLE_EQUATION;
|
2011-12-05 06:04:06 +00:00
|
|
|
const ROLE_FIGURE = nsIAccessibleRole.ROLE_FIGURE;
|
2010-11-08 13:33:34 +00:00
|
|
|
const ROLE_FOOTER = nsIAccessibleRole.ROLE_FOOTER;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_FLAT_EQUATION = nsIAccessibleRole.ROLE_FLAT_EQUATION;
|
|
|
|
const ROLE_FORM = nsIAccessibleRole.ROLE_FORM;
|
|
|
|
const ROLE_GRAPHIC = nsIAccessibleRole.ROLE_GRAPHIC;
|
|
|
|
const ROLE_GRID_CELL = nsIAccessibleRole.ROLE_GRID_CELL;
|
|
|
|
const ROLE_GROUPING = nsIAccessibleRole.ROLE_GROUPING;
|
2010-11-08 13:33:34 +00:00
|
|
|
const ROLE_HEADER = nsIAccessibleRole.ROLE_HEADER;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_HEADING = nsIAccessibleRole.ROLE_HEADING;
|
|
|
|
const ROLE_IMAGE_MAP = nsIAccessibleRole.ROLE_IMAGE_MAP;
|
|
|
|
const ROLE_INTERNAL_FRAME = nsIAccessibleRole.ROLE_INTERNAL_FRAME;
|
|
|
|
const ROLE_LABEL = nsIAccessibleRole.ROLE_LABEL;
|
|
|
|
const ROLE_LINK = nsIAccessibleRole.ROLE_LINK;
|
|
|
|
const ROLE_LIST = nsIAccessibleRole.ROLE_LIST;
|
|
|
|
const ROLE_LISTBOX = nsIAccessibleRole.ROLE_LISTBOX;
|
2009-08-20 06:45:19 +00:00
|
|
|
const ROLE_LISTITEM = nsIAccessibleRole.ROLE_LISTITEM;
|
2012-06-10 23:44:50 +00:00
|
|
|
const ROLE_MENUBAR = nsIAccessibleRole.ROLE_MENUBAR;
|
2009-11-10 05:58:52 +00:00
|
|
|
const ROLE_MENUITEM = nsIAccessibleRole.ROLE_MENUITEM;
|
|
|
|
const ROLE_MENUPOPUP = nsIAccessibleRole.ROLE_MENUPOPUP;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_NOTHING = nsIAccessibleRole.ROLE_NOTHING;
|
2010-11-15 18:30:44 +00:00
|
|
|
const ROLE_NOTE = nsIAccessibleRole.ROLE_NOTE;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_OPTION = nsIAccessibleRole.ROLE_OPTION;
|
2009-08-20 06:45:19 +00:00
|
|
|
const ROLE_OUTLINE = nsIAccessibleRole.ROLE_OUTLINE;
|
|
|
|
const ROLE_OUTLINEITEM = nsIAccessibleRole.ROLE_OUTLINEITEM;
|
2010-01-19 04:35:08 +00:00
|
|
|
const ROLE_PAGETAB = nsIAccessibleRole.ROLE_PAGETAB;
|
|
|
|
const ROLE_PAGETABLIST = nsIAccessibleRole.ROLE_PAGETABLIST;
|
|
|
|
const ROLE_PANE = nsIAccessibleRole.ROLE_PANE;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_PARAGRAPH = nsIAccessibleRole.ROLE_PARAGRAPH;
|
2009-11-10 05:58:52 +00:00
|
|
|
const ROLE_PARENT_MENUITEM = nsIAccessibleRole.ROLE_PARENT_MENUITEM;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
|
2009-04-20 07:09:21 +00:00
|
|
|
const ROLE_PROGRESSBAR = nsIAccessibleRole.ROLE_PROGRESSBAR;
|
2010-01-19 04:35:08 +00:00
|
|
|
const ROLE_PROPERTYPAGE = nsIAccessibleRole.ROLE_PROPERTYPAGE;
|
2009-04-20 07:09:21 +00:00
|
|
|
const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON;
|
2009-12-10 19:12:19 +00:00
|
|
|
const ROLE_RADIOBUTTON = nsIAccessibleRole.ROLE_RADIOBUTTON;
|
2012-06-10 23:44:50 +00:00
|
|
|
const ROLE_RADIO_MENU_ITEM = nsIAccessibleRole.ROLE_RADIO_MENU_ITEM;
|
2012-03-27 07:29:51 +00:00
|
|
|
const ROLE_RICH_OPTION = nsIAccessibleRole.ROLE_RICH_OPTION;
|
2009-05-07 05:59:49 +00:00
|
|
|
const ROLE_ROW = nsIAccessibleRole.ROLE_ROW;
|
2009-09-11 01:07:56 +00:00
|
|
|
const ROLE_ROWHEADER = nsIAccessibleRole.ROLE_ROWHEADER;
|
2009-12-15 16:03:39 +00:00
|
|
|
const ROLE_SCROLLBAR = nsIAccessibleRole.ROLE_SCROLLBAR;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_SECTION = nsIAccessibleRole.ROLE_SECTION;
|
2009-12-10 19:12:19 +00:00
|
|
|
const ROLE_SEPARATOR = nsIAccessibleRole.ROLE_SEPARATOR;
|
2009-04-20 07:09:21 +00:00
|
|
|
const ROLE_SLIDER = nsIAccessibleRole.ROLE_SLIDER;
|
2012-06-10 23:44:50 +00:00
|
|
|
const ROLE_SPINBUTTON = nsIAccessibleRole.ROLE_SPINBUTTON;
|
2009-09-19 06:30:07 +00:00
|
|
|
const ROLE_STATICTEXT = nsIAccessibleRole.ROLE_STATICTEXT;
|
2012-06-10 23:44:50 +00:00
|
|
|
const ROLE_STATUSBAR = nsIAccessibleRole.ROLE_STATUSBAR;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE;
|
2012-04-24 18:35:23 +00:00
|
|
|
const ROLE_TERM = nsIAccessibleRole.ROLE_TERM;
|
2009-03-07 11:23:25 +00:00
|
|
|
const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER;
|
|
|
|
const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF;
|
|
|
|
const ROLE_TOGGLE_BUTTON = nsIAccessibleRole.ROLE_TOGGLE_BUTTON;
|
2010-05-12 07:29:51 +00:00
|
|
|
const ROLE_TOOLBAR = nsIAccessibleRole.ROLE_TOOLBAR;
|
2010-01-19 04:35:08 +00:00
|
|
|
const ROLE_TOOLTIP = nsIAccessibleRole.ROLE_TOOLTIP;
|
2009-08-20 06:45:19 +00:00
|
|
|
const ROLE_TREE_TABLE = nsIAccessibleRole.ROLE_TREE_TABLE;
|
2009-12-10 19:12:19 +00:00
|
|
|
const ROLE_WHITESPACE = nsIAccessibleRole.ROLE_WHITESPACE;
|
2009-03-07 11:23:25 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Public methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that the role of the given accessible is the role passed in.
|
|
|
|
*
|
|
|
|
* @param aAccOrElmOrID the accessible, DOM element or ID to be tested.
|
|
|
|
* @param aRole The role that is to be expected.
|
|
|
|
*/
|
|
|
|
function testRole(aAccOrElmOrID, aRole)
|
|
|
|
{
|
|
|
|
var role = getRole(aAccOrElmOrID);
|
|
|
|
is(role, aRole, "Wrong role for " + prettyName(aAccOrElmOrID) + "!");
|
|
|
|
}
|
|
|
|
|
2009-03-03 10:42:00 +00:00
|
|
|
/**
|
|
|
|
* Return the role of the given accessible. Return -1 if accessible could not
|
|
|
|
* be retrieved.
|
|
|
|
*
|
|
|
|
* @param aAccOrElmOrID [in] The accessible, DOM element or element ID the
|
|
|
|
* accessible role is being requested for.
|
|
|
|
*/
|
|
|
|
function getRole(aAccOrElmOrID)
|
2009-01-20 15:02:35 +00:00
|
|
|
{
|
2009-03-03 10:42:00 +00:00
|
|
|
var acc = getAccessible(aAccOrElmOrID);
|
2009-01-20 15:02:35 +00:00
|
|
|
if (!acc)
|
2009-03-03 10:42:00 +00:00
|
|
|
return -1;
|
2009-01-20 15:02:35 +00:00
|
|
|
|
2009-03-03 10:42:00 +00:00
|
|
|
var role = -1;
|
2009-01-20 15:02:35 +00:00
|
|
|
try {
|
2009-03-07 15:38:58 +00:00
|
|
|
role = acc.role;
|
2009-01-20 15:02:35 +00:00
|
|
|
} catch(e) {
|
2009-03-03 10:42:00 +00:00
|
|
|
ok(false, "Role for " + aAccOrElmOrID + " could not be retrieved!");
|
2009-01-20 15:02:35 +00:00
|
|
|
}
|
2009-03-03 10:42:00 +00:00
|
|
|
|
|
|
|
return role;
|
|
|
|
}
|
2010-10-21 04:16:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Analogy of SimpleTest.is function used to check the role.
|
|
|
|
*/
|
|
|
|
function isRole(aIdentifier, aRole, aMsg)
|
|
|
|
{
|
|
|
|
var role = getRole(aIdentifier);
|
|
|
|
if (role == - 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (role == aRole) {
|
|
|
|
ok(true, aMsg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var got = roleToString(role);
|
|
|
|
var expected = roleToString(aRole);
|
|
|
|
|
|
|
|
ok(false, aMsg + "got '" + got + "', expected '" + expected + "'");
|
|
|
|
}
|