|
1 <html> |
|
2 |
|
3 <head> |
|
4 <title>ARIA state change event 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 |
|
12 <script type="application/javascript" |
|
13 src="../common.js"></script> |
|
14 <script type="application/javascript" |
|
15 src="../role.js"></script> |
|
16 <script type="application/javascript" |
|
17 src="../states.js"></script> |
|
18 <script type="application/javascript" |
|
19 src="../events.js"></script> |
|
20 |
|
21 <script type="application/javascript"> |
|
22 |
|
23 |
|
24 /** |
|
25 * Do tests. |
|
26 */ |
|
27 var gQueue = null; |
|
28 |
|
29 //gA11yEventDumpID = "eventdump"; // debugging |
|
30 //gA11yEventDumpToConsole = true; // debugging |
|
31 |
|
32 function expandNode(aID, aIsExpanded) |
|
33 { |
|
34 this.DOMNode = getNode(aID); |
|
35 |
|
36 this.eventSeq = [ |
|
37 new expandedStateChecker(aIsExpanded, this.DOMNode) |
|
38 ]; |
|
39 |
|
40 this.invoke = function expandNode_invoke() |
|
41 { |
|
42 this.DOMNode.setAttribute("aria-expanded", |
|
43 (aIsExpanded ? "true" : "false")); |
|
44 }; |
|
45 |
|
46 this.getID = function expandNode_getID() |
|
47 { |
|
48 return prettyName(aID) + " aria-expanded changed to '" + aIsExpanded + "'"; |
|
49 }; |
|
50 } |
|
51 |
|
52 function busyify(aID, aIsBusy) |
|
53 { |
|
54 this.DOMNode = getNode(aID); |
|
55 |
|
56 this.eventSeq = [ |
|
57 new stateChangeChecker(STATE_BUSY, kOrdinalState, aIsBusy, this.DOMNode) |
|
58 ]; |
|
59 |
|
60 this.invoke = function busyify_invoke() |
|
61 { |
|
62 this.DOMNode.setAttribute("aria-busy", (aIsBusy ? "true" : "false")); |
|
63 }; |
|
64 |
|
65 this.getID = function busyify_getID() |
|
66 { |
|
67 return prettyName(aID) + " aria-busy changed to '" + aIsBusy + "'"; |
|
68 }; |
|
69 } |
|
70 |
|
71 function setAttrOfMixedType(aID, aAttr, aState, aValue) |
|
72 { |
|
73 this.DOMNode = getNode(aID); |
|
74 |
|
75 this.eventSeq = [ |
|
76 new stateChangeChecker(aState, kOrdinalState, |
|
77 aValue == "true", this.DOMNode) |
|
78 ]; |
|
79 |
|
80 if (hasState(aID, STATE_MIXED) || aValue == "mixed") { |
|
81 this.eventSeq.push( |
|
82 new stateChangeChecker(STATE_MIXED, kOrdinalState, |
|
83 aValue == "mixed", this.DOMNode) |
|
84 ); |
|
85 } |
|
86 |
|
87 this.invoke = function setAttrOfMixedType_invoke() |
|
88 { |
|
89 this.DOMNode.setAttribute(aAttr, aValue); |
|
90 }; |
|
91 |
|
92 this.getID = function setAttrOfMixedType_getID() |
|
93 { |
|
94 return prettyName(aID) + " " + aAttr + " changed to '" + aValue + "'"; |
|
95 }; |
|
96 } |
|
97 |
|
98 function setPressed(aID, aValue) |
|
99 { |
|
100 this.__proto__ = |
|
101 new setAttrOfMixedType(aID, "aria-pressed", STATE_PRESSED, aValue); |
|
102 } |
|
103 |
|
104 function setChecked(aID, aValue) |
|
105 { |
|
106 this.__proto__ = |
|
107 new setAttrOfMixedType(aID, "aria-checked", STATE_CHECKED, aValue); |
|
108 } |
|
109 |
|
110 function buildQueueForAttrOfMixedType(aQueue, aID, aInvokerFunc) |
|
111 { |
|
112 var list = [ "", "undefined", "false", "true", "mixed" ]; |
|
113 for (var i = 0; i < list.length; i++) { |
|
114 for (var j = i + 1; j < list.length; j++) { |
|
115 // XXX: changes from/to "undefined"/"" shouldn't fire state change |
|
116 // events, bug 472142. |
|
117 aQueue.push(new aInvokerFunc(aID, list[i])); |
|
118 aQueue.push(new aInvokerFunc(aID, list[j])); |
|
119 } |
|
120 } |
|
121 } |
|
122 |
|
123 function doTests() |
|
124 { |
|
125 gQueue = new eventQueue(); |
|
126 |
|
127 gQueue.push(new expandNode("section", true)); |
|
128 gQueue.push(new expandNode("section", false)); |
|
129 gQueue.push(new expandNode("div", true)); |
|
130 gQueue.push(new expandNode("div", false)); |
|
131 |
|
132 gQueue.push(new busyify("aria_doc", true)); |
|
133 gQueue.push(new busyify("aria_doc", false)); |
|
134 |
|
135 buildQueueForAttrOfMixedType(gQueue, "pressable", setPressed); |
|
136 buildQueueForAttrOfMixedType(gQueue, "pressable_native", setPressed); |
|
137 buildQueueForAttrOfMixedType(gQueue, "checkable", setChecked); |
|
138 |
|
139 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
140 } |
|
141 |
|
142 SimpleTest.waitForExplicitFinish(); |
|
143 addA11yLoadEvent(doTests); |
|
144 </script> |
|
145 </head> |
|
146 |
|
147 <body> |
|
148 |
|
149 <a target="_blank" |
|
150 href="https://bugzilla.mozilla.org/show_bug.cgi?id=551684" |
|
151 title="No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets"> |
|
152 Mozilla Bug 551684 |
|
153 </a><br> |
|
154 <a target="_blank" |
|
155 href="https://bugzilla.mozilla.org/show_bug.cgi?id=648133" |
|
156 title="fire state change event for aria-busy" |
|
157 Mozilla Bug 648133 |
|
158 </a><br> |
|
159 <a target="_blank" |
|
160 href="https://bugzilla.mozilla.org/show_bug.cgi?id=467143" |
|
161 title="mixed state change event is fired for focused accessible only" |
|
162 Mozilla Bug 467143 |
|
163 </a> |
|
164 <a target="_blank" |
|
165 href="https://bugzilla.mozilla.org/show_bug.cgi?id=989958" |
|
166 title="Pressed state is not exposed on a button element with aria-pressed attribute" |
|
167 Mozilla Bug 989958 |
|
168 </a> |
|
169 |
|
170 <p id="display"></p> |
|
171 <div id="content" style="display: none"></div> |
|
172 <pre id="test"> |
|
173 </pre> |
|
174 <div id="eventdump"></div> |
|
175 |
|
176 <!-- aria-expanded --> |
|
177 <div id="section" role="section" aria-expanded="false">expandable section</div> |
|
178 <div id="div" aria-expanded="false">expandable native div</div> |
|
179 |
|
180 <!-- aria-busy --> |
|
181 <div id="aria_doc" role="document" tabindex="0">A document</div> |
|
182 |
|
183 <!-- aria-pressed --> |
|
184 <div id="pressable" role="button"></div> |
|
185 <button id="pressable_native"></button> |
|
186 |
|
187 <!-- aria-checked --> |
|
188 <div id="checkable" role="checkbox"></div> |
|
189 </body> |
|
190 </html> |