diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /accessible/tests/mochitest/selectable | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/tests/mochitest/selectable')
-rw-r--r-- | accessible/tests/mochitest/selectable/a11y.ini | 12 | ||||
-rw-r--r-- | accessible/tests/mochitest/selectable/test_aria.html | 246 | ||||
-rw-r--r-- | accessible/tests/mochitest/selectable/test_listbox.xhtml | 144 | ||||
-rw-r--r-- | accessible/tests/mochitest/selectable/test_menu.xhtml | 77 | ||||
-rw-r--r-- | accessible/tests/mochitest/selectable/test_menulist.xhtml | 95 | ||||
-rw-r--r-- | accessible/tests/mochitest/selectable/test_select.html | 241 | ||||
-rw-r--r-- | accessible/tests/mochitest/selectable/test_tabs.xhtml | 93 | ||||
-rw-r--r-- | accessible/tests/mochitest/selectable/test_tree.xhtml | 171 |
8 files changed, 1079 insertions, 0 deletions
diff --git a/accessible/tests/mochitest/selectable/a11y.ini b/accessible/tests/mochitest/selectable/a11y.ini new file mode 100644 index 0000000000..8f109e8b81 --- /dev/null +++ b/accessible/tests/mochitest/selectable/a11y.ini @@ -0,0 +1,12 @@ +[DEFAULT] +support-files = + !/accessible/tests/mochitest/*.js + !/accessible/tests/mochitest/treeview.css + +[test_aria.html] +[test_listbox.xhtml] +[test_menu.xhtml] +[test_menulist.xhtml] +[test_select.html] +[test_tabs.xhtml] +[test_tree.xhtml] diff --git a/accessible/tests/mochitest/selectable/test_aria.html b/accessible/tests/mochitest/selectable/test_aria.html new file mode 100644 index 0000000000..46ecd94031 --- /dev/null +++ b/accessible/tests/mochitest/selectable/test_aria.html @@ -0,0 +1,246 @@ +<html> + +<head> + <title>nsIAccessibleSelectable ARIA widgets testing</title> + + <link rel="stylesheet" type="text/css" + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> + + </style> + + <script 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" + src="../selectable.js"></script> + + <script type="application/javascript"> + function testSelectable(aID, aSelectableChildren) { + var acc = getAccessible(aID, [nsIAccessibleSelectable]); + + testSelectableSelection(acc, []); + + acc.selectAll(); + testSelectableSelection(acc, aSelectableChildren); + + acc.unselectAll(); + testSelectableSelection(acc, []); + } + + function doTest() { + // //////////////////////////////////////////////////////////////////////// + // role="tablist" + + let id = "tablist_single"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectableSelection(id, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // role="tablist" aria-multiselectable + + id = "tablist_multi"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectableSelection(id, [ ]); + + let select = getAccessible(id, [nsIAccessibleSelectable]); + select.addItemToSelection(0); + testSelectableSelection(id, [ "tab_multi1" ]); + select.removeItemFromSelection(0); + testSelectableSelection(id, [ ]); + select.selectAll(); + testSelectableSelection(id, [ "tab_multi1", "tab_multi2" ]); + select.unselectAll(); + testSelectableSelection(id, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // role="listbox" + + id = "listbox1"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectableSelection(id, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // role="listbox" aria-multiselectable + + id = "listbox2"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectableSelection(id, [ ]); + + select = getAccessible(id, [nsIAccessibleSelectable]); + select.addItemToSelection(0); + testSelectableSelection(id, [ "listbox2_item1" ]); + select.removeItemFromSelection(0); + testSelectableSelection(id, [ ]); + select.selectAll(); + testSelectableSelection(id, [ "listbox2_item1", "listbox2_item2" ]); + select.unselectAll(); + testSelectableSelection(id, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // role="grid" + + id = "grid1"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectableSelection(id, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // role="tree" + + id = "tree1"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectableSelection(id, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // role="treegrid" + + id = "treegrid1"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectableSelection(id, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // role="grid" aria-multiselectable, selectable children in subtree + + id = "grid2"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + testSelectable(id, + ["grid2_colhead1", "grid2_colhead2", "grid2_colhead3", + "grid2_rowhead", "grid2_cell1", "grid2_cell2"]); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + </script> + +</head> + +<body> + + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=530014" + title="ARIA single selectable widget should implement nsIAccessibleSelectable"> + Mozilla Bug 530014 + </a> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=566551" + title="ARIA grid and accessible selectable methods shouldn't use GetNextSibling"> + Mozilla Bug 566551 + </a> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" + title="add pseudo SelectAccessible interface"> + Mozilla Bug 590176 + </a> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=804040" + title="Selection event not fired when selection of ARIA tab changes"> + Mozilla Bug 804040 + </a> + <p id="display"></p> + <div id="content" style="display: none"></div> + <pre id="test"> + </pre> + + <div role="tablist" id="tablist_single"> + <div role="tab">tab1</div> + <div role="tab">tab2</div> + </div> + + <div role="tablist" id="tablist_multi" aria-multiselectable="true"> + <div role="tab" id="tab_multi1">tab1</div> + <div role="tab" id="tab_multi2">tab2</div> + </div> + + <div role="listbox" id="listbox1"> + <div role="option">item1</div> + <div role="option">item2</div> + </div> + + <div role="listbox" id="listbox2" aria-multiselectable="true"> + <div role="option" id="listbox2_item1">item1</div> + <div role="option" id="listbox2_item2">item2</div> + </div> + + <div role="grid" id="grid1"> + <div role="row"> + <span role="gridcell">cell</span> + <span role="gridcell">cell</span> + </div> + <div role="row"> + <span role="gridcell">cell</span> + <span role="gridcell">cell</span> + </div> + </div> + + <div role="tree" id="tree1"> + <div role="treeitem"> + item1 + <div role="group"> + <div role="treeitem">item1.1</div> + </div> + </div> + <div>item2</div> + </div> + + <div role="treegrid" id="treegrid1"> + <div role="row" aria-level="1"> + <span role="gridcell">cell</span> + <span role="gridcell">cell</span> + </div> + <div role="row" aria-level="2"> + <span role="gridcell">cell</span> + <span role="gridcell">cell</span> + </div> + <div role="row" aria-level="1"> + <span role="gridcell">cell</span> + <span role="gridcell">cell</span> + </div> + </div> + + <table tabindex="0" border="2" cellspacing="0" id="grid2" role="grid" + aria-multiselectable="true"> + <thead> + <tr> + <th tabindex="-1" role="columnheader" id="grid2_colhead1" + style="width:6em">Entry #</th> + <th tabindex="-1" role="columnheader" id="grid2_colhead2" + style="width:10em">Date</th> + <th tabindex="-1" role="columnheader" id="grid2_colhead3" + style="width:20em">Expense</th> + </tr> + </thead> + <tbody> + <tr> + <td tabindex="-1" role="rowheader" id="grid2_rowhead" + aria-readonly="true">1</td> + <td tabindex="-1" role="gridcell" id="grid2_cell1" + aria-selected="false">03/14/05</td> + <td tabindex="-1" role="gridcell" id="grid2_cell2" + aria-selected="false">Conference Fee</td> + </tr> + </tobdy> + </table> +</body> +</html> diff --git a/accessible/tests/mochitest/selectable/test_listbox.xhtml b/accessible/tests/mochitest/selectable/test_listbox.xhtml new file mode 100644 index 0000000000..b915b2790f --- /dev/null +++ b/accessible/tests/mochitest/selectable/test_listbox.xhtml @@ -0,0 +1,144 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> +<?xml-stylesheet href="../treeview.css" type="text/css"?> + +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + title="XUL tree selectable tests"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + + <script type="application/javascript" + src="../common.js" /> + <script type="application/javascript" + src="../role.js" /> + <script type="application/javascript" + src="../states.js" /> + <script type="application/javascript" + src="../selectable.js" /> + + <script type="application/javascript"> + <![CDATA[ + + //////////////////////////////////////////////////////////////////////////// + // Test + + //gA11yEventDumpID = "debug"; + + var gQueue = null; + + function doTest() + { + ////////////////////////////////////////////////////////////////////////// + // single selectable listbox, the first item is selected by default + + var id = "listbox"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for list of " + id); + + var select = getAccessible(id, [nsIAccessibleSelectable]); + select.removeItemFromSelection(0); + testSelectableSelection(select, [ ]); + + select.addItemToSelection(1); + testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelect(1): "); + + select.removeItemFromSelection(1); + testSelectableSelection(select, [ ], + "removeItemFromSelection(1): "); + + todo(!select.selectAll(), + "No way to select all items in listbox '" + id + "'"); + testSelectableSelection(select, [ "lb1_item1" ], "selectAll: "); + + select.addItemToSelection(1); + select.unselectAll(); + testSelectableSelection(select, [ ], "unselectAll: "); + + ////////////////////////////////////////////////////////////////////////// + // multiple selectable listbox + + id = "listbox2"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for list of " + id); + + select = getAccessible(id, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ ]); + + select.addItemToSelection(1); + testSelectableSelection(select, [ "lb2_item2" ], "addItemToSelect(1): "); + + select.removeItemFromSelection(1); + testSelectableSelection(select, [ ], + "removeItemFromSelection(1): "); + + is(select.selectAll(), true, + "All items should be selected in listbox '" + id + "'"); + testSelectableSelection(select, [ "lb2_item1", "lb2_item2" ], + "selectAll: "); + + select.unselectAll(); + testSelectableSelection(select, [ ], "unselectAll: "); + + ////////////////////////////////////////////////////////////////////////// + // listbox with headers + + // XXX: addItemToSelection/removeItemFromSelection don't work correctly + // on listboxes with headers because header is inserted into hierarchy + // and child indexes that are used in these methods are shifted (see bug + // 591939). + todo(false, + "Fix addItemToSelection/removeItemFromSelection on listboxes with headers."); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + ]]> + </script> + + <hbox flex="1" style="overflow: auto;"> + <body xmlns="http://www.w3.org/1999/xhtml"> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" + title="add pseudo SelectAccessible interface"> + Mozilla Bug 590176 + </a><br/> + <p id="display"></p> + <div id="content" style="display: none"> + </div> + <pre id="test"> + </pre> + </body> + + <vbox flex="1"> + <richlistbox id="listbox"> + <richlistitem id="lb1_item1"> + <label value="cell0"/> + <label value="cell1"/> + </richlistitem> + <richlistitem id="lb1_item2"> + <label value="cell3"/> + <label value="cell4"/> + </richlistitem> + </richlistbox> + + <richlistbox id="listbox2" seltype="multiple"> + <richlistitem id="lb2_item1"> + <label value="cell0"/> + <label value="cell1"/> + </richlistitem> + <richlistitem id="lb2_item2"> + <label value="cell3"/> + <label value="cell4"/> + </richlistitem> + </richlistbox> + + <vbox id="debug"/> + </vbox> + </hbox> + +</window> + diff --git a/accessible/tests/mochitest/selectable/test_menu.xhtml b/accessible/tests/mochitest/selectable/test_menu.xhtml new file mode 100644 index 0000000000..bfef622348 --- /dev/null +++ b/accessible/tests/mochitest/selectable/test_menu.xhtml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> +<?xml-stylesheet href="../treeview.css" type="text/css"?> + +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + title="XUL tree selectable tests"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + + <script type="application/javascript" + src="../common.js" /> + <script type="application/javascript" + src="../role.js" /> + <script type="application/javascript" + src="../states.js" /> + <script type="application/javascript" + src="../selectable.js" /> + + <script type="application/javascript"> + <![CDATA[ + + //////////////////////////////////////////////////////////////////////////// + // Test + + //gA11yEventDumpID = "debug"; + + var gQueue = null; + + function doTest() + { + ////////////////////////////////////////////////////////////////////////// + // menu + + var id = "menu"; + var menu = getAccessible("menu"); + var menuList = menu.firstChild; + todo(isAccessible(menuList, [nsIAccessibleSelectable]), + "No selectable accessible for list of menu '" + id + "'"); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + ]]> + </script> + + <hbox flex="1" style="overflow: auto;"> + <body xmlns="http://www.w3.org/1999/xhtml"> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" + title="add pseudo SelectAccessible interface"> + Mozilla Bug 590176 + </a><br/> + <p id="display"></p> + <div id="content" style="display: none"> + </div> + <pre id="test"> + </pre> + </body> + + <vbox flex="1"> + <menu label="menu" id="menu"> + <menupopup> + <menuitem label="item1" id="m_item1"/> + <menuitem label="item2" id="m_item2"/> + </menupopup> + </menu> + + <vbox id="debug"/> + </vbox> + </hbox> + +</window> + diff --git a/accessible/tests/mochitest/selectable/test_menulist.xhtml b/accessible/tests/mochitest/selectable/test_menulist.xhtml new file mode 100644 index 0000000000..2e4b5ac08f --- /dev/null +++ b/accessible/tests/mochitest/selectable/test_menulist.xhtml @@ -0,0 +1,95 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> +<?xml-stylesheet href="../treeview.css" type="text/css"?> + +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + title="XUL tree selectable tests"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + + <script type="application/javascript" + src="../common.js" /> + <script type="application/javascript" + src="../role.js" /> + <script type="application/javascript" + src="../states.js" /> + <script type="application/javascript" + src="../selectable.js" /> + + <script type="application/javascript"> + <![CDATA[ + + //////////////////////////////////////////////////////////////////////////// + // Test + + //gA11yEventDumpID = "debug"; + + var gQueue = null; + + function doTest() + { + ////////////////////////////////////////////////////////////////////////// + // menulist aka combobox + + var id = "combobox"; + var combobox = getAccessible(id); + var comboboxList = combobox.firstChild; + ok(isAccessible(comboboxList, [nsIAccessibleSelectable]), + "No selectable accessible for list of " + id); + + var select = getAccessible(comboboxList, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ "cb1_item1" ]); + + select.addItemToSelection(1); + testSelectableSelection(select, [ "cb1_item2" ], "addItemToSelection(1): "); + + select.removeItemFromSelection(1); + testSelectableSelection(select, [ ], + "removeItemFromSelection(1): "); + + is(select.selectAll(), false, + "No way to select all items in combobox '" + id + "'"); + testSelectableSelection(select, [ ], "selectAll: "); + + select.addItemToSelection(1); + select.unselectAll(); + testSelectableSelection(select, [ ], "unselectAll: "); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + ]]> + </script> + + <hbox flex="1" style="overflow: auto;"> + <body xmlns="http://www.w3.org/1999/xhtml"> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" + title="add pseudo SelectAccessible interface"> + Mozilla Bug 590176 + </a><br/> + <p id="display"></p> + <div id="content" style="display: none"> + </div> + <pre id="test"> + </pre> + </body> + + <vbox flex="1"> + <menulist id="combobox"> + <menupopup> + <menuitem id="cb1_item1" label="item1"/> + <menuitem id="cb1_item2" label="item2"/> + </menupopup> + </menulist> + + <vbox id="debug"/> + </vbox> + </hbox> + +</window> + diff --git a/accessible/tests/mochitest/selectable/test_select.html b/accessible/tests/mochitest/selectable/test_select.html new file mode 100644 index 0000000000..324831a498 --- /dev/null +++ b/accessible/tests/mochitest/selectable/test_select.html @@ -0,0 +1,241 @@ +<html> + +<head> + <title>nsIAccessibleSelectable HTML select testing</title> + + <link rel="stylesheet" type="text/css" + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> + + </style> + + <script 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" + src="../selectable.js"></script> + + <script type="application/javascript"> + + function doTest() { + // //////////////////////////////////////////////////////////////////////// + // select@size="1" aka combobox + + var id = "combobox"; + var combobox = getAccessible(id); + var comboboxList = combobox.firstChild; + ok(isAccessible(comboboxList, [nsIAccessibleSelectable]), + "No selectable accessible for list of " + id); + + var select = getAccessible(comboboxList, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ "cb1_item1" ]); + + // select 2nd item + select.addItemToSelection(1); + testSelectableSelection(select, [ "cb1_item2" ], "addItemToSelection(1): "); + + // unselect 2nd item, 1st item gets selected automatically + select.removeItemFromSelection(1); + testSelectableSelection(select, [ "cb1_item1" ], + "removeItemFromSelection(1): "); + + // doesn't change selection + is(select.selectAll(), false, + "No way to select all items in combobox '" + id + "'"); + testSelectableSelection(select, [ "cb1_item1" ], "selectAll: "); + + // doesn't change selection + select.unselectAll(); + testSelectableSelection(select, [ "cb1_item1" ], "unselectAll: "); + + // //////////////////////////////////////////////////////////////////////// + // select@size="1" with optgroups + + id = "combobox2"; + combobox = getAccessible(id); + comboboxList = combobox.firstChild; + ok(isAccessible(comboboxList, [nsIAccessibleSelectable]), + "No selectable accessible for list of " + id); + + select = getAccessible(comboboxList, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ "cb2_item1" ]); + + select.addItemToSelection(1); + testSelectableSelection(select, [ "cb2_item2" ]); + + select.removeItemFromSelection(1); + testSelectableSelection(select, [ "cb2_item1" ]); + + is(select.selectAll(), false, + "No way to select all items in combobox " + id + "'"); + testSelectableSelection(select, [ "cb2_item1" ]); + + select.unselectAll(); + testSelectableSelection(select, [ "cb2_item1" ]); + + // //////////////////////////////////////////////////////////////////////// + // select@size="4" aka single selectable listbox + + id = "listbox"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + select = getAccessible(id, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ ]); + + // select 2nd item + select.addItemToSelection(1); + testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelection(1): "); + + // unselect 2nd item, 1st item gets selected automatically + select.removeItemFromSelection(1); + testSelectableSelection(select, [ ], + "removeItemFromSelection(1): "); + + // doesn't change selection + is(select.selectAll(), false, + "No way to select all items in single selectable listbox '" + id + "'"); + testSelectableSelection(select, [ ], "selectAll: "); + + // doesn't change selection + select.unselectAll(); + testSelectableSelection(select, [ ], "unselectAll: "); + + // //////////////////////////////////////////////////////////////////////// + // select@size="4" with optgroups, single selectable + + id = "listbox2"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + select = getAccessible(id, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ ]); + + select.addItemToSelection(1); + testSelectableSelection(select, [ "lb2_item2" ]); + + select.removeItemFromSelection(1); + testSelectableSelection(select, [ ]); + + is(select.selectAll(), false, + "No way to select all items in single selectable listbox " + id + "'"); + testSelectableSelection(select, [ ]); + + select.unselectAll(); + testSelectableSelection(select, [ ]); + + // //////////////////////////////////////////////////////////////////////// + // select@size="4" multiselect aka listbox + + id = "listbox3"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + select = getAccessible(id, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ ]); + + select.addItemToSelection(0); + testSelectableSelection(select, [ "lb3_item1" ], "addItemToSelection: "); + + select.removeItemFromSelection(0); + testSelectableSelection(select, [ ], "removeItemFromSelection: "); + + is(select.selectAll(), true, + "All items in listbox '" + id + "' should be selected"); + testSelectableSelection(select, [ "lb3_item1", "lb3_item2"], + "selectAll: "); + + select.unselectAll(); + testSelectableSelection(select, [ ], "unselectAll: "); + + // //////////////////////////////////////////////////////////////////////// + // select@size="4" multiselect with optgroups + + id = "listbox4"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for " + id); + + select = getAccessible(id, [nsIAccessibleSelectable]); + testSelectableSelection(select, [ ]); + + select.addItemToSelection(0); + testSelectableSelection(select, [ "lb4_item1" ]); + + select.removeItemFromSelection(0); + testSelectableSelection(select, [ ]); + + is(select.selectAll(), true, + "All items in listbox '" + id + "' should be selected"); + testSelectableSelection(select, [ "lb4_item1", "lb4_item2"]); + + select.unselectAll(); + testSelectableSelection(select, [ ]); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + </script> + +</head> + +<body> + + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=530014" + title="ARIA single selectable widget should implement nsIAccessibleSelectable"> + Mozilla Bug 530014 + </a><br> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" + title="add pseudo SelectAccessible interface"> + Mozilla Bug 590176 + </a><br> + <p id="display"></p> + <div id="content" style="display: none"></div> + <pre id="test"> + </pre> + + <select id="combobox"> + <option id="cb1_item1">option1</option> + <option id="cb1_item2">option2</option> + </select> + + <select id="combobox2"> + <option id="cb2_item1">option1</option> + <optgroup>optgroup + <option id="cb2_item2">option2</option> + </optgroup> + </select> + + <select id="listbox" size="4"> + <option id="lb1_item1">option1</option> + <option id="lb1_item2">option2</option> + </select> + + <select id="listbox2" size="4"> + <option id="lb2_item1">option1</option> + <optgroup>optgroup> + <option id="lb2_item2">option2</option> + </optgroup> + </select> + + <select id="listbox3" size="4" multiple="true"> + <option id="lb3_item1">option1</option> + <option id="lb3_item2">option2</option> + </select> + + <select id="listbox4" size="4" multiple="true"> + <option id="lb4_item1">option1</option> + <optgroup>optgroup> + <option id="lb4_item2">option2</option> + </optgroup> + </select> + +</body> +</html> diff --git a/accessible/tests/mochitest/selectable/test_tabs.xhtml b/accessible/tests/mochitest/selectable/test_tabs.xhtml new file mode 100644 index 0000000000..bc16ab0fe7 --- /dev/null +++ b/accessible/tests/mochitest/selectable/test_tabs.xhtml @@ -0,0 +1,93 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> + +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + title="XUL tabs selectable tests"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + + <script type="application/javascript" + src="../common.js" /> + <script type="application/javascript" + src="../role.js" /> + <script type="application/javascript" + src="../states.js" /> + <script type="application/javascript" + src="../selectable.js" /> + + <script type="application/javascript"> + <![CDATA[ + + //////////////////////////////////////////////////////////////////////////// + // Test + + function doTest() + { + var id = "tabs_single"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for tabs_single"); + var select = getAccessible(id, [nsIAccessibleSelectable]); + + testSelectableSelection(select, ["tab_single1"]); + + select.unselectAll(); + select.addItemToSelection(1); // tab_single2 + testSelectableSelection(select, ["tab_single2"], "select tab_single2: "); + + id = "tabs_multi"; + ok(isAccessible(id, [nsIAccessibleSelectable]), + "No selectable accessible for tabs_multi"); + select = getAccessible(id, [nsIAccessibleSelectable]); + + // Make sure both XUL selection and ARIA selection are included. + testSelectableSelection(select, ["tab_multi_xul1", "tab_multi_aria"]); + + select.unselectAll(); + select.addItemToSelection(2); // tab_multi_xul2 + // We can only affect XUL selection, so ARIA selection won't change. + testSelectableSelection(select, ["tab_multi_aria", "tab_multi_xul2"], + "select tab_multi_xul2: "); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + ]]> + </script> + + <hbox flex="1" style="overflow: auto;"> + <body xmlns="http://www.w3.org/1999/xhtml"> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=1480058" + title="XUL tabs don't support ARIA selection"> + Mozilla Bug 1480058 + </a><br/> + <p id="display"></p> + <div id="content" style="display: none"> + </div> + <pre id="test"> + </pre> + </body> + + <vbox flex="1"> + <tabbox> + <tabs id="tabs_single"> + <tab id="tab_single1" label="tab1" selected="true"/> + <tab id="tab_single2" label="tab2"/> + </tabs> + </tabbox> + + <tabbox> + <tabs id="tabs_multi" aria-multiselectable="true"> + <tab id="tab_multi_xul1" label="tab1" selected="true"/> + <tab id="tab_multi_aria" label="tab2" aria-selected="true"/> + <tab id="tab_multi_xul2" label="tab3"/> + </tabs> + </tabbox> + </vbox> + </hbox> + +</window> diff --git a/accessible/tests/mochitest/selectable/test_tree.xhtml b/accessible/tests/mochitest/selectable/test_tree.xhtml new file mode 100644 index 0000000000..5527625b24 --- /dev/null +++ b/accessible/tests/mochitest/selectable/test_tree.xhtml @@ -0,0 +1,171 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> +<?xml-stylesheet href="../treeview.css" + type="text/css"?> + +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + title="XUL tree selectable tests"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + + <script type="application/javascript" + src="../treeview.js" /> + + <script type="application/javascript" + src="../common.js" /> + <script type="application/javascript" + src="../events.js" /> + <script type="application/javascript" + src="../role.js" /> + <script type="application/javascript" + src="../states.js" /> + <script type="application/javascript" + src="../selectable.js" /> + + <script type="application/javascript"> + <![CDATA[ + //////////////////////////////////////////////////////////////////////////// + // Test + + // gA11yEventDumpID = "debug"; + + /** + * Event queue invoker object to test accessible states for XUL tree + * accessible. + */ + function statesChecker(aTreeID, aView) + { + this.DOMNode = getNode(aTreeID); + + this.invoke = function invoke() + { + this.DOMNode.view = aView; + } + this.check = function check() + { + var tree = getAccessible(this.DOMNode); + + var isTreeMultiSelectable = false; + var seltype = this.DOMNode.getAttribute("seltype"); + if (seltype != "single") + isTreeMultiSelectable = true; + + // selectAll + var accSelectable = getAccessible(this.DOMNode, + [nsIAccessibleSelectable]); + ok(accSelectable, "tree is not selectable!"); + if (accSelectable) { + is(accSelectable.selectAll(), isTreeMultiSelectable, + "SelectAll is not correct for seltype: " + seltype); + } + + var selectedChildren = []; + if (isTreeMultiSelectable) { + var rows = tree.children; + for (var i = 0; i < rows.length; i++) { + var row = rows.queryElementAt(i, nsIAccessible); + if (getRole(row) == ROLE_OUTLINEITEM || getRole(row) == ROLE_ROW) + selectedChildren.push(row); + } + } + testSelectableSelection(accSelectable, selectedChildren, + "selectAll test. "); + + // unselectAll + accSelectable.unselectAll(); + testSelectableSelection(accSelectable, [], "unselectAll test. "); + + // addItemToSelection + accSelectable.addItemToSelection(1); + accSelectable.addItemToSelection(3); + + selectedChildren = isTreeMultiSelectable ? + [ accSelectable.getChildAt(2), accSelectable.getChildAt(4) ] : + [ accSelectable.getChildAt(2) ]; + testSelectableSelection(accSelectable, selectedChildren, + "addItemToSelection test. "); + + // removeItemFromSelection + accSelectable.removeItemFromSelection(1); + + selectedChildren = isTreeMultiSelectable ? + [ accSelectable.getChildAt(4) ] : [ ]; + testSelectableSelection(accSelectable, selectedChildren, + "removeItemFromSelection test. "); + } + + this.getID = function getID() + { + "tree processor for " + prettyName(aTreeID); + } + } + + var gQueue = null; + + function doTest() + { + gQueue = new eventQueue(EVENT_REORDER); + gQueue.push(new statesChecker("tree", new nsTreeTreeView())); + gQueue.push(new statesChecker("treesingle", new nsTreeTreeView())); + gQueue.push(new statesChecker("tabletree", new nsTreeTreeView())); + + gQueue.invoke(); // Will call SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + ]]> + </script> + + <hbox flex="1" style="overflow: auto;"> + <body xmlns="http://www.w3.org/1999/xhtml"> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=523118" + title="we mistake 'cell' and text' xul tree seltypes for multiselects"> + Mozilla Bug 523118 + </a> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=624977" + title="Optimize nsXulTreeAccessible selectedItems()"> + Mozilla Bug 624977 + </a><br/> + <p id="display"></p> + <div id="content" style="display: none"> + </div> + <pre id="test"> + </pre> + </body> + + <vbox flex="1"> + <tree id="tree" flex="1"> + <treecols> + <treecol id="col" flex="1" primary="true" label="column"/> + </treecols> + <treechildren/> + </tree> + + <tree id="treesingle" flex="1" seltype="single"> + <treecols> + <treecol id="col_single" flex="1" primary="true" label="column"/> + </treecols> + <treechildren/> + </tree> + + <tree id="tabletree" flex="1" editable="true"> + <treecols> + <treecol id="tabletree_col1" cycler="true" label="cycler"/> + <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/> + <treecol id="tabletree_col3" flex="1" label="column2"/> + <treecol id="tabletree_col4" flex="1" label="checker" + type="checkbox" editable="true"/> + </treecols> + <treechildren/> + </tree> + + <vbox id="debug"/> + </vbox> + </hbox> + +</window> |