diff --git a/tests/tests/swfs/avm1/button_keypress_vs_press/input.json b/tests/tests/swfs/avm1/button_keypress_vs_press/input.json new file mode 100644 index 0000000000000..faa67eeac2e25 --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_press/input.json @@ -0,0 +1,17 @@ +[ + { "type": "KeyDown", "key_code": 13 }, + { "type": "TextControl", "code": "Enter" }, + { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, + { "type": "TextInput", "codepoint": " " }, + { "type": "KeyUp", "key_code": 32 }, + { "type": "KeyDown", "key_code": 9 }, + { "type": "TextInput", "codepoint": "\t" }, + { "type": "KeyUp", "key_code": 9 }, + { "type": "KeyDown", "key_code": 13 }, + { "type": "TextControl", "code": "Enter" }, + { "type": "KeyUp", "key_code": 13 }, + { "type": "KeyDown", "key_code": 32 }, + { "type": "TextInput", "codepoint": " " }, + { "type": "KeyUp", "key_code": 32 } +] diff --git a/tests/tests/swfs/avm1/button_keypress_vs_press/output.txt b/tests/tests/swfs/avm1/button_keypress_vs_press/output.txt new file mode 100644 index 0000000000000..ac03ad0ec2284 --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_press/output.txt @@ -0,0 +1,25 @@ +button.onKeyDown: 13 +Enter pressed +keyPress 2 enter +button.onKeyUp: 13 +button.onKeyDown: 32 +Space pressed +press 1 +button.onPress: 32 +release 1 +button.onRelease: 32 +button.onKeyUp: 32 +button.onKeyDown: 9 +Tab pressed +button2.onKeyUp: 9 +button2.onKeyDown: 13 +Enter pressed +keyPress 2 enter +button2.onKeyUp: 13 +button2.onKeyDown: 32 +Space pressed +press 2 +button2.onPress: 32 +release 2 +button2.onRelease: 32 +button2.onKeyUp: 32 diff --git a/tests/tests/swfs/avm1/button_keypress_vs_press/test.as b/tests/tests/swfs/avm1/button_keypress_vs_press/test.as new file mode 100644 index 0000000000000..6c9fa28765720 --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_press/test.as @@ -0,0 +1,25 @@ +var listener = new Object(); +listener.onKeyDown = function() { + if (Key.getCode() == 32) { + trace("Space pressed"); + } + if (Key.getCode() == 13) { + trace("Enter pressed"); + } + if (Key.getCode() == 9) { + trace("Tab pressed"); + } +}; +Key.addListener(listener); + +button.onKeyDown = function () { trace("button.onKeyDown: " + Key.getCode()); } +button.onKeyUp = function () { trace("button.onKeyUp: " + Key.getCode()); } +button.onPress = function () { trace("button.onPress: " + Key.getCode()); } +button.onRelease = function () { trace("button.onRelease: " + Key.getCode()); } + +button2.onKeyDown = function () { trace("button2.onKeyDown: " + Key.getCode()); } +button2.onKeyUp = function () { trace("button2.onKeyUp: " + Key.getCode()); } +button2.onPress = function () { trace("button2.onPress: " + Key.getCode()); } +button2.onRelease = function () { trace("button2.onRelease: " + Key.getCode()); } + +Selection.setFocus(button); diff --git a/tests/tests/swfs/avm1/button_keypress_vs_press/test.swf b/tests/tests/swfs/avm1/button_keypress_vs_press/test.swf new file mode 100644 index 0000000000000..177452c05f60e Binary files /dev/null and b/tests/tests/swfs/avm1/button_keypress_vs_press/test.swf differ diff --git a/tests/tests/swfs/avm1/button_keypress_vs_press/test.toml b/tests/tests/swfs/avm1/button_keypress_vs_press/test.toml new file mode 100644 index 0000000000000..cf6123969a1d6 --- /dev/null +++ b/tests/tests/swfs/avm1/button_keypress_vs_press/test.toml @@ -0,0 +1 @@ +num_ticks = 1