accessible/tests/mochitest/selectable/test_listbox.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 4 type="text/css"?>
michael@0 5 <?xml-stylesheet href="../treeview.css" type="text/css"?>
michael@0 6
michael@0 7 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 8 title="XUL tree selectable tests">
michael@0 9
michael@0 10 <script type="application/javascript"
michael@0 11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 12
michael@0 13 <script type="application/javascript"
michael@0 14 src="../common.js" />
michael@0 15 <script type="application/javascript"
michael@0 16 src="../role.js" />
michael@0 17 <script type="application/javascript"
michael@0 18 src="../states.js" />
michael@0 19 <script type="application/javascript"
michael@0 20 src="../selectable.js" />
michael@0 21
michael@0 22 <script type="application/javascript">
michael@0 23 <![CDATA[
michael@0 24
michael@0 25 ////////////////////////////////////////////////////////////////////////////
michael@0 26 // Test
michael@0 27
michael@0 28 //gA11yEventDumpID = "debug";
michael@0 29
michael@0 30 var gQueue = null;
michael@0 31
michael@0 32 function doTest()
michael@0 33 {
michael@0 34 //////////////////////////////////////////////////////////////////////////
michael@0 35 // single selectable listbox
michael@0 36
michael@0 37 var id = "listbox";
michael@0 38 ok(isAccessible(id, [nsIAccessibleSelectable]),
michael@0 39 "No selectable accessible for list of " + id);
michael@0 40
michael@0 41 var select = getAccessible(id, [nsIAccessibleSelectable]);
michael@0 42 testSelectableSelection(select, [ ]);
michael@0 43
michael@0 44 select.addItemToSelection(1);
michael@0 45 testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelect(1): ");
michael@0 46
michael@0 47 select.removeItemFromSelection(1);
michael@0 48 testSelectableSelection(select, [ ],
michael@0 49 "removeItemFromSelection(1): ");
michael@0 50
michael@0 51 todo(select.selectAll() == false,
michael@0 52 "No way to select all items in listbox '" + id + "'");
michael@0 53 testSelectableSelection(select, [ "lb1_item1" ], "selectAll: ");
michael@0 54
michael@0 55 select.addItemToSelection(1);
michael@0 56 select.unselectAll();
michael@0 57 testSelectableSelection(select, [ ], "unselectAll: ");
michael@0 58
michael@0 59 //////////////////////////////////////////////////////////////////////////
michael@0 60 // multiple selectable listbox
michael@0 61
michael@0 62 var id = "listbox2";
michael@0 63 ok(isAccessible(id, [nsIAccessibleSelectable]),
michael@0 64 "No selectable accessible for list of " + id);
michael@0 65
michael@0 66 var select = getAccessible(id, [nsIAccessibleSelectable]);
michael@0 67 testSelectableSelection(select, [ ]);
michael@0 68
michael@0 69 select.addItemToSelection(1);
michael@0 70 testSelectableSelection(select, [ "lb2_item2" ], "addItemToSelect(1): ");
michael@0 71
michael@0 72 select.removeItemFromSelection(1);
michael@0 73 testSelectableSelection(select, [ ],
michael@0 74 "removeItemFromSelection(1): ");
michael@0 75
michael@0 76 is(select.selectAll(), true,
michael@0 77 "All items should be selected in listbox '" + id + "'");
michael@0 78 testSelectableSelection(select, [ "lb2_item1", "lb2_item2" ],
michael@0 79 "selectAll: ");
michael@0 80
michael@0 81 select.unselectAll();
michael@0 82 testSelectableSelection(select, [ ], "unselectAll: ");
michael@0 83
michael@0 84 //////////////////////////////////////////////////////////////////////////
michael@0 85 // listbox with headers
michael@0 86
michael@0 87 // XXX: addItemToSelection/removeItemFromSelection don't work correctly
michael@0 88 // on listboxes with headers because header is inserted into hierarchy
michael@0 89 // and child indexes that are used in these methods are shifted (see bug
michael@0 90 // 591939).
michael@0 91 todo(false,
michael@0 92 "Fix addItemToSelection/removeItemFromSelection on listboxes with headers.");
michael@0 93
michael@0 94 SimpleTest.finish();
michael@0 95 }
michael@0 96
michael@0 97 SimpleTest.waitForExplicitFinish();
michael@0 98 addA11yLoadEvent(doTest);
michael@0 99 ]]>
michael@0 100 </script>
michael@0 101
michael@0 102 <hbox flex="1" style="overflow: auto;">
michael@0 103 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 104 <a target="_blank"
michael@0 105 href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176"
michael@0 106 title="add pseudo SelectAccessible interface">
michael@0 107 Mozilla Bug 590176
michael@0 108 </a><br/>
michael@0 109 <p id="display"></p>
michael@0 110 <div id="content" style="display: none">
michael@0 111 </div>
michael@0 112 <pre id="test">
michael@0 113 </pre>
michael@0 114 </body>
michael@0 115
michael@0 116 <vbox flex="1">
michael@0 117 <listbox id="listbox">
michael@0 118 <listcols>
michael@0 119 <listcol flex="1"/>
michael@0 120 <listcol flex="1"/>
michael@0 121 </listcols>
michael@0 122 <listitem id="lb1_item1">
michael@0 123 <listcell label="cell0"/>
michael@0 124 <listcell label="cell1"/>
michael@0 125 </listitem>
michael@0 126 <listitem id="lb1_item2">
michael@0 127 <listcell label="cell3"/>
michael@0 128 <listcell label="cell4"/>
michael@0 129 </listitem>
michael@0 130 </listbox>
michael@0 131
michael@0 132 <listbox id="listbox2" seltype="multiple">
michael@0 133 <listcols>
michael@0 134 <listcol flex="1"/>
michael@0 135 <listcol flex="1"/>
michael@0 136 </listcols>
michael@0 137 <listitem id="lb2_item1">
michael@0 138 <listcell label="cell0"/>
michael@0 139 <listcell label="cell1"/>
michael@0 140 </listitem>
michael@0 141 <listitem id="lb2_item2">
michael@0 142 <listcell label="cell3"/>
michael@0 143 <listcell label="cell4"/>
michael@0 144 </listitem>
michael@0 145 </listbox>
michael@0 146
michael@0 147 <vbox id="debug"/>
michael@0 148 </vbox>
michael@0 149 </hbox>
michael@0 150
michael@0 151 </window>
michael@0 152

mercurial