diff --git a/tests/tests/regression_tests.rs b/tests/tests/regression_tests.rs index 0691c12f8..459524608 100644 --- a/tests/tests/regression_tests.rs +++ b/tests/tests/regression_tests.rs @@ -722,6 +722,7 @@ swf_tests! { (as3_proxy_hasproperty, "avm2/proxy_hasproperty", 1), (as3_proxy_enumeration, "avm2/proxy_enumeration", 1), (as3_nonconflicting_declarations, "avm2/nonconflicting_declarations", 1), + (as3_eventdispatcher_tostring, "avm2/eventdispatcher_tostring", 1), } // TODO: These tests have some inaccuracies currently, so we use approx_eq to test that numeric values are close enough. diff --git a/tests/tests/swfs/avm2/eventdispatcher_tostring/Test.as b/tests/tests/swfs/avm2/eventdispatcher_tostring/Test.as new file mode 100644 index 000000000..1cc5df5d6 --- /dev/null +++ b/tests/tests/swfs/avm2/eventdispatcher_tostring/Test.as @@ -0,0 +1,34 @@ +package { + public class Test { + } +} + +import flash.events.EventDispatcher; + +trace("///Object.prototype.toString = function() { /* ... */ };"); +Object.prototype.toString = (function (old_ts) { + return function () { + trace("///(Object.prototype.toString called)"); + return old_ts.apply(this, arguments); + } +}(Object.prototype.toString)); + +trace("///var ed = new EventDispatcher();"); +var ed = new EventDispatcher(); + +trace("///ed.toString();"); +trace(ed.toString()); + +class CustomDispatch extends EventDispatcher { + public override function toString() : String { + trace("///(CustomDispatch.prototype.toString called);"); + + return super.toString(); + } +} + +trace("///var cust = new CustomDispatch();"); +var cust = new CustomDispatch(); + +trace("///cust.toString();"); +trace(cust.toString()); \ No newline at end of file diff --git a/tests/tests/swfs/avm2/eventdispatcher_tostring/output.txt b/tests/tests/swfs/avm2/eventdispatcher_tostring/output.txt new file mode 100644 index 000000000..e81b83503 --- /dev/null +++ b/tests/tests/swfs/avm2/eventdispatcher_tostring/output.txt @@ -0,0 +1,10 @@ +///Object.prototype.toString = function() { /* ... */ }; +///var ed = new EventDispatcher(); +///ed.toString(); +///(Object.prototype.toString called) +[object EventDispatcher] +///var cust = new CustomDispatch(); +///cust.toString(); +///(CustomDispatch.prototype.toString called); +///(Object.prototype.toString called) +[object CustomDispatch] diff --git a/tests/tests/swfs/avm2/eventdispatcher_tostring/test.fla b/tests/tests/swfs/avm2/eventdispatcher_tostring/test.fla new file mode 100644 index 000000000..b27a5e649 Binary files /dev/null and b/tests/tests/swfs/avm2/eventdispatcher_tostring/test.fla differ diff --git a/tests/tests/swfs/avm2/eventdispatcher_tostring/test.swf b/tests/tests/swfs/avm2/eventdispatcher_tostring/test.swf new file mode 100644 index 000000000..607ae9a50 Binary files /dev/null and b/tests/tests/swfs/avm2/eventdispatcher_tostring/test.swf differ