|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=408231 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 408231</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408231">Mozilla Bug 408231</a> |
|
13 <p id="display"></p> |
|
14 <div id="content" style="display: none"> |
|
15 |
|
16 </div> |
|
17 <pre id="test"> |
|
18 <script class="testbody" type="text/javascript"> |
|
19 |
|
20 /** Test for Bug 408231 **/ |
|
21 |
|
22 var commandEnabledResults = [ |
|
23 ["contentReadOnly", "true"], |
|
24 ["copy", "false"], |
|
25 ["createlink", "true"], |
|
26 ["cut", "false"], |
|
27 ["decreasefontsize", "true"], |
|
28 ["delete", "true"], |
|
29 ["fontname", "true"], |
|
30 ["fontsize", "true"], |
|
31 ["formatblock", "true"], |
|
32 ["heading", "true"], |
|
33 ["hilitecolor", "true"], |
|
34 ["increasefontsize", "true"], |
|
35 ["indent", "true"], |
|
36 ["inserthorizontalrule", "true"], |
|
37 ["inserthtml", "true"], |
|
38 ["insertimage", "true"], |
|
39 ["insertorderedlist", "true"], |
|
40 ["insertunorderedlist", "true"], |
|
41 ["insertparagraph", "true"], |
|
42 ["italic", "true"], |
|
43 ["justifycenter", "true"], |
|
44 ["justifyfull", "true"], |
|
45 ["justifyleft", "true"], |
|
46 ["justifyright", "true"], |
|
47 ["outdent", "true"], |
|
48 //["paste", "true"], |
|
49 ["redo", "false"], |
|
50 ["removeformat", "true"], |
|
51 ["selectall", "true"], |
|
52 ["strikethrough", "true"], |
|
53 ["styleWithCSS", "true"], |
|
54 ["subscript", "true"], |
|
55 ["superscript", "true"], |
|
56 ["underline", "true"], |
|
57 ["undo", "false"], |
|
58 ["unlink", "true"], |
|
59 ["not-a-command", "false"] |
|
60 ]; |
|
61 |
|
62 var commandIndetermResults = [ |
|
63 ["contentReadOnly", "false"], |
|
64 ["copy", "false"], |
|
65 ["createlink", "false"], |
|
66 ["cut", "false"], |
|
67 ["decreasefontsize", "false"], |
|
68 ["delete", "false"], |
|
69 ["fontname", "false"], |
|
70 ["fontsize", "false"], |
|
71 ["formatblock", "false"], |
|
72 ["heading", "false"], |
|
73 ["hilitecolor", "false"], |
|
74 ["increasefontsize", "false"], |
|
75 ["indent", "false"], |
|
76 ["inserthorizontalrule", "false"], |
|
77 ["inserthtml", "false"], |
|
78 ["insertimage", "false"], |
|
79 ["insertorderedlist", "false"], |
|
80 ["insertunorderedlist", "false"], |
|
81 ["insertparagraph", "false"], |
|
82 ["italic", "false"], |
|
83 ["justifycenter", "false"], |
|
84 ["justifyfull", "false"], |
|
85 ["justifyleft", "false"], |
|
86 ["justifyright", "false"], |
|
87 ["outdent", "false"], |
|
88 //["paste", "false"], |
|
89 ["redo", "false"], |
|
90 ["removeformat", "false"], |
|
91 ["selectall", "false"], |
|
92 ["strikethrough", "false"], |
|
93 ["styleWithCSS", "false"], |
|
94 ["subscript", "false"], |
|
95 ["superscript", "false"], |
|
96 ["underline", "false"], |
|
97 ["undo", "false"], |
|
98 ["unlink", "false"], |
|
99 ["not-a-command", "false"] |
|
100 ]; |
|
101 |
|
102 var commandStateResults = [ |
|
103 ["contentReadOnly", "false"], |
|
104 ["copy", "false"], |
|
105 ["createlink", "false"], |
|
106 ["cut", "false"], |
|
107 ["decreasefontsize", "false"], |
|
108 ["delete", "false"], |
|
109 ["fontname", "false"], |
|
110 ["fontsize", "false"], |
|
111 ["formatblock", "false"], |
|
112 ["heading", "false"], |
|
113 ["hilitecolor", "false"], |
|
114 ["increasefontsize", "false"], |
|
115 ["indent", "false"], |
|
116 ["inserthorizontalrule", "false"], |
|
117 ["inserthtml", "false"], |
|
118 ["insertimage", "false"], |
|
119 ["insertorderedlist", "false"], |
|
120 ["insertunorderedlist", "false"], |
|
121 ["insertparagraph", "false"], |
|
122 ["italic", "false"], |
|
123 ["justifycenter", "false"], |
|
124 ["justifyfull", "false"], |
|
125 ["justifyleft", "true"], |
|
126 ["justifyright", "false"], |
|
127 ["outdent", "false"], |
|
128 //["paste", "false"], |
|
129 ["redo", "false"], |
|
130 ["removeformat", "false"], |
|
131 ["selectall", "false"], |
|
132 ["strikethrough", "false"], |
|
133 ["styleWithCSS", "false"], |
|
134 ["subscript", "false"], |
|
135 ["superscript", "false"], |
|
136 ["underline", "false"], |
|
137 ["undo", "false"], |
|
138 ["unlink", "false"], |
|
139 ["not-a-command", "false"] |
|
140 ]; |
|
141 |
|
142 var commandValueResults = [ |
|
143 ["contentReadOnly", ""], |
|
144 ["copy", ""], |
|
145 ["createlink", ""], |
|
146 ["cut", ""], |
|
147 ["decreasefontsize", ""], |
|
148 ["delete", ""], |
|
149 ["fontname", ""], |
|
150 ["fontsize", ""], |
|
151 ["formatblock", ""], |
|
152 ["heading", ""], |
|
153 ["hilitecolor", "transparent"], |
|
154 ["increasefontsize", ""], |
|
155 ["indent", ""], |
|
156 ["inserthorizontalrule", ""], |
|
157 ["inserthtml", ""], |
|
158 ["insertimage", ""], |
|
159 ["insertorderedlist", ""], |
|
160 ["insertunorderedlist", ""], |
|
161 ["insertparagraph", ""], |
|
162 ["italic", ""], |
|
163 ["justifycenter", "left"], |
|
164 ["justifyfull", "left"], |
|
165 ["justifyleft", "left"], |
|
166 ["justifyright", "left"], |
|
167 ["outdent", ""], |
|
168 //["paste", ""], |
|
169 ["redo", ""], |
|
170 ["removeformat", ""], |
|
171 ["selectall", ""], |
|
172 ["strikethrough", ""], |
|
173 ["styleWithCSS", ""], |
|
174 ["subscript", ""], |
|
175 ["superscript", ""], |
|
176 ["underline", ""], |
|
177 ["undo", ""], |
|
178 ["unlink", ""], |
|
179 ["not-a-command", ""], |
|
180 ]; |
|
181 |
|
182 |
|
183 function callQueryCommandEnabled(cmdName) { |
|
184 var result; |
|
185 try { |
|
186 result = '' + document.queryCommandEnabled( cmdName ); |
|
187 } catch( error ) { |
|
188 result = 'name' in error ? error.name : 'exception'; |
|
189 } |
|
190 return result; |
|
191 } |
|
192 |
|
193 function callQueryCommandIndeterm(cmdName) { |
|
194 var result; |
|
195 try { |
|
196 result = '' + document.queryCommandIndeterm( cmdName ); |
|
197 } catch( error ) { |
|
198 result = 'name' in error ? error.name : 'exception'; |
|
199 } |
|
200 return result; |
|
201 } |
|
202 |
|
203 function callQueryCommandState(cmdName) { |
|
204 var result; |
|
205 try { |
|
206 result = '' + document.queryCommandState( cmdName ); |
|
207 } catch( error ) { |
|
208 result = 'name' in error ? error.name : 'exception'; |
|
209 } |
|
210 return result; |
|
211 } |
|
212 |
|
213 function callQueryCommandValue(cmdName) { |
|
214 var result; |
|
215 try { |
|
216 result = '' + document.queryCommandValue( cmdName ); |
|
217 } catch( error ) { |
|
218 result = 'name' in error ? error.name : 'exception'; |
|
219 } |
|
220 return result; |
|
221 } |
|
222 |
|
223 function testQueryCommand(expectedResults, fun, funName) { |
|
224 for (i=0; i<expectedResults.length; i++) { |
|
225 var commandName = expectedResults[i][0]; |
|
226 var expectedResult = expectedResults[i][1]; |
|
227 var result = fun(commandName); |
|
228 ok(result == expectedResult, funName + '('+commandName+') result=' +result+ ' expected=' + expectedResult); |
|
229 } |
|
230 } |
|
231 |
|
232 function runTests() { |
|
233 document.designMode='on'; |
|
234 window.getSelection().collapse(document.body, 0); |
|
235 testQueryCommand(commandEnabledResults, callQueryCommandEnabled, "queryCommandEnabled"); |
|
236 testQueryCommand(commandIndetermResults, callQueryCommandIndeterm, "queryCommandIndeterm"); |
|
237 testQueryCommand(commandStateResults, callQueryCommandState, "queryCommandState"); |
|
238 testQueryCommand(commandValueResults, callQueryCommandValue, "queryCommandValue"); |
|
239 document.designMode='off'; |
|
240 SimpleTest.finish(); |
|
241 } |
|
242 |
|
243 window.onload = runTests; |
|
244 SimpleTest.waitForExplicitFinish(); |
|
245 |
|
246 </script> |
|
247 </pre> |
|
248 </body> |
|
249 </html> |
|
250 |