4 background-color: white;
8 border:
2px solid black;
14 document
.getElementById('log').appendChild(document
.createTextNode(msg
+ '\n'));
17 function windowFocused(win
, name
)
20 log(name
+ ': window focused');
24 function windowBlurred(win
, name
)
27 win
.document
.body
.style
.background
= "red";
28 log(name
+ ': window blurred');
32 function logTabbedElement(event
, elem
, i
, name
)
34 log(name
+ ': ' + elem
.tagName
+ ' #' + i
+ ' (tabindex=' + elem
.tabIndex
+ ') ' + event
);
37 var lastFocusedElement
= null;
38 function elementFocused(elem
, i
, name
)
41 logTabbedElement('focused', elem
, i
, name
);
42 lastFocusedElement
= elem
;
46 function elementBlurred(elem
, i
, name
)
49 logTabbedElement('blurred', elem
, i
, name
);
53 function setupElements(win
, name
, tag
)
55 var elems
= win
.document
.getElementsByTagName(tag
);
56 for (var i
= 0; i
< elems
.length
; ++i
) {
57 elems
[i
].onfocus
= elementFocused(elems
[i
], i
, name
);
58 elems
[i
].onblur
= elementBlurred(elems
[i
], i
, name
);
62 function setupBodyFunc(win
, name
)
65 setupElements(win
, name
, 'a');
66 setupElements(win
, name
, 'input');
67 setupElements(win
, name
, 'iframe');
71 function setupWindow(win
)
74 if (win
.frameElement
) {
75 name
= win
.frameElement
.id
;
80 win
.setupWindow
= setupWindow
;
81 win
.setupBody
= setupBodyFunc(win
, name
);
83 win
.onfocus
= windowFocused(win
, name
);
84 win
.onblur
= windowBlurred(win
, name
);
87 function dispatchTabPress(element
, shiftKey
, altKey
)
89 if (window
.eventSender
) {
92 modifiers
.push("shiftKey");
94 modifiers
.push("altKey");
95 eventSender
.keyDown('\u0009', modifiers
);
101 if (window
.testRunner
) {
102 testRunner
.dumpAsText();
105 log('Tabbing forward...\n');
106 document
.getElementById('first').focus();
107 for (var i
= 0; i
< 7; ++i
) {
108 dispatchTabPress(document
, false, false);
111 lastFocusedElement
.blur();
113 log('\nTabbing backward...\n');
114 for (var i
= 0; i
< 8; ++i
) {
115 dispatchTabPress(document
, true, false);
118 lastFocusedElement
.blur();
120 log('\nOption-tabbing forward...\n');
121 for (var i
= 0; i
< 12; ++i
) {
122 dispatchTabPress(document
, false, navigator
.platform
.indexOf('Mac') == 0);
125 lastFocusedElement
.blur();
127 log('\nOption-tabbing backward...\n');
128 for (var i
= 0; i
< 12; ++i
) {
129 dispatchTabPress(document
, true, navigator
.platform
.indexOf('Mac') == 0);
132 lastFocusedElement
.blur();
134 log('\nTest finished\n');
139 <body onload=
"window.setupBody(); test();">
140 <p>This page tests tabbing between subframes. To test, click on this text
141 to focus the main window. Then press Tab
7 times, then Shift-Tab
7 times,
142 which should move focus forward and backward through all inputs and frames.
143 Then press Option-Tab
11 times and Shift-Option-Tab
11 times, which should
144 move focus forward and backward through all inputs, frames, and links.
</p>
147 <iframe id=
"empty-middle" src=
"resources/frame-tab-focus-empty-middle.html" width=
"400" height=
"200"></iframe>
148 <input type=
"text" tabindex=
"3">
149 <input type=
"text" tabindex=
"2" id=
"first">
150 <iframe id=
"upper" src=
"resources/frame-tab-focus-upper.html" height=
"300"></iframe>
151 <iframe id=
"child" tabindex=
"4" src=
"resources/frame-tab-focus-child.html"></iframe>
153 <a tabindex=
"1" href=
"#">[tabindex of one]
</a>
154 <a tabindex=
"3" href=
"#">[tabindex of three]
</a>
155 <a tabindex=
"2" href=
"#">[tabindex of two]
</a>
156 <a tabindex=
"3" href=
"#">[tabindex of three]
</a>