accessible/tests/mochitest/selectable/test_listbox.xul

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

mercurial