6 document
.getElementById('log').appendChild(document
.createTextNode(msg
+ '\n'));
9 function description(element
)
11 if (element
.tagName
&& element
.tagName
.match(/rect/i)) {
12 return '<rect id="' + element
.id
+ '" tabindex="' + element
.tabIndex
+ '">';
14 return element
.toString();
18 function dispatchTabPress(element
, shiftKey
)
20 var event
= document
.createEvent('KeyboardEvents');
21 var tabKeyIdentifier
= 'U+0009';
22 event
.initKeyboardEvent('keydown', true, true, document
.defaultView
, tabKeyIdentifier
, 0, false, false, shiftKey
, false, false);
23 element
.dispatchEvent(event
);
26 var lastFocusedElement
= null;
27 function focusListener(event
)
29 log('<rect id="' + event
.target
.id
+ '" tabindex="' + event
.target
.tabIndex
+ '"> focused');
30 lastFocusedElement
= event
.target
;
33 function addEventListenersToRects(rects
)
35 for (var i
= 0; i
< rects
.length
; ++i
) {
36 rects
[i
].addEventListener('focus', focusListener
, false);
42 if (window
.testRunner
) {
43 testRunner
.dumpAsText();
46 var rects
= document
.getElementsByTagName('rect');
48 // Put focus in the page
52 addEventListenersToRects(rects
);
54 log('Tabbing forward....\n');
55 for (var i
= 0; i
< rects
.length
; ++i
) {
56 if (rects
[i
].tabIndex
>= 0)
57 dispatchTabPress(document
, false);
60 lastFocusedElement
.blur();
62 log('\nTabbing backward....\n');
63 for (var i
= 0; i
< rects
.length
; ++i
) {
64 if (rects
[i
].tabIndex
>= 0)
65 dispatchTabPress(document
, true);
68 log('\nTest finished\n');
72 <body onload=
"test()">
73 <p>This page tests that the SVG tabbing order is respected properly.
</p>
74 <p>To test, put focus in
"a
". Pressing Tab should focus
"a
" through
"k
" in order, and pressing Shift-Tab should reverse the order.
</p>
76 <rect tabindex=
"6" id=
"g" width=
"1" height=
"1"/>
77 <rect tabindex=
"1" id=
"a" width=
"1" height=
"1"/>
78 <rect tabindex=
"-5" id=
"not in tab order (negative tabindex)" width=
"1" height=
"1"/>
79 <rect tabindex=
"1" id=
"b" width=
"1" height=
"1"/>
80 <rect tabindex=
"0" id=
"i" width=
"1" height=
"1"/>
81 <rect tabindex=
"6" id=
"h" width=
"1" height=
"1"/>
82 <rect tabindex=
"1" id=
"c" width=
"1" height=
"1"/>
83 <rect tabindex=
"1" id=
"d" width=
"1" height=
"1"/>
84 <rect tabindex=
"0" id=
"j" width=
"1" height=
"1"/>
85 <rect tabindex=
"-1" id=
"not in tab order (negative tabindex)" width=
"1" height=
"1"/>
86 <rect tabindex=
"0" id=
"k" width=
"1" height=
"1"/>
87 <rect tabindex=
"4" id=
"f" width=
"1" height=
"1"/>
88 <rect tabindex=
"3" id=
"e" width=
"1" height=
"1"/>