diff --git a/tests/tests/swfs/avm1/focus_remove/output.txt b/tests/tests/swfs/avm1/focus_remove/output.txt new file mode 100644 index 000000000000..9dd377cadd30 --- /dev/null +++ b/tests/tests/swfs/avm1/focus_remove/output.txt @@ -0,0 +1,24 @@ +===== clip +Object: _level0.clip +Focus changed + old: null + new: _level0.clip +Focus: _level0.clip +Focus: null +Focus: null +===== text +Object: _level0.clip.text +Focus changed + old: null + new: _level0.clip.text +Focus: _level0.clip.text +Focus: null +Focus: null +===== button +Object: _level0.clip.button +Focus changed + old: null + new: _level0.clip.button +Focus: _level0.clip.button +Focus: null +Focus: null diff --git a/tests/tests/swfs/avm1/focus_remove/test.as b/tests/tests/swfs/avm1/focus_remove/test.as new file mode 100644 index 000000000000..31a2e1ae5865 --- /dev/null +++ b/tests/tests/swfs/avm1/focus_remove/test.as @@ -0,0 +1,48 @@ +var listener = new Object(); +listener.onSetFocus = function(oldFocus, newFocus) { + if (newFocus) { + trace("Focus changed"); + trace(" old: " + oldFocus); + trace(" new: " + newFocus); + } +}; +Selection.addListener(listener); + +function testObject(create, remove) { + var obj = create(); + trace("Object: " + obj); + obj.focusEnabled = true; + Selection.setFocus(obj); + trace("Focus: " + Selection.getFocus()); + remove(); + trace("Focus: " + Selection.getFocus()); + + create(); + trace("Focus: " + Selection.getFocus()); + remove(); +} + +trace("===== clip"); +testObject(function() { + return _root.createEmptyMovieClip("clip", 2); +}, function() { + _root.clip.removeMovieClip(); +}); + +trace("===== text"); +testObject(function() { + var mc = _root.createEmptyMovieClip("clip", 3); + var tf = mc.createTextField("text", 1, 0, 0, 150, 20); + tf.type = "input"; + return tf; +}, function() { + _root.clip.removeMovieClip(); +}); + +trace("===== button"); +testObject(function() { + var mc = _root.attachMovie("CustomButton", "clip", 3); + return mc.button; +}, function() { + _root.clip.removeMovieClip(); +}); diff --git a/tests/tests/swfs/avm1/focus_remove/test.swf b/tests/tests/swfs/avm1/focus_remove/test.swf new file mode 100644 index 000000000000..74e11ef9d52e Binary files /dev/null and b/tests/tests/swfs/avm1/focus_remove/test.swf differ diff --git a/tests/tests/swfs/avm1/focus_remove/test.toml b/tests/tests/swfs/avm1/focus_remove/test.toml new file mode 100644 index 000000000000..cf6123969a1d --- /dev/null +++ b/tests/tests/swfs/avm1/focus_remove/test.toml @@ -0,0 +1 @@ +num_ticks = 1