2 * Original author: Doug Turner <doug.turner@gmail.com>
5 * * Antonio Gomes <tonikitoo@webkit.org>
8 var gExpectedResults
= 0;
10 var gClosureCallback
= null;
11 var gFocusedDocument
= 0;
13 function initTest(table
, completedCb
) {
15 gExpectedResults
= table
;
17 gClosureCallback
= completedCb
;
23 function prepareMove()
25 // When a table has with "DONE", call the completion callback and end the moves.
26 if (gExpectedResults
[gIndex
][0] == "DONE")
27 if (gClosureCallback
) {
32 // When a table has an "", just end the moves.
33 if (gExpectedResults
[gIndex
][0] == "")
43 switch (gExpectedResults
[gIndex
][0]) {
45 direction
= "upArrow";
48 direction
= "rightArrow";
51 direction
= "downArrow";
54 direction
= "leftArrow";
60 debug("Action [" + gExpectedResults
[gIndex
][0] + "] not supported.");
63 if (window
.testRunner
&& direction
)
64 eventSender
.keyDown(direction
);
66 setTimeout(verifyAndAdvance
, 15);
69 function verifyAndAdvance()
71 var direction
= gExpectedResults
[gIndex
][0];
72 var expectedID
= gExpectedResults
[gIndex
][1];
74 gFocusedDocument
= document
;
75 findFocusedDocument(document
);
78 var mainFrameHasFocus
= true;
79 for ( ; i
< window
.frames
.length
; i
++) {
80 if (window
.frames
[i
].document
.hasFocus()) {
81 mainFrameHasFocus
= false;
86 shouldBeEqualToString("gFocusedDocument.activeElement.getAttribute(\"id\")", expectedID
);
92 function findFocusedDocument(currentDocument
)
95 for ( ; i
< currentDocument
.defaultView
.frames
.length
; i
++) {
96 findFocusedDocument(currentDocument
.defaultView
.frames
[i
].document
);
97 if (gFocusedDocument
!= document
)
101 if (currentDocument
.hasFocus()) {
102 gFocusedDocument
= currentDocument
;