diff --git a/tests/tests/swfs/avm1/focus_keyboard_press/input.json b/tests/tests/swfs/avm1/focus_keyboard_press/input.json new file mode 100644 index 0000000000000..707d0bc0b8e29 --- /dev/null +++ b/tests/tests/swfs/avm1/focus_keyboard_press/input.json @@ -0,0 +1,61 @@ +[ + { "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + { "type": "MouseMove", "pos": [5, 5] }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + + { "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, + + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + { "type": "MouseMove", "pos": [5, 5] }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + + { "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, + + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + { "type": "MouseMove", "pos": [5, 5] }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + + { "type": "KeyDown", "key_code": 27 }, { "type": "KeyUp", "key_code": 27 }, + + { "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + { "type": "MouseMove", "pos": [5, 5] }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + + { "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, + + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + { "type": "MouseMove", "pos": [5, 5] }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + + { "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, + + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, + { "type": "MouseMove", "pos": [5, 5] }, + { "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 } +] diff --git a/tests/tests/swfs/avm1/focus_keyboard_press/output.txt b/tests/tests/swfs/avm1/focus_keyboard_press/output.txt new file mode 100644 index 0000000000000..0b4b98939d930 --- /dev/null +++ b/tests/tests/swfs/avm1/focus_keyboard_press/output.txt @@ -0,0 +1,60 @@ +Focus at: _level0.text +Tab pressed +Focus at: _level0.clip +_level0.clip.onKeyUp: 9 +_level0.clip.onKeyDown: 13 +_level0.clip.onPress: 13 +_level0.clip.onRelease: 13 +_level0.clip.onKeyUp: 13 +_level0.clip.onKeyDown: 32 +_level0.clip.onPress: 32 +_level0.clip.onRelease: 32 +_level0.clip.onKeyUp: 32 +_level0.clip.onKeyDown: 65 +_level0.clip.onKeyUp: 65 +_level0.clip.onMouseMove +Tab pressed +Focus at: _level0.button +_level0.button.onKeyUp: 9 +_level0.button.onKeyDown: 13 +press +_level0.button.onPress: 13 +release +_level0.button.onRelease: 13 +_level0.button.onKeyUp: 13 +_level0.button.onKeyDown: 32 +press +_level0.button.onPress: 32 +release +_level0.button.onRelease: 32 +_level0.button.onKeyUp: 32 +_level0.button.onKeyDown: 65 +_level0.button.onKeyUp: 65 +_level0.clip.onMouseMove +Tab pressed +Focus at: _level0.text +_level0.clip.onMouseMove +Escape pressed +Tab pressed +Focus at: _level0.clip +_level0.clip.onKeyUp: 9 +_level0.clip.onKeyDown: 13 +_level0.clip.onKeyUp: 13 +_level0.clip.onKeyDown: 32 +_level0.clip.onKeyUp: 32 +_level0.clip.onKeyDown: 65 +_level0.clip.onKeyUp: 65 +_level0.clip.onMouseMove +Tab pressed +Focus at: _level0.button +_level0.button.onKeyUp: 9 +_level0.button.onKeyDown: 13 +_level0.button.onKeyUp: 13 +_level0.button.onKeyDown: 32 +_level0.button.onKeyUp: 32 +_level0.button.onKeyDown: 65 +_level0.button.onKeyUp: 65 +_level0.clip.onMouseMove +Tab pressed +Focus at: _level0.text +_level0.clip.onMouseMove diff --git a/tests/tests/swfs/avm1/focus_keyboard_press/test.as b/tests/tests/swfs/avm1/focus_keyboard_press/test.as new file mode 100644 index 0000000000000..7bad4c548506a --- /dev/null +++ b/tests/tests/swfs/avm1/focus_keyboard_press/test.as @@ -0,0 +1,39 @@ +var listener = new Object(); +listener.onSetFocus = function(oldFocus, newFocus) { + trace("Focus at: " + newFocus); +}; +listener.onKeyDown = function() { + if (Key.getCode() == 27) { + trace("Escape pressed"); + _focusrect = false; + Selection.setFocus(text); + } + if (Key.getCode() == 9) { + trace("Tab pressed"); + } +}; +Selection.addListener(listener); +Key.addListener(listener); + +function setHandlers(obj) { + obj.onRelease = function () { trace(obj + ".onRelease: " + Key.getCode()); } + obj.onKeyDown = function () { trace(obj + ".onKeyDown: " + Key.getCode()); } + obj.onKeyUp = function () { trace(obj + ".onKeyUp: " + Key.getCode()); } + obj.onPress = function () { trace(obj + ".onPress: " + Key.getCode()); } + obj.onReleaseOutside = function () { trace(obj + ".onReleaseOutside"); } + obj.onMouseDown = function () { trace(obj + ".onMouseDown") } + obj.onMouseUp = function () { trace(obj + ".onMouseUp") } + obj.onMouseMove = function () { trace(obj + ".onMouseMove") } +} + +clip.tabEnabled = true; +clip.tabIndex = 1; +setHandlers(clip); +button.tabEnabled = true; +button.tabIndex = 2; +setHandlers(button); +text.tabEnabled = true; +text.tabIndex = 3; +setHandlers(text); + +Selection.setFocus(text); diff --git a/tests/tests/swfs/avm1/focus_keyboard_press/test.swf b/tests/tests/swfs/avm1/focus_keyboard_press/test.swf new file mode 100644 index 0000000000000..de9d3758f453a Binary files /dev/null and b/tests/tests/swfs/avm1/focus_keyboard_press/test.swf differ diff --git a/tests/tests/swfs/avm1/focus_keyboard_press/test.toml b/tests/tests/swfs/avm1/focus_keyboard_press/test.toml new file mode 100644 index 0000000000000..cf6123969a1d6 --- /dev/null +++ b/tests/tests/swfs/avm1/focus_keyboard_press/test.toml @@ -0,0 +1 @@ +num_ticks = 1