|
1 <html> |
|
2 |
|
3 <head> |
|
4 <title>Accessible value change events testing</title> |
|
5 |
|
6 <link rel="stylesheet" type="text/css" |
|
7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
8 |
|
9 <script type="application/javascript" |
|
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
11 <script type="application/javascript" |
|
12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
13 |
|
14 <script type="application/javascript" |
|
15 src="../common.js"></script> |
|
16 <script type="application/javascript" |
|
17 src="../events.js"></script> |
|
18 |
|
19 <script type="application/javascript" |
|
20 src="../value.js"></script> |
|
21 |
|
22 <script type="application/javascript"> |
|
23 |
|
24 |
|
25 /** |
|
26 * Do tests. |
|
27 */ |
|
28 var gQueue = null; |
|
29 |
|
30 // Value change invoker |
|
31 function changeARIAValue(aNodeOrID, aValuenow, aValuetext) |
|
32 { |
|
33 this.DOMNode = getNode(aNodeOrID); |
|
34 |
|
35 this.invoke = function changeARIAValue_invoke() { |
|
36 |
|
37 // Note: this should not fire an EVENT_VALUE_CHANGE when aria-valuetext |
|
38 // is not empty |
|
39 if (aValuenow != undefined) |
|
40 this.DOMNode.setAttribute("aria-valuenow", aValuenow); |
|
41 |
|
42 // Note: this should always fire an EVENT_VALUE_CHANGE |
|
43 if (aValuetext != undefined) |
|
44 this.DOMNode.setAttribute("aria-valuetext", aValuetext); |
|
45 } |
|
46 |
|
47 this.check = function changeARIAValue_check() { |
|
48 var acc = getAccessible(aNodeOrID, [nsIAccessibleValue]); |
|
49 if (!acc) |
|
50 return; |
|
51 |
|
52 // Note: always test against valuetext first because the existence of |
|
53 // aria-valuetext takes precedence over aria-valuenow in gecko. |
|
54 is(acc.value, (aValuetext != undefined)? aValuetext : aValuenow, |
|
55 "Wrong value of " + prettyName(aNodeOrID)); |
|
56 } |
|
57 |
|
58 this.getID = function changeARIAValue_getID() { |
|
59 return prettyName(aNodeOrID) + " value changed"; |
|
60 } |
|
61 } |
|
62 |
|
63 function changeValue(aID, aValue) |
|
64 { |
|
65 this.DOMNode = getNode(aID); |
|
66 |
|
67 this.invoke = function changeValue_invoke() |
|
68 { |
|
69 this.DOMNode.value = aValue; |
|
70 } |
|
71 |
|
72 this.check = function changeValue_check() |
|
73 { |
|
74 var acc = getAccessible(this.DOMNode); |
|
75 is(acc.value, aValue, "Wrong value for " + prettyName(aID)); |
|
76 } |
|
77 |
|
78 this.getID = function changeValue_getID() |
|
79 { |
|
80 return prettyName(aID) + " value changed"; |
|
81 } |
|
82 } |
|
83 |
|
84 function changeProgressValue(aID, aValue) |
|
85 { |
|
86 this.DOMNode = getNode(aID); |
|
87 |
|
88 this.invoke = function changeProgressValue_invoke() |
|
89 { |
|
90 this.DOMNode.value = aValue; |
|
91 } |
|
92 |
|
93 this.check = function changeProgressValue_check() |
|
94 { |
|
95 var acc = getAccessible(this.DOMNode); |
|
96 is(acc.value, aValue+"%", "Wrong value for " + prettyName(aID)); |
|
97 } |
|
98 |
|
99 this.getID = function changeProgressValue_getID() |
|
100 { |
|
101 return prettyName(aID) + " value changed"; |
|
102 } |
|
103 } |
|
104 |
|
105 function changeRangeValue(aID) |
|
106 { |
|
107 this.DOMNode = getNode(aID); |
|
108 |
|
109 this.invoke = function changeRangeValue_invoke() |
|
110 { |
|
111 synthesizeMouse(getNode(aID), 5, 5, { }); |
|
112 } |
|
113 |
|
114 this.finalCheck = function changeRangeValue_finalCheck() |
|
115 { |
|
116 var acc = getAccessible(this.DOMNode); |
|
117 is(acc.value, "0", "Wrong value for " + prettyName(aID)); |
|
118 } |
|
119 |
|
120 this.getID = function changeRangeValue_getID() |
|
121 { |
|
122 return prettyName(aID) + " range value changed"; |
|
123 } |
|
124 } |
|
125 |
|
126 function doTests() |
|
127 { |
|
128 // Test initial values |
|
129 testValue("slider_vn", "5", 5, 0, 1000, 0); |
|
130 testValue("slider_vnvt", "plain", 0, 0, 5, 0); |
|
131 testValue("slider_vt", "hi", 0, 0, 3, 0); |
|
132 testValue("scrollbar", "5", 5, 0, 1000, 0); |
|
133 testValue("progress", "22%", 22, 0, 100, 0); |
|
134 testValue("range", "6", 6, 0, 10, 1); |
|
135 |
|
136 // Test value change events |
|
137 gQueue = new eventQueue(nsIAccessibleEvent.EVENT_VALUE_CHANGE); |
|
138 |
|
139 gQueue.push(new changeARIAValue("slider_vn", "6", undefined)); |
|
140 gQueue.push(new changeARIAValue("slider_vt", undefined, "hey!")); |
|
141 gQueue.push(new changeARIAValue("slider_vnvt", "3", "sweet")); |
|
142 gQueue.push(new changeARIAValue("scrollbar", "6", undefined)); |
|
143 |
|
144 gQueue.push(new changeValue("combobox", "hello")); |
|
145 |
|
146 gQueue.push(new changeProgressValue("progress", "50")); |
|
147 gQueue.push(new changeRangeValue("range")); |
|
148 |
|
149 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
150 } |
|
151 |
|
152 SimpleTest.waitForExplicitFinish(); |
|
153 addA11yLoadEvent(doTests); |
|
154 </script> |
|
155 </head> |
|
156 |
|
157 <body> |
|
158 |
|
159 <a target="_blank" |
|
160 href="https://bugzilla.mozilla.org/show_bug.cgi?id=478032" |
|
161 title=" Fire delayed value changed event for aria-valuetext changes"> |
|
162 Mozilla Bug 478032 |
|
163 </a> |
|
164 <a target="_blank" |
|
165 href="https://bugzilla.mozilla.org/show_bug.cgi?id=529289" |
|
166 title="We dont expose new aria role 'scrollbar' and property aria-orientation"> |
|
167 Mozilla Bug 529289 |
|
168 </a> |
|
169 <a target="_blank" |
|
170 href="https://bugzilla.mozilla.org/show_bug.cgi?id=559764" |
|
171 title="Make HTML5 input@type=range element accessible"> |
|
172 Mozilla Bug 559764 |
|
173 </a> |
|
174 <a target="_blank" |
|
175 href="https://bugzilla.mozilla.org/show_bug.cgi?id=703202" |
|
176 title="ARIA comboboxes don't fire value change events"> |
|
177 Mozilla Bug 703202 |
|
178 </a> |
|
179 <a target="_blank" |
|
180 href="https://bugzilla.mozilla.org/show_bug.cgi?id=761901" |
|
181 title=" HTML5 progress accessible should fire value change event"> |
|
182 Mozilla Bug 761901 |
|
183 </a> |
|
184 |
|
185 |
|
186 <p id="display"></p> |
|
187 <div id="content" style="display: none"></div> |
|
188 <pre id="test"> |
|
189 </pre> |
|
190 <div id="eventdump"></div> |
|
191 |
|
192 <!-- ARIA sliders --> |
|
193 <div id="slider_vn" role="slider" aria-valuenow="5" |
|
194 aria-valuemin="0" aria-valuemax="1000">slider</div> |
|
195 |
|
196 <div id="slider_vt" role="slider" aria-valuetext="hi" |
|
197 aria-valuemin="0" aria-valuemax="3">greeting slider</div> |
|
198 |
|
199 <div id="slider_vnvt" role="slider" aria-valuenow="0" aria-valuetext="plain" |
|
200 aria-valuemin="0" aria-valuemax="5">sweetness slider</div> |
|
201 |
|
202 <!-- ARIA scrollbar --> |
|
203 <div id="scrollbar" role="scrollbar" aria-valuenow="5" |
|
204 aria-valuemin="0" aria-valuemax="1000">slider</div> |
|
205 |
|
206 <!-- ARIA combobox --> |
|
207 <input id="combobox" role="combobox" aria-autocomplete="inline"> |
|
208 |
|
209 <!-- progress bar --> |
|
210 <progress id="progress" value="22" max="100"></progress> |
|
211 |
|
212 <!-- input@type="range" --> |
|
213 <input type="range" id="range" min="0" max="10" value="6"> |
|
214 |
|
215 </body> |
|
216 </html> |