|
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 |
|
6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
7 title="Tests: accessible XUL label/description events"> |
|
8 |
|
9 <script type="application/javascript" |
|
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
|
11 |
|
12 <script type="application/javascript" |
|
13 src="../common.js" /> |
|
14 <script type="application/javascript" |
|
15 src="../role.js" /> |
|
16 <script type="application/javascript" |
|
17 src="../events.js" /> |
|
18 |
|
19 <script type="application/javascript"> |
|
20 <![CDATA[ |
|
21 //////////////////////////////////////////////////////////////////////////// |
|
22 // Invokers |
|
23 |
|
24 const kRecreated = 0; |
|
25 const kTextRemoved = 1; |
|
26 const kTextChanged = 2; |
|
27 |
|
28 const kNoValue = 0; |
|
29 |
|
30 /** |
|
31 * Set/remove @value attribute. |
|
32 */ |
|
33 function setValue(aID, aValue, aResult, aOldValue) |
|
34 { |
|
35 this.labelNode = getNode(aID); |
|
36 |
|
37 this.eventSeq = []; |
|
38 |
|
39 switch (aResult) { |
|
40 case kRecreated: |
|
41 this.eventSeq.push(new invokerChecker(EVENT_HIDE, this.labelNode)); |
|
42 this.eventSeq.push(new invokerChecker(EVENT_SHOW, this.labelNode)); |
|
43 break; |
|
44 case kTextRemoved: |
|
45 this.eventSeq.push( |
|
46 new textChangeChecker(this.labelNode, 0, aOldValue.length, |
|
47 aOldValue, false)); |
|
48 break; |
|
49 case kTextChanged: |
|
50 this.eventSeq.push( |
|
51 new textChangeChecker(this.labelNode, 0, aOldValue.length, |
|
52 aOldValue, false)); |
|
53 this.eventSeq.push( |
|
54 new textChangeChecker(this.labelNode, 0, aValue.length, |
|
55 aValue, true)); |
|
56 break; |
|
57 } |
|
58 |
|
59 this.invoke = function setValue_invoke() |
|
60 { |
|
61 if (aValue === kNoValue) |
|
62 this.labelNode.removeAttribute("value"); |
|
63 else |
|
64 this.labelNode.setAttribute("value", aValue); |
|
65 } |
|
66 |
|
67 this.finalCheck = function setValue_finalCheck() |
|
68 { |
|
69 var tree = |
|
70 { LABEL: [ |
|
71 { TEXT_LEAF: [ ] } |
|
72 ] }; |
|
73 testAccessibleTree(aID, tree); |
|
74 } |
|
75 |
|
76 this.getID = function setValue_getID() |
|
77 { |
|
78 return "set @value='" + aValue + "' for label " + prettyName(aID); |
|
79 } |
|
80 } |
|
81 |
|
82 /** |
|
83 * Change @crop attribute. |
|
84 */ |
|
85 function setCrop(aID, aCropValue, aRemovedText, aInsertedText) |
|
86 { |
|
87 this.labelNode = getNode(aID); |
|
88 this.width = this.labelNode.boxObject.width; |
|
89 this.charWidth = this.width / this.labelNode.value.length; |
|
90 |
|
91 this.eventSeq = [ |
|
92 new textChangeChecker(this.labelNode, 0, -1, aRemovedText, false), |
|
93 new textChangeChecker(this.labelNode, 0, -1, aInsertedText, true) |
|
94 ]; |
|
95 |
|
96 this.invoke = function setCrop_invoke() |
|
97 { |
|
98 if (!this.labelNode.hasAttribute("crop")) |
|
99 this.labelNode.width = Math.floor(this.width - 2 * this.charWidth); |
|
100 |
|
101 this.labelNode.setAttribute("crop", aCropValue); |
|
102 } |
|
103 |
|
104 this.getID = function setCrop_finalCheck() |
|
105 { |
|
106 return "set crop " + aCropValue; |
|
107 } |
|
108 } |
|
109 |
|
110 //////////////////////////////////////////////////////////////////////////// |
|
111 // Test |
|
112 |
|
113 gA11yEventDumpToConsole = true; |
|
114 |
|
115 var gQueue = null; |
|
116 function doTest() |
|
117 { |
|
118 gQueue = new eventQueue(); |
|
119 |
|
120 gQueue.push(new setValue("label", "shiroka strana", kRecreated)); |
|
121 gQueue.push(new setValue("label", "?<>!+_", kTextChanged, "shiroka strana")); |
|
122 gQueue.push(new setValue("label", "", kTextRemoved, "?<>!+_")); |
|
123 gQueue.push(new setValue("label", kNoValue, kRecreated)); |
|
124 |
|
125 gQueue.push(new setValue("descr", "hello world", kRecreated)); |
|
126 gQueue.push(new setValue("descr", "si_ya", kTextChanged, "hello world")); |
|
127 gQueue.push(new setValue("descr", "", kTextRemoved, "si_ya")); |
|
128 gQueue.push(new setValue("descr", kNoValue, kRecreated)); |
|
129 |
|
130 if (MAC) { |
|
131 // "valuetocro" -> "…etocro" |
|
132 gQueue.push(new setCrop("croplabel", "left", "valu", "…")); |
|
133 // "…etocro", "val…cro" |
|
134 gQueue.push(new setCrop("croplabel", "center", "…eto", "val…")); |
|
135 } else { |
|
136 // "valuetocro" -> "…uetocro" |
|
137 gQueue.push(new setCrop("croplabel", "left", "val", "…")); |
|
138 // "…uetocro" -> "valu…cro" |
|
139 gQueue.push(new setCrop("croplabel", "center", "…ueto", "valu…")); |
|
140 } |
|
141 |
|
142 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
143 } |
|
144 |
|
145 SimpleTest.waitForExplicitFinish(); |
|
146 addA11yLoadEvent(doTest); |
|
147 ]]> |
|
148 </script> |
|
149 |
|
150 <hbox flex="1" style="overflow: auto;"> |
|
151 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
152 <a target="_blank" |
|
153 href="https://bugzilla.mozilla.org/show_bug.cgi?id=396166" |
|
154 title="xul:label@value accessible should implement nsIAccessibleText"> |
|
155 Bug 396166 |
|
156 </a> |
|
157 <br/> |
|
158 <p id="display"></p> |
|
159 <div id="content" style="display: none"> |
|
160 </div> |
|
161 <pre id="test"> |
|
162 </pre> |
|
163 </body> |
|
164 |
|
165 <vbox flex="1"> |
|
166 <label id="label">hello</label> |
|
167 <description id="descr">hello</description> |
|
168 |
|
169 <hbox> |
|
170 <label id="croplabel" value="valuetocro" |
|
171 style="font-family: monospace;"/> |
|
172 </hbox> |
|
173 </vbox> |
|
174 </hbox> |
|
175 |
|
176 </window> |
|
177 |