From: Nutchanon Wetchasit <Nutchanon.Wetchasit@gmail.com>
Subject: Add automated tests on function-type FSCommand parameter passing.
Bug: https://savannah.gnu.org/bugs/?50393

See bug #50393 <https://savannah.gnu.org/bugs/?50393>

diff --git a/testsuite/misc-ming.all/hostcmd.as b/testsuite/misc-ming.all/hostcmd.as
index 0786790..748124c 100644
--- a/testsuite/misc-ming.all/hostcmd.as
+++ b/testsuite/misc-ming.all/hostcmd.as
@@ -36,6 +36,7 @@
 var arrayarg;
 var objectarg;
 var object_customstringarg;
+var functionarg;
 
 trace("STARTOFTEST");
 getURL("FSCommand:");
@@ -60,6 +61,10 @@ object_customstringarg.toString = function():String {
 	return "This is a custom Object.toString()";
 };
 getURL("FSCommand:object_customstringarg", object_customstringarg);
+functionarg = function() {
+	trace("This code should not run!");
+};
+getURL("FSCommand:functionarg", functionarg);
 
 this.getURL("FSCommand:");
 this.getURL("FSCommand:", "This is a string for empty call");
@@ -77,4 +82,5 @@ this.getURL("FSCommand:m_undefinedarg", undefined);
 this.getURL("FSCommand:m_arrayarg", arrayarg);
 this.getURL("FSCommand:m_objectarg", objectarg);
 this.getURL("FSCommand:m_object_customstringarg", object_customstringarg);
+this.getURL("FSCommand:m_functionarg", functionarg);
 trace("ENDOFTEST");
diff --git a/testsuite/misc-ming.all/hostcmd_htmltest.sh b/testsuite/misc-ming.all/hostcmd_htmltest.sh
index cdc5216..354b243 100644
--- a/testsuite/misc-ming.all/hostcmd_htmltest.sh
+++ b/testsuite/misc-ming.all/hostcmd_htmltest.sh
@@ -187,6 +187,7 @@ cat << EOF
 	var arrayarg_call = 0;
 	var objectarg_call = 0;
 	var object_customstringarg_call = 0;
+	var functionarg_call = 0;
 	var m_noarg_call = 0;
 	var m_stringarg_call = 0;
 	var m_weirdstringarg_call = 0;
@@ -201,6 +202,7 @@ cat << EOF
 	var m_arrayarg_call = 0;
 	var m_objectarg_call = 0;
 	var m_object_customstringarg_call = 0;
+	var m_functionarg_call = 0;
 
 	function player_DoFSCommand(cmd, arg) {
 		if("" == cmd) {
@@ -283,6 +285,10 @@ cat << EOF
 			object_customstringarg_call++;
 			check_equals(typeof(arg), "string", "getURL-based FSCommand call with object parameter bearing custom toString() should pass string-type parameter");
 			check_equals(arg, "This is a custom Object.toString()", "Custom string representation of object parameter of getURL-based FSCommand call should be correctly passed");
+		} else if("functionarg" == cmd) {
+			functionarg_call++;
+			check_equals(typeof(arg), "string", "getURL-based FSCommand call with function parameter should pass string-type parameter");
+			check_equals(arg, "[type Function]", "String representation of function parameter of getURL-based FSCommand call should be correctly passed");
 		} else if("m_noarg" == cmd) {
 			m_noarg_call++;
 			check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with no parameter should pass string-type parameter");
@@ -342,6 +348,10 @@ cat << EOF
 			m_object_customstringarg_call++;
 			check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with object parameter bearing custom toString() should pass string-type parameter");
 			check_equals(arg, "This is a custom Object.toString()", "Custom string representation of object parameter of MovieClip-based FSCommand call should be correctly passed");
+		} else if("m_functionarg" == cmd) {
+			m_functionarg_call++;
+			check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with function parameter should pass string-type parameter");
+			check_equals(arg, "[type Function]", "String representation of function parameter of MovieClip-based FSCommand call should be correctly passed");
 		} else {
 			check_error("Unknown FSCommand issued: \"" + cmd + "\" parameter \"" + arg + "\"");
 		}
@@ -364,6 +374,7 @@ cat << EOF
 		check_equals(arrayarg_call, 1, "\"arrayarg\" FSCommand should be called for 1 time");
 		check_equals(objectarg_call, 1, "\"objectarg\" FSCommand should be called for 1 time");
 		check_equals(object_customstringarg_call, 1, "\"object_customstringarg\" FSCommand should be called for 1 time");
+		check_equals(m_functionarg_call, 1, "\"functionarg\" FSCommand should be called for 1 time");
 
 		check_equals(m_noarg_call, 1, "\"m_noarg\" FSCommand should be called for 1 time");
 		check_equals(m_stringarg_call, 1, "\"m_stringarg\" FSCommand should be called for 1 time");
@@ -379,8 +390,9 @@ cat << EOF
 		check_equals(m_arrayarg_call, 1, "\"m_arrayarg\" FSCommand should be called for 1 time");
 		check_equals(m_objectarg_call, 1, "\"m_objectarg\" FSCommand should be called for 1 time");
 		check_equals(m_object_customstringarg_call, 1, "\"m_object_customstringarg\" FSCommand should be called for 1 time");
+		check_equals(m_functionarg_call, 1, "\"m_functionarg\" FSCommand should be called for 1 time");
 
-		xcheck_totals(93);
+		xcheck_totals(99);
 	}
 
 	setTimeout("verify_flash()",3000);
diff --git a/testsuite/misc-ming.all/hostcmd_testrunner.sh b/testsuite/misc-ming.all/hostcmd_testrunner.sh
index 1946203..01bc0c7 100644
--- a/testsuite/misc-ming.all/hostcmd_testrunner.sh
+++ b/testsuite/misc-ming.all/hostcmd_testrunner.sh
@@ -260,6 +260,10 @@ check_equals "\$LINE" '<invoke name="fsCommand" returntype="xml"><arguments><str
 read_timeout LINE \$READTIMEOUT <&3
 check_equals "\$LINE" '<invoke name="fsCommand" returntype="xml"><arguments><string>object_customstringarg</string><string>This is a custom Object.toString()</string></arguments></invoke>' "Gnash should correctly pass getURL-based FSCommand call with object parameter bearing custom toString()"
 
+# Read for function-parameter FSCommand statement
+read_timeout LINE \$READTIMEOUT <&3
+check_equals "\$LINE" '<invoke name="fsCommand" returntype="xml"><arguments><string>functionarg</string><string>[type Function]</string></arguments></invoke>' "Gnash should correctly pass getURL-based FSCommand call with function parameter"
+
 #
 # MovieClip-based FSCommand tests
 #
@@ -328,6 +332,10 @@ check_equals "\$LINE" '<invoke name="fsCommand" returntype="xml"><arguments><str
 read_timeout LINE \$READTIMEOUT <&3
 check_equals "\$LINE" '<invoke name="fsCommand" returntype="xml"><arguments><string>m_object_customstringarg</string><string>This is a custom Object.toString()</string></arguments></invoke>' "Gnash should correctly pass MovieClip-based FSCommand call with object parameter bearing custom toString()"
 
+# Read for function-parameter FSCommand statement
+read_timeout LINE \$READTIMEOUT <&3
+check_equals "\$LINE" '<invoke name="fsCommand" returntype="xml"><arguments><string>m_functionarg</string><string>[type Function]</string></arguments></invoke>' "Gnash should correctly pass MovieClip-based FSCommand call with function parameter"
+
 # Close pipes
 exec 3<&-
 exec 4<&-
@@ -337,7 +345,7 @@ kill \$GNASHPID
 wait \$GNASHPID
 
 # Check for total number of test run
-check_totals "33" "There should be 33 tests run"
+check_totals "35" "There should be 35 tests run"
 
 # Remove temporary files
 rm "\$LOGFILE"
