diff --git a/tests/tests/swfs/avm1/button_keypress_vs_tab/input.json b/tests/tests/swfs/avm1/button_keypress_vs_tab/input.json new file mode 100644 index 000000000000..d2d3e472eff9 --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_tab/input.json @@ -0,0 +1,16 @@ +[ + { "type": "KeyDown", "key_code": 9 }, + { "type": "TextInput", "codepoint": "\t" }, + { "type": "KeyUp", "key_code": 9 }, + { "type": "KeyDown", "key_code": 9 }, + { "type": "TextInput", "codepoint": "\t" }, + { "type": "KeyUp", "key_code": 9 }, + { "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": 9 }, + { "type": "TextInput", "codepoint": "\t" }, + { "type": "KeyUp", "key_code": 9 } +] diff --git a/tests/tests/swfs/avm1/button_keypress_vs_tab/output.txt b/tests/tests/swfs/avm1/button_keypress_vs_tab/output.txt new file mode 100644 index 000000000000..a8dcc1cb5b00 --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_tab/output.txt @@ -0,0 +1,20 @@ +Focus changed: null -> _level0.button1 +button.onKeyDown: 9 +Tab pressed +Focus changed: _level0.button1 -> _level0.button2 +button.onKeyUp: 9 +button.onKeyDown: 9 +Tab pressed +Focus changed: _level0.button2 -> _level0.button1 +button.onKeyUp: 9 +button.onKeyDown: 27 +===== Escape pressed +button.onKeyUp: 27 +button.onKeyDown: 9 +Tab pressed +keyPress 3 tab +button.onKeyUp: 9 +button.onKeyDown: 9 +Tab pressed +keyPress 3 tab +button.onKeyUp: 9 diff --git a/tests/tests/swfs/avm1/button_keypress_vs_tab/test.as b/tests/tests/swfs/avm1/button_keypress_vs_tab/test.as new file mode 100644 index 000000000000..a7adcb0e9511 --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_tab/test.as @@ -0,0 +1,35 @@ +var listener = new Object(); +listener.onKeyDown = function() { + if (Key.getCode() == 9) { + trace("Tab pressed"); + } + if (Key.getCode() == 27) { + trace("===== Escape pressed"); + + button2._visible = false; + button3._visible = true; + Selection.setFocus(button1); + } +}; +listener.onSetFocus = function(oldFocus, newFocus) { + if (newFocus) { + trace("Focus changed: " + oldFocus + " -> " + newFocus); + } +}; +Key.addListener(listener); +Selection.addListener(listener); + +button1.tabIndex = 1; +button2.tabIndex = 2; +button3.tabIndex = 3; + +var buttons = [button1, button2, button3]; +for (var i in buttons) { + buttons[i].onKeyDown = function () { trace("button.onKeyDown: " + Key.getCode()); } + buttons[i].onKeyUp = function () { trace("button.onKeyUp: " + Key.getCode()); } + buttons[i].onPress = function () { trace("button.onPress: " + Key.getCode()); } + buttons[i].onRelease = function () { trace("button.onRelease: " + Key.getCode()); } +} + +button3._visible = false; +Selection.setFocus(button1); diff --git a/tests/tests/swfs/avm1/button_keypress_vs_tab/test.swf b/tests/tests/swfs/avm1/button_keypress_vs_tab/test.swf new file mode 100644 index 000000000000..852acf847cae Binary files /dev/null and b/tests/tests/swfs/avm1/button_keypress_vs_tab/test.swf differ diff --git a/tests/tests/swfs/avm1/button_keypress_vs_tab/test.toml b/tests/tests/swfs/avm1/button_keypress_vs_tab/test.toml new file mode 100644 index 000000000000..cf6123969a1d --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_tab/test.toml @@ -0,0 +1 @@ +num_ticks = 1