2 <title>Tabindex on svg elements tests
</title>
3 <script src=../../resources/testharness.js
></script>
4 <script src=../../resources/testharnessreport.js
></script>
6 <div id=
"testcontainer"><svg id=
"testroot" width=
"1" height=
"1"/></div>
9 var svg
= document
.getElementById("testroot");
10 function isFocusable(elm
) {
11 switch (elm
.nodeName
) {
13 return elm
.hasAttributeNS("http://www.w3.org/1999/xlink", "href");
18 function isFocusableWithTabindex(elm
) {
19 switch (elm
.nodeName
) {
36 //case "tref": /* not supported */
38 // only if inside a <text> element
39 return elm
.parentNode
.nodeName
== "text";
46 function createSvg() {
66 "feComponentTransfer",
129 for (var i
= 0; i
< svgelements
.length
; i
++) {
130 svg
.appendChild(document
.createElementNS("http://www.w3.org/2000/svg", svgelements
[i
]));
134 function setupTextContentElements() {
135 // specialcases for the text content elements
137 // cleanup any old content
138 while(svg
.firstChild
)
139 svg
.removeChild(svg
.firstChild
);
141 var textContentChildElements
= ["textPath", "tref", "tspan"];
142 for (var i
= 0; i
< textContentChildElements
.length
; i
++) {
143 var text
= document
.createElementNS("http://www.w3.org/2000/svg", "text");
144 text
.appendChild(document
.createElementNS("http://www.w3.org/2000/svg", textContentChildElements
[i
]));
145 svg
.appendChild(text
);
150 var element
= svg
.firstElementChild
;
155 assert_equals(document
.activeElement
, isFocusable(element
) ? element
: document
.body
);
158 document
.body
.focus();
160 }, element
.nodeName
+ ".focus() without tabindex set.");
163 element
.setAttribute("tabindex", "1");
165 assert_equals(document
.activeElement
, isFocusableWithTabindex(element
) ? element
: document
.body
);
166 element
.removeAttribute("tabindex");
169 document
.body
.focus();
171 }, element
.nodeName
+ ".focus() with tabindex set.");
173 element
.parentNode
.removeChild(element
);
174 element
= svg
.firstElementChild
;
177 setupTextContentElements();
178 var element
= svg
.firstElementChild
;
182 element
.firstElementChild
.focus();
183 assert_equals(document
.activeElement
, isFocusable(element
.firstElementChild
) ? element
.firstElementChild
: document
.body
);
186 document
.body
.focus();
188 }, element
.firstElementChild
.nodeName
+ ".focus() without tabindex set.");
191 element
.firstElementChild
.setAttribute("tabindex", "1");
192 element
.firstElementChild
.focus();
193 assert_equals(document
.activeElement
, isFocusableWithTabindex(element
.firstElementChild
) ? element
.firstElementChild
: document
.body
);
194 element
.firstElementChild
.removeAttribute("tabindex");
197 document
.body
.focus();
199 }, element
.firstElementChild
.nodeName
+ ".focus() with tabindex set.");
201 element
.parentNode
.removeChild(element
);
202 element
= svg
.firstElementChild
;