|
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" |
|
6 type="text/css"?> |
|
7 |
|
8 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
9 title="XUL tree selectable tests"> |
|
10 |
|
11 <script type="application/javascript" |
|
12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
|
13 |
|
14 <script type="application/javascript" |
|
15 src="../treeview.js" /> |
|
16 |
|
17 <script type="application/javascript" |
|
18 src="../common.js" /> |
|
19 <script type="application/javascript" |
|
20 src="../events.js" /> |
|
21 <script type="application/javascript" |
|
22 src="../role.js" /> |
|
23 <script type="application/javascript" |
|
24 src="../states.js" /> |
|
25 <script type="application/javascript" |
|
26 src="../selectable.js" /> |
|
27 |
|
28 <script type="application/javascript"> |
|
29 <![CDATA[ |
|
30 //////////////////////////////////////////////////////////////////////////// |
|
31 // Test |
|
32 |
|
33 // gA11yEventDumpID = "debug"; |
|
34 |
|
35 /** |
|
36 * Event queue invoker object to test accessible states for XUL tree |
|
37 * accessible. |
|
38 */ |
|
39 function statesChecker(aTreeID, aView) |
|
40 { |
|
41 this.DOMNode = getNode(aTreeID); |
|
42 |
|
43 this.invoke = function invoke() |
|
44 { |
|
45 this.DOMNode.treeBoxObject.view = aView; |
|
46 } |
|
47 this.check = function check() |
|
48 { |
|
49 var tree = getAccessible(this.DOMNode); |
|
50 |
|
51 var isTreeMultiSelectable = false; |
|
52 var seltype = this.DOMNode.getAttribute("seltype"); |
|
53 if (seltype != "single" && seltype != "cell" && seltype != "text") |
|
54 isTreeMultiSelectable = true; |
|
55 |
|
56 // selectAll |
|
57 var accSelectable = getAccessible(this.DOMNode, |
|
58 [nsIAccessibleSelectable]); |
|
59 ok(accSelectable, "tree is not selectable!"); |
|
60 if (accSelectable) { |
|
61 is(accSelectable.selectAll(), isTreeMultiSelectable, |
|
62 "SelectAll is not correct for seltype: " + seltype); |
|
63 } |
|
64 |
|
65 var selectedChildren = []; |
|
66 if (isTreeMultiSelectable) { |
|
67 var rows = tree.children; |
|
68 for (var i = 0; i < rows.length; i++) { |
|
69 var row = rows.queryElementAt(i, nsIAccessible); |
|
70 if (getRole(row) == ROLE_OUTLINEITEM || getRole(row) == ROLE_ROW) |
|
71 selectedChildren.push(row); |
|
72 } |
|
73 } |
|
74 testSelectableSelection(accSelectable, selectedChildren, |
|
75 "selectAll test. "); |
|
76 |
|
77 // unselectAll |
|
78 accSelectable.unselectAll(); |
|
79 testSelectableSelection(accSelectable, [], "unselectAll test. "); |
|
80 |
|
81 // addItemToSelection |
|
82 accSelectable.addItemToSelection(1); |
|
83 accSelectable.addItemToSelection(3); |
|
84 |
|
85 selectedChildren = isTreeMultiSelectable ? |
|
86 [ accSelectable.getChildAt(2), accSelectable.getChildAt(4) ] : |
|
87 [ accSelectable.getChildAt(2) ]; |
|
88 testSelectableSelection(accSelectable, selectedChildren, |
|
89 "addItemToSelection test. "); |
|
90 |
|
91 // removeItemFromSelection |
|
92 accSelectable.removeItemFromSelection(1); |
|
93 |
|
94 selectedChildren = isTreeMultiSelectable ? |
|
95 [ accSelectable.getChildAt(4) ] : [ ]; |
|
96 testSelectableSelection(accSelectable, selectedChildren, |
|
97 "removeItemFromSelection test. "); |
|
98 } |
|
99 |
|
100 this.getID = function getID() |
|
101 { |
|
102 "tree processor for " + prettyName(aTreeID); |
|
103 } |
|
104 } |
|
105 |
|
106 var gQueue = null; |
|
107 |
|
108 function doTest() |
|
109 { |
|
110 gQueue = new eventQueue(EVENT_REORDER); |
|
111 gQueue.push(new statesChecker("tree", new nsTreeTreeView())); |
|
112 gQueue.push(new statesChecker("treesingle", new nsTreeTreeView())); |
|
113 gQueue.push(new statesChecker("treecell", new nsTreeTreeView())); |
|
114 gQueue.push(new statesChecker("treetext", new nsTreeTreeView())); |
|
115 gQueue.push(new statesChecker("tabletree", new nsTreeTreeView())); |
|
116 |
|
117 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
118 } |
|
119 |
|
120 SimpleTest.waitForExplicitFinish(); |
|
121 addA11yLoadEvent(doTest); |
|
122 ]]> |
|
123 </script> |
|
124 |
|
125 <hbox flex="1" style="overflow: auto;"> |
|
126 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
127 <a target="_blank" |
|
128 href="https://bugzilla.mozilla.org/show_bug.cgi?id=523118" |
|
129 title="we mistake 'cell' and text' xul tree seltypes for multiselects"> |
|
130 Mozilla Bug 523118 |
|
131 </a> |
|
132 <a target="_blank" |
|
133 href="https://bugzilla.mozilla.org/show_bug.cgi?id=624977" |
|
134 title="Optimize nsXulTreeAccessible selectedItems()"> |
|
135 Mozilla Bug 624977 |
|
136 </a><br/> |
|
137 <p id="display"></p> |
|
138 <div id="content" style="display: none"> |
|
139 </div> |
|
140 <pre id="test"> |
|
141 </pre> |
|
142 </body> |
|
143 |
|
144 <vbox flex="1"> |
|
145 <tree id="tree" flex="1"> |
|
146 <treecols> |
|
147 <treecol id="col" flex="1" primary="true" label="column"/> |
|
148 </treecols> |
|
149 <treechildren/> |
|
150 </tree> |
|
151 |
|
152 <tree id="treesingle" flex="1" seltype="single"> |
|
153 <treecols> |
|
154 <treecol id="col_single" flex="1" primary="true" label="column"/> |
|
155 </treecols> |
|
156 <treechildren/> |
|
157 </tree> |
|
158 |
|
159 <tree id="treecell" flex="1" seltype="cell"> |
|
160 <treecols> |
|
161 <treecol id="col_cell" flex="1" primary="true" label="column"/> |
|
162 </treecols> |
|
163 <treechildren/> |
|
164 </tree> |
|
165 |
|
166 <tree id="treetext" flex="1" seltype="text"> |
|
167 <treecols> |
|
168 <treecol id="col_text" flex="1" primary="true" label="column"/> |
|
169 </treecols> |
|
170 <treechildren/> |
|
171 </tree> |
|
172 |
|
173 <tree id="tabletree" flex="1" editable="true"> |
|
174 <treecols> |
|
175 <treecol id="tabletree_col1" cycler="true" label="cycler"/> |
|
176 <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/> |
|
177 <treecol id="tabletree_col3" flex="1" label="column2"/> |
|
178 <treecol id="tabletree_col4" flex="1" label="checker" |
|
179 type="checkbox" editable="true"/> |
|
180 </treecols> |
|
181 <treechildren/> |
|
182 </tree> |
|
183 |
|
184 <vbox id="debug"/> |
|
185 </vbox> |
|
186 </hbox> |
|
187 |
|
188 </window> |
|
189 |