|
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="Accessible XUL tree actions 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="../role.js" /> |
|
21 <script type="application/javascript" |
|
22 src="../states.js" /> |
|
23 <script type="application/javascript" |
|
24 src="../events.js" /> |
|
25 <script type="application/javascript" |
|
26 src="../actions.js" /> |
|
27 |
|
28 <script type="application/javascript"> |
|
29 <![CDATA[ |
|
30 //////////////////////////////////////////////////////////////////////////// |
|
31 // Accessible tree testers |
|
32 |
|
33 function focusChecker(aAcc, aStates) |
|
34 { |
|
35 this.type = EVENT_FOCUS; |
|
36 this.target = aAcc; |
|
37 this.getID = function focusChecker_getID() |
|
38 { |
|
39 return "focus handling"; |
|
40 } |
|
41 this.check = function focusChecker_check(aEvent) |
|
42 { |
|
43 var states = aStates ? aStates : 0; |
|
44 testStates(this.target, STATE_FOCUSED | STATE_SELECTED | states); |
|
45 } |
|
46 } |
|
47 |
|
48 function stateChangeChecker(aAcc, aIsEnabled) |
|
49 { |
|
50 this.type = EVENT_STATE_CHANGE; |
|
51 this.target = aAcc; |
|
52 this.getID = function stateChangeChecker_getID() |
|
53 { |
|
54 return "state change handling"; |
|
55 } |
|
56 this.check = function stateChangeChecker_check(aEvent) |
|
57 { |
|
58 if (aIsEnabled) |
|
59 testStates(this.target, STATE_CHECKED); |
|
60 else |
|
61 testStates(this.target, STATE_CHECKABLE, 0, STATE_CHECKED); |
|
62 } |
|
63 } |
|
64 |
|
65 //////////////////////////////////////////////////////////////////////////// |
|
66 // Test |
|
67 |
|
68 function doTestActions() |
|
69 { |
|
70 var treeNode = getNode("tabletree"); |
|
71 |
|
72 var treeBodyNode = treeNode.boxObject.treeBody; |
|
73 treeNode.focus(); |
|
74 |
|
75 var tree = getAccessible(treeNode); |
|
76 |
|
77 var expandedTreeItem = tree.getChildAt(2); |
|
78 var collapsedTreeItem = tree.getChildAt(5); |
|
79 var cycleCell = expandedTreeItem.getChildAt(0); |
|
80 var checkableCell = expandedTreeItem.getChildAt(3); |
|
81 |
|
82 var actions = [ |
|
83 { |
|
84 ID: expandedTreeItem, |
|
85 actionName: "activate", |
|
86 actionIndex: 0, |
|
87 events: CLICK_EVENTS, |
|
88 targetID: treeBodyNode, |
|
89 eventSeq: [ |
|
90 new focusChecker(expandedTreeItem, STATE_EXPANDED) |
|
91 ] |
|
92 }, |
|
93 { |
|
94 ID: collapsedTreeItem, |
|
95 actionName: "expand", |
|
96 actionIndex: 1, |
|
97 events: CLICK_EVENTS, |
|
98 targetID: treeBodyNode, |
|
99 check: function check(aEvent) |
|
100 { |
|
101 testStates(this.ID, STATE_EXPANDED); |
|
102 } |
|
103 }, |
|
104 { |
|
105 ID: collapsedTreeItem, |
|
106 actionName: "collapse", |
|
107 actionIndex: 1, |
|
108 events: CLICK_EVENTS, |
|
109 targetID: treeBodyNode, |
|
110 check: function check(aEvent) |
|
111 { |
|
112 testStates(this.ID, STATE_COLLAPSED); |
|
113 } |
|
114 }, |
|
115 { |
|
116 ID: cycleCell, |
|
117 actionName: "cycle", |
|
118 actionIndex: 0, |
|
119 events: CLICK_EVENTS, |
|
120 targetID: treeBodyNode |
|
121 }, |
|
122 { |
|
123 ID: checkableCell, |
|
124 actionName: "uncheck", |
|
125 actionIndex: 0, |
|
126 events: CLICK_EVENTS, |
|
127 targetID: treeBodyNode, |
|
128 eventSeq: [ |
|
129 new stateChangeChecker(checkableCell, false) |
|
130 ] |
|
131 }, |
|
132 { |
|
133 ID: checkableCell, |
|
134 actionName: "check", |
|
135 actionIndex: 0, |
|
136 events: CLICK_EVENTS, |
|
137 targetID: treeBodyNode, |
|
138 eventSeq: [ |
|
139 new stateChangeChecker(checkableCell, true) |
|
140 ] |
|
141 } |
|
142 ]; |
|
143 |
|
144 testActions(actions); // Will call SimpleTest.finish(); |
|
145 } |
|
146 |
|
147 // gA11yEventDumpID = "debug"; |
|
148 |
|
149 function doTest() |
|
150 { |
|
151 var treeNode = getNode("tabletree"); |
|
152 waitForEvent(EVENT_REORDER, treeNode, doTestActions); |
|
153 treeNode.view = new nsTreeTreeView(); |
|
154 } |
|
155 |
|
156 function test1() |
|
157 { |
|
158 var boxObj = getNode("tabletree").treeBoxObject; |
|
159 boxObj.view.setCellValue(0, boxObj.columns.firstColumn, "false"); |
|
160 } |
|
161 |
|
162 SimpleTest.waitForExplicitFinish(); |
|
163 addA11yLoadEvent(doTest); |
|
164 ]]> |
|
165 </script> |
|
166 |
|
167 <hbox flex="1" style="overflow: auto;"> |
|
168 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
169 <a target="_blank" |
|
170 href="https://bugzilla.mozilla.org/show_bug.cgi?id=503727" |
|
171 title="Reorganize implementation of XUL tree accessibility"> |
|
172 Mozilla Bug 503727 |
|
173 </a><br/> |
|
174 <p id="display"></p> |
|
175 <div id="content" style="display: none"> |
|
176 </div> |
|
177 <pre id="test"> |
|
178 </pre> |
|
179 </body> |
|
180 |
|
181 <vbox flex="1"> |
|
182 <tree id="tabletree" flex="1" editable="true"> |
|
183 <treecols> |
|
184 <treecol id="tabletree_col1" cycler="true" label="cycler"/> |
|
185 <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/> |
|
186 <treecol id="tabletree_col3" flex="1" label="column2"/> |
|
187 <treecol id="tabletree_col4" flex="1" label="checker" |
|
188 type="checkbox" editable="true"/> |
|
189 </treecols> |
|
190 <treechildren/> |
|
191 </tree> |
|
192 |
|
193 <vbox id="debug"/> |
|
194 <button oncommand="test1();" label="uncheck"/> |
|
195 </vbox> |
|
196 </hbox> |
|
197 |
|
198 </window> |
|
199 |