Treat undefined target parameter of MovieClip.getURL() like empty string.
[gnash.git] / testsuite / misc-ming.all / hostcmd_htmltest.sh
blob0fffffd5af427558900f1c6e545235c05f767e6b
1 #!/bin/sh
4 # hostcmd_htmltest.sh - HTML-based non-predefined FSCommand invocation
5 # test runner generator
7 # Copyright (C) 2017 Free Software Foundation, Inc.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 # Original author: Nutchanon Wetchasit <Nutchanon.Wetchasit@gmail.com>
26 # The generated test runner checks Gnash (or proprietary player) for:
27 # * Support of FSCommand call via MovieClip.getURL() (bug #46944)
28 # <https://savannah.gnu.org/bugs/?46944>
29 # * Undefined FSCommand parameter passing via MovieClip.getURL() (bug #50393)
30 # <https://savannah.gnu.org/bugs/?50393>
32 # Usage:
33 # ./hostcmd_htmltest.sh <swfversion> <swf>
35 # The <swf> must be a valid URL name and must not contain '&',
36 # as this test generator does not escape SWF file name.
38 # Generated test runner's usage:
39 # Open the generated test HTML file under web browser with JavaScript and
40 # plug-ins enabled, wait few seconds for the test to run. Once finished,
41 # the result will be shown on browser screen, with "There should be NN
42 # tests run" as the last line.
44 # When testing with proprietary player, the test directory might need
45 # to be added as player's trusted location, or tests would fail due to
46 # sandbox violation. Alternative is putting the test directory
47 # on a web server and run the test online.
49 # Note:
50 # The generated test runner does not count checks run inside SWF file
51 # (because there aren't any).
54 # Check for generation parameters
55 while getopts "" name
57 case $name in
59 echo "Usage: $0 <swfversion> <swf>" >&2
60 exit 1;;
61 esac
62 done
63 shift $(($OPTIND - 1))
64 if [ "$#" -ne 2 ]
65 then
66 echo "Usage: $0 <swfversion> <swf>" >&2
67 exit 1
70 # Load generation parameters
71 swfversion=$1
72 shift
73 swf=$1
75 cat << EOF
76 <html>
77 <head>
78 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
79 <title>Host Communication FSCommand Test</title>
80 </head>
81 <body>
82 <div id="flashstate">
83 <noscript>
84 <strong>ERROR: JavaScript is not enabled, tests will not run</strong>
85 </noscript>
86 </div>
87 <object id="player" name="player" data="${swf}" width="320" height="240" type="application/x-shockwave-flash">
88 <param name="movie" value="${swf}">
89 <param name="AllowScriptAccess" value="always">
90 <div>
91 <strong>ERROR: SWF failed to load, tests will not run correctly</strong>
92 </div>
93 </object>
94 <script type="text/javascript">
95 <!--
96 var tested = 0;
97 var passed = 0;
98 var failed = 0;
99 var xpassed = 0;
100 var xfailed = 0;
102 function check(op, msg) {
103 var flashstatus;
104 var failureline;
106 flashstatus=document.getElementById("flashstate");
107 tested++;
108 if(op) {
109 passed++;
110 flashstatus.appendChild(document.createTextNode("PASSED: " + msg));
111 } else {
112 failed++;
113 failureline=document.createElement("strong");
114 failureline.appendChild(document.createTextNode("FAILED: " + msg));
115 flashstatus.appendChild(failureline);
117 flashstatus.appendChild(document.createElement("br"));
120 function check_equals(op1, op2, msg) {
121 var flashstatus;
122 var failureline;
124 flashstatus=document.getElementById("flashstate");
125 tested++;
126 if(op1 == op2) {
127 passed++;
128 flashstatus.appendChild(document.createTextNode("PASSED: " + msg));
129 } else {
130 failed++;
131 failureline=document.createElement("strong");
132 failureline.appendChild(document.createTextNode("FAILED: " + msg + " (\"" + op1 + "\" != \"" + op2 + "\")"));
133 flashstatus.appendChild(failureline);
135 flashstatus.appendChild(document.createElement("br"));
138 function xcheck_equals(op1, op2, msg) {
139 var flashstatus;
140 var successline;
142 flashstatus=document.getElementById("flashstate");
143 tested++;
144 if(op1 == op2) {
145 xpassed++;
146 successline=document.createElement("strong");
147 successline.appendChild(document.createTextNode("XPASSED: "+msg));
148 flashstatus.appendChild(successline);
149 } else {
150 xfailed++;
151 flashstatus.appendChild(document.createTextNode("XFAILED: " + msg + " (\"" + op1 + "\" != \"" + op2 + "\")"));
153 flashstatus.appendChild(document.createElement("br"));
156 function check_error(msg) {
157 var flashstatus;
158 var errorline;
160 flashstatus=document.getElementById("flashstate");
161 errorline=document.createElement("strong");
162 errorline.appendChild(document.createTextNode("ERROR: " + msg));
163 flashstatus.appendChild(errorline);
164 flashstatus.appendChild(document.createElement("br"));
167 function check_totals(total) {
168 check_equals(tested,total,"There should be "+total+" tests run");
171 function xcheck_totals(total) {
172 xcheck_equals(tested,total,"There should be "+total+" tests run");
175 var noname_call = 0;
176 var noarg_call = 0;
177 var stringarg_call = 0;
178 var weirdstringarg_call = 0;
179 var integerarg_call = 0;
180 var floatarg_call = 0;
181 var infinitearg_call = 0;
182 var neginfinitearg_call = 0;
183 var nanarg_call = 0;
184 var booleanarg_call = 0;
185 var nullarg_call = 0;
186 var undefinedarg_call = 0;
187 var arrayarg_call = 0;
188 var objectarg_call = 0;
189 var object_customstringarg_call = 0;
190 var m_noarg_call = 0;
191 var m_stringarg_call = 0;
192 var m_weirdstringarg_call = 0;
193 var m_integerarg_call = 0;
194 var m_floatarg_call = 0;
195 var m_infinitearg_call = 0;
196 var m_neginfinitearg_call = 0;
197 var m_nanarg_call = 0;
198 var m_booleanarg_call = 0;
199 var m_nullarg_call = 0;
200 var m_undefinedarg_call = 0;
201 var m_arrayarg_call = 0;
202 var m_objectarg_call = 0;
203 var m_object_customstringarg_call = 0;
205 function player_DoFSCommand(cmd, arg) {
206 if("" == cmd) {
207 noname_call++;
208 if (noname_call == 1) {
209 check_equals(typeof(arg), "string", "getURL-based no-name FSCommand call with no parameter should pass string-type parameter");
210 check_equals(arg, "", "getURL-based no-name FSCommand call with no-parameter should pass an empty string parameter");
211 } else if(noname_call == 2) {
212 check_equals(typeof(arg), "string", "getURL-based no-name FSCommand call with string parameter should pass string-type parameter");
213 check_equals(arg, "This is a string for empty call", "getURL-based no-name FSCommand call with string parameter should pass a correct string parameter value");
214 } else if(noname_call == 3) {
215 check_equals(typeof(arg), "string", "MovieClip-based no-name FSCommand call with no parameter should pass string-type parameter");
216 check_equals(arg, "", "MovieClip-based no-name FSCommand call with no-parameter should pass an empty string parameter");
217 } else if(noname_call == 4) {
218 check_equals(typeof(arg), "string", "MovieClip-based no-name FSCommand call with string parameter should pass string-type parameter");
219 check_equals(arg, "This is a string for empty call", "MovieClip-based no-name FSCommand call with string parameter should pass a correct string parameter value");
220 } else {
221 check_error("Unknown no-name FSCommand issued: \"" + cmd + "\" parameter \"" + arg + "\"");
223 } else if("noarg" == cmd) {
224 noarg_call++;
225 check_equals(typeof(arg), "string", "getURL-based FSCommand call with no parameter should pass string-type parameter");
226 check_equals(arg, "", "getURL-based FSCommand call with no parameter should pass an empty string parameter value");
227 } else if("stringarg" == cmd) {
228 stringarg_call++;
229 check_equals(typeof(arg), "string", "getURL-based FSCommand call with string parameter should pass string-type parameter");
230 check_equals(arg, "This is a string", "getURL-based FSCommand call with string parameter should pass a correct string parameter value");
231 } else if("weirdstringarg" == cmd) {
232 // Currently, this FSCommand won't run under libgnashplugin,
233 // due to its internal parameter parsing issue.
235 weirdstringarg_call++;
236 xcheck_equals(typeof(arg),"string", "getURL-based FSCommand call with string parameter full of symbols should pass string-type parameter");
237 xcheck_equals(arg,"!@#\$%^&*()_+-={}|[]\\\\:\";\'<>?,./~\`", "Full-of-symbols string parameter value of getURL-based FSCommand call should be passed correctly");
238 } else if("integerarg" == cmd) {
239 integerarg_call++;
240 check_equals(typeof(arg), "string", "getURL-based FSCommand call with integer parameter should pass string-type parameter");
241 check_equals(arg, "9876", "getURL-based FSCommand call should pass a correct string representation of integer parameter value");
242 } else if("floatarg" == cmd) {
243 floatarg_call++;
244 check_equals(typeof(arg), "string", "getURL-based FSCommand call with floating point parameter should pass string-type parameter");
245 check_equals(arg, "9876.5432", "getURL-based FSCommand call should pass a correct string representation of floating point parameter value");
246 } else if("infinitearg" == cmd) {
247 infinitearg_call++;
248 check_equals(typeof(arg), "string", "getURL-based FSCommand call with infinity parameter should pass string-type parameter");
249 check_equals(arg, "Infinity", "getURL-based FSCommand call should pass a correct string representation of infinity parameter");
250 } else if("neginfinitearg" == cmd) {
251 neginfinitearg_call++;
252 check_equals(typeof(arg), "string", "getURL-based FSCommand call with negative infinity parameter should pass string-type parameter");
253 check_equals(arg, "-Infinity", "getURL-based FSCommand call should pass a correct string representation of negative infinity parameter value");
254 } else if("nanarg" == cmd) {
255 nanarg_call++;
256 check_equals(typeof(arg), "string", "getURL-based FSCommand call with not-a-number parameter should pass string-type parameter");
257 check_equals(arg, "NaN", "getURL-based FSCommand call should pass a correct string representation of not-a-number parameter value");
258 } else if("booleanarg" == cmd) {
259 booleanarg_call++;
260 check_equals(typeof(arg), "string", "getURL-based FSCommand call with boolean parameter should pass string-type parameter");
261 check_equals(arg, "true", "getURL-based FSCommand call should pass a correct string representation of boolean parameter value");
262 } else if("nullarg" == cmd) {
263 nullarg_call++;
264 check_equals(typeof(arg), "string", "getURL-based FSCommand call with null parameter should pass string-type parameter");
265 xcheck_equals(arg, "null", "getURL-based FSCommand call should pass a correct string representation of null parameter");
266 } else if("undefinedarg" == cmd) {
267 undefinedarg_call++;
268 check_equals(typeof(arg), "string", "getURL-based FSCommand call with undefined parameter should pass string-type parameter");
269 xcheck_equals(arg, "undefined", "getURL-based FSCommand call should pass a correct string representation of undefined parameter");
270 } else if("arrayarg" == cmd) {
271 arrayarg_call++;
272 check_equals(typeof(arg), "string", "getURL-based FSCommand call with array parameter should pass string-type parameter");
273 check_equals(arg, "The,quick,brown,fox,jumps,over,the,lazy,dog", "Array parameter value of getURL-based FSCommand call should be passed correctly as CSV string");
274 } else if("objectarg" == cmd) {
275 objectarg_call++;
276 check_equals(typeof(arg), "string", "getURL-based FSCommand call with object parameter should pass string-type parameter");
277 check_equals(arg, "[object Object]", "String representation of object parameter of getURL-based FSCommand call should be correctly passed");
278 } else if("object_customstringarg" == cmd) {
279 object_customstringarg_call++;
280 check_equals(typeof(arg), "string", "getURL-based FSCommand call with object parameter bearing custom toString() should pass string-type parameter");
281 check_equals(arg, "This is a custom Object.toString()", "Custom string representation of object parameter of getURL-based FSCommand call should be correctly passed");
282 } else if("m_noarg" == cmd) {
283 m_noarg_call++;
284 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with no parameter should pass string-type parameter");
285 check_equals(arg, "", "MovieClip-based FSCommand call with no parameter should pass an empty string parameter value");
286 } else if("m_stringarg" == cmd) {
287 m_stringarg_call++;
288 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with string parameter should pass string-type parameter");
289 check_equals(arg, "This is a string", "MovieClip-based FSCommand call with string parameter should pass a correct string parameter value");
290 } else if("m_weirdstringarg" == cmd) {
291 // Currently, this FSCommand won't run under libgnashplugin,
292 // due to its internal parameter parsing issue.
294 m_weirdstringarg_call++;
295 xcheck_equals(typeof(arg),"string", "MovieClip-based FSCommand call with string parameter full of symbols should pass string-type parameter");
296 xcheck_equals(arg,"!@#\$%^&*()_+-={}|[]\\\\:\";\'<>?,./~\`", "Full-of-symbols string parameter value of MovieClip-based FSCommand call should be passed correctly");
297 } else if("m_integerarg" == cmd) {
298 m_integerarg_call++;
299 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with integer parameter should pass string-type parameter");
300 check_equals(arg, "9876", "MovieClip-based FSCommand call should pass a correct string representation of integer parameter value");
301 } else if("m_floatarg" == cmd) {
302 m_floatarg_call++;
303 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with floating point parameter should pass string-type parameter");
304 check_equals(arg, "9876.5432", "MovieClip-based FSCommand call should pass a correct string representation of floating point parameter value");
305 } else if("m_infinitearg" == cmd) {
306 m_infinitearg_call++;
307 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with infinity parameter should pass string-type parameter");
308 check_equals(arg, "Infinity", "MovieClip-based FSCommand call should pass a correct string representation of infinity parameter");
309 } else if("m_neginfinitearg" == cmd) {
310 m_neginfinitearg_call++;
311 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with negative infinity parameter should pass string-type parameter");
312 check_equals(arg, "-Infinity", "MovieClip-based FSCommand call should pass a correct string representation of negative infinity parameter value");
313 } else if("m_nanarg" == cmd) {
314 m_nanarg_call++;
315 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with not-a-number parameter should pass string-type parameter");
316 check_equals(arg, "NaN", "MovieClip-based FSCommand call should pass a correct string representation of not-a-number parameter value");
317 } else if("m_booleanarg" == cmd) {
318 m_booleanarg_call++;
319 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with boolean parameter should pass string-type parameter");
320 check_equals(arg, "true", "MovieClip-based FSCommand call should pass a correct string representation of boolean parameter value");
321 } else if("m_nullarg" == cmd) {
322 m_nullarg_call++;
323 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with null parameter should pass string-type parameter");
324 check_equals(arg, "null", "MovieClip-based FSCommand call should pass a correct string representation of null parameter");
325 } else if("m_undefinedarg" == cmd) {
326 m_undefinedarg_call++;
327 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with undefined parameter should pass string-type parameter");
328 check_equals(arg, "", "MovieClip-based FSCommand call should pass an empty string as a representation of undefined parameter");
329 } else if("m_arrayarg" == cmd) {
330 m_arrayarg_call++;
331 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with array parameter should pass string-type parameter");
332 check_equals(arg, "The,quick,brown,fox,jumps,over,the,lazy,dog", "Array parameter value of MovieClip-based FSCommand call should be passed correctly as CSV string");
333 } else if("m_objectarg" == cmd) {
334 m_objectarg_call++;
335 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with object parameter should pass string-type parameter");
336 check_equals(arg, "[object Object]", "String representation of object parameter of MovieClip-based FSCommand call should be correctly passed");
337 } else if("m_object_customstringarg" == cmd) {
338 m_object_customstringarg_call++;
339 check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with object parameter bearing custom toString() should pass string-type parameter");
340 check_equals(arg, "This is a custom Object.toString()", "Custom string representation of object parameter of MovieClip-based FSCommand call should be correctly passed");
341 } else {
342 check_error("Unknown FSCommand issued: \"" + cmd + "\" parameter \"" + arg + "\"");
346 function verify_flash() {
347 check_equals(noname_call, 4, "No-name FSCommand should be called for 4 times");
349 check_equals(noarg_call, 1, "\"noarg\" FSCommand should be called for 1 time");
350 check_equals(stringarg_call, 1, "\"stringarg\" FSCommand should be called for 1 time");
351 xcheck_equals(weirdstringarg_call, 1, "\"weirdstringarg\" FSCommand should be called for 1 time");
352 check_equals(integerarg_call, 1, "\"integerarg\" FSCommand should be called for 1 time");
353 check_equals(floatarg_call, 1, "\"floatarg\" FSCommand should be called for 1 time");
354 check_equals(infinitearg_call, 1, "\"infinitearg\" FSCommand should be called for 1 time");
355 check_equals(neginfinitearg_call, 1, "\"neginfinitearg\" FSCommand should be called for 1 time");
356 check_equals(nanarg_call, 1, "\"nanarg\" FSCommand should be called for 1 time");
357 check_equals(booleanarg_call, 1, "\"booleanarg\" FSCommand should be called for 1 time");
358 check_equals(nullarg_call, 1, "\"nullarg\" FSCommand should be called for 1 time");
359 check_equals(undefinedarg_call, 1, "\"undefinedarg\" FSCommand should be called for 1 time");
360 check_equals(arrayarg_call, 1, "\"arrayarg\" FSCommand should be called for 1 time");
361 check_equals(objectarg_call, 1, "\"objectarg\" FSCommand should be called for 1 time");
362 check_equals(object_customstringarg_call, 1, "\"object_customstringarg\" FSCommand should be called for 1 time");
364 check_equals(m_noarg_call, 1, "\"m_noarg\" FSCommand should be called for 1 time");
365 check_equals(m_stringarg_call, 1, "\"m_stringarg\" FSCommand should be called for 1 time");
366 xcheck_equals(m_weirdstringarg_call, 1, "\"m_weirdstringarg\" FSCommand should be called for 1 time");
367 check_equals(m_integerarg_call, 1, "\"m_integerarg\" FSCommand should be called for 1 time");
368 check_equals(m_floatarg_call, 1, "\"m_floatarg\" FSCommand should be called for 1 time");
369 check_equals(m_infinitearg_call, 1, "\"m_infinitearg\" FSCommand should be called for 1 time");
370 check_equals(m_neginfinitearg_call, 1, "\"m_neginfinitearg\" FSCommand should be called for 1 time");
371 check_equals(m_nanarg_call, 1, "\"m_nanarg\" FSCommand should be called for 1 time");
372 check_equals(m_booleanarg_call, 1, "\"m_booleanarg\" FSCommand should be called for 1 time");
373 check_equals(m_nullarg_call, 1, "\"m_nullarg\" FSCommand should be called for 1 time");
374 check_equals(m_undefinedarg_call, 1, "\"m_undefinedarg\" FSCommand should be called for 1 time");
375 check_equals(m_arrayarg_call, 1, "\"m_arrayarg\" FSCommand should be called for 1 time");
376 check_equals(m_objectarg_call, 1, "\"m_objectarg\" FSCommand should be called for 1 time");
377 check_equals(m_object_customstringarg_call, 1, "\"m_object_customstringarg\" FSCommand should be called for 1 time");
379 xcheck_totals(93);
382 setTimeout("verify_flash()",3000);
383 //-->
384 </script>
385 </body>
386 </html>