Skip to content

Commit

Permalink
tests: Add avm1/tab_ordering_custom_m1
Browse files Browse the repository at this point in the history
This test verifies the behavior of tabIndex = -1.
  • Loading branch information
kjarosh authored and Dinnerbone committed Apr 30, 2024
1 parent 8f288b5 commit e898696
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/tests/swfs/avm1/tab_ordering_custom_m1/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 }
]
29 changes: 29 additions & 0 deletions tests/tests/swfs/avm1/tab_ordering_custom_m1/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Tab pressed
Focus changed
old: null
new: _level0.text6
Tab pressed
Focus changed
old: _level0.text6
new: _level0.text5
Tab pressed
Focus changed
old: _level0.text5
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text4
Tab pressed
Focus changed
old: _level0.text4
new: _level0.text6
Tab pressed
Focus changed
old: _level0.text6
new: _level0.text5
Tab pressed
32 changes: 32 additions & 0 deletions tests/tests/swfs/avm1/tab_ordering_custom_m1/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var stopTrace = false;
var tracedCount = 0;

var listener = new Object();
listener.onSetFocus = function(oldFocus, newFocus) {
if (newFocus && !stopTrace) {
trace("Focus changed");
trace(" old: " + oldFocus);
trace(" new: " + newFocus);
}
};
Selection.addListener(listener);

var listener = new Object();
listener.onKeyDown = function() {
if (Key.getCode() == 9 && !stopTrace) {
++tracedCount;
if (tracedCount == 9) {
stopTrace = true;
} else {
trace("Tab pressed");
}
}
};
Key.addListener(listener);

text1.tabIndex = 1;
text2.tabIndex = 0;
text3.tabIndex = -1;
text4.tabIndex = 2;
text5.tabIndex = -2;
text6.tabIndex = -3;
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm1/tab_ordering_custom_m1/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit e898696

Please sign in to comment.