diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js index 7a3c56d6543..0915e787c44 100644 --- a/accessible/tests/mochitest/common.js +++ b/accessible/tests/mochitest/common.js @@ -44,39 +44,6 @@ const nsIDOMWindow = Components.interfaces.nsIDOMWindow; const nsIPropertyElement = Components.interfaces.nsIPropertyElement; -//////////////////////////////////////////////////////////////////////////////// -// Roles - -const ROLE_ALERT = nsIAccessibleRole.ROLE_ALERT; -const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON; -const ROLE_CELL = nsIAccessibleRole.ROLE_CELL; -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; -const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT; -const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY; -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; -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; -const ROLE_OPTION = nsIAccessibleRole.ROLE_OPTION; -const ROLE_PARAGRAPH = nsIAccessibleRole.ROLE_PARAGRAPH; -const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT; -const ROLE_SECTION = nsIAccessibleRole.ROLE_SECTION; -const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE; -const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER; -const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF; -const ROLE_TOGGLE_BUTTON = nsIAccessibleRole.ROLE_TOGGLE_BUTTON; - //////////////////////////////////////////////////////////////////////////////// // States diff --git a/accessible/tests/mochitest/nsIAccessible_selects.js b/accessible/tests/mochitest/nsIAccessible_selects.js index 5e5795caa5f..bdd6cd0d611 100644 --- a/accessible/tests/mochitest/nsIAccessible_selects.js +++ b/accessible/tests/mochitest/nsIAccessible_selects.js @@ -55,7 +55,7 @@ function testThis(aID, aAcc, aNames, aRoles, aStates, aUndesiredStates, aIndex) is(aAcc.name, aNames[aIndex], "wrong name for " + aID + " at index " + aIndex + "!"); - var role = aAcc.role; + var role = getRole(aAcc); is(role, aRoles[aIndex], "Wrong role for " + aID + " at index " + aIndex + "!"); testStates(aID, aAcc, aStates, aUndesiredStates, aIndex); diff --git a/accessible/tests/mochitest/nsIAccessible_states.js b/accessible/tests/mochitest/nsIAccessible_states.js index dd7fb7f539e..84e45ae900f 100644 --- a/accessible/tests/mochitest/nsIAccessible_states.js +++ b/accessible/tests/mochitest/nsIAccessible_states.js @@ -73,7 +73,7 @@ function testStatesInSubtree(aAccOrElmOrID, aState, aExtraState, aAbsentState) if (!acc) return; - if (acc.finalRole != ROLE_TEXT_LEAF) + if (getRole(acc) != ROLE_TEXT_LEAF) // Right now, text leafs don't get tested because the states are not being // propagated. testStates(acc, aState, aExtraState, aAbsentState); diff --git a/accessible/tests/mochitest/role.js b/accessible/tests/mochitest/role.js index 98d867994ae..0250a07c7d2 100644 --- a/accessible/tests/mochitest/role.js +++ b/accessible/tests/mochitest/role.js @@ -1,3 +1,52 @@ +//////////////////////////////////////////////////////////////////////////////// +// Role constants + +const ROLE_ALERT = nsIAccessibleRole.ROLE_ALERT; +const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON; +const ROLE_CELL = nsIAccessibleRole.ROLE_CELL; +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; +const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT; +const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY; +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; +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; +const ROLE_NOTHING = nsIAccessibleRole.ROLE_NOTHING; +const ROLE_OPTION = nsIAccessibleRole.ROLE_OPTION; +const ROLE_PARAGRAPH = nsIAccessibleRole.ROLE_PARAGRAPH; +const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT; +const ROLE_SECTION = nsIAccessibleRole.ROLE_SECTION; +const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE; +const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER; +const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF; +const ROLE_TOGGLE_BUTTON = nsIAccessibleRole.ROLE_TOGGLE_BUTTON; + +//////////////////////////////////////////////////////////////////////////////// +// 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) + "!"); +} + /** * Return the role of the given accessible. Return -1 if accessible could not * be retrieved. @@ -20,15 +69,3 @@ function getRole(aAccOrElmOrID) return role; } - -/** - * 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 " + aAccOrElmOrID + "!"); -} diff --git a/accessible/tests/mochitest/testTextboxes.js b/accessible/tests/mochitest/testTextboxes.js index 568d524931c..df6c18519c9 100644 --- a/accessible/tests/mochitest/testTextboxes.js +++ b/accessible/tests/mochitest/testTextboxes.js @@ -38,7 +38,7 @@ function testThis(aID, aName, aValue, aDescription, aRole, aState, 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 + "!"); + testRole(aID, aRole); testStates(acc, aState, aExtraState, aAbsentState); diff --git a/accessible/tests/mochitest/test_aria_role_article.html b/accessible/tests/mochitest/test_aria_role_article.html index 2cbe7ba4662..595786a7e24 100644 --- a/accessible/tests/mochitest/test_aria_role_article.html +++ b/accessible/tests/mochitest/test_aria_role_article.html @@ -14,17 +14,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=429666 + + + @@ -62,21 +64,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=452388 testStates("button_pressed_absent", 0, 0, STATE_PRESSED | STATE_CHECKABLE); // test aria-pressed state mapping to roles PUSHBUTTON vs TOGGLEBUTTON - var aButton = getAccessible("button_pressed_true"); - if (aButton) - is(aButton.finalRole, ROLE_TOGGLE_BUTTON, "Wrong role for togglebutton!"); - aButton = getAccessible("button_pressed_false"); - if (aButton) - is(aButton.finalRole, ROLE_TOGGLE_BUTTON, "Wrong role for togglebutton!"); - aButton = getAccessible("button_pressed_empty"); - if (aButton) - is(aButton.finalRole, ROLE_PUSHBUTTON, "Wrong role for button!"); - aButton = getAccessible("button_pressed_undefined"); - if (aButton) - is(aButton.finalRole, ROLE_PUSHBUTTON, "Wrong role for button!"); - aButton = getAccessible("button_pressed_absent"); - if (aButton) - is(aButton.finalRole, ROLE_PUSHBUTTON, "Wrong role for button!"); + testRole("button_pressed_true", ROLE_TOGGLE_BUTTON); + testRole("button_pressed_false", ROLE_TOGGLE_BUTTON); + testRole("button_pressed_empty", ROLE_PUSHBUTTON); + testRole("button_pressed_undefined", ROLE_PUSHBUTTON); + testRole("button_pressed_absent", ROLE_PUSHBUTTON); SimpleTest.finish(); } diff --git a/accessible/tests/mochitest/test_nsIAccessibleDocument.html b/accessible/tests/mochitest/test_nsIAccessibleDocument.html index 1722dea0733..50884ee0459 100644 --- a/accessible/tests/mochitest/test_nsIAccessibleDocument.html +++ b/accessible/tests/mochitest/test_nsIAccessibleDocument.html @@ -11,6 +11,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441737 + @@ -23,8 +25,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=441737 // nsIAccessible is(docAcc.name, "nsIAccessibleDocument chrome tests", "Name for document accessible not correct!"); - is(docAcc.role, nsIAccessibleRole.ROLE_DOCUMENT, - "Wrong role for document!"); + + testRole(docAcc, ROLE_DOCUMENT); // check if it is focusable, read-only. testStates(docAcc, (STATE_READONLY | STATE_FOCUSABLE)); diff --git a/accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul b/accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul index a85d543a288..9370ea4b3f0 100644 --- a/accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul +++ b/accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul @@ -10,15 +10,16 @@ src="chrome://mochikit/content/MochiKit/packed.js"> + + + + diff --git a/accessible/tests/mochitest/test_relations.html b/accessible/tests/mochitest/test_relations.html index 25f289a7713..178b4361771 100644 --- a/accessible/tests/mochitest/test_relations.html +++ b/accessible/tests/mochitest/test_relations.html @@ -8,10 +8,13 @@ src="chrome://mochikit/content/MochiKit/packed.js"> + + + diff --git a/accessible/tests/mochitest/test_textboxes.xul b/accessible/tests/mochitest/test_textboxes.xul index 7fd2b5f56ce..ac3d554deac 100644 --- a/accessible/tests/mochitest/test_textboxes.xul +++ b/accessible/tests/mochitest/test_textboxes.xul @@ -13,6 +13,8 @@