3 testRunner
.waitUntilDone();
10 var p6Focused
= false;
11 var p7Focused
= false;
13 function test(focusHappened
, focusWasExpected
, spanNum
)
15 var tabindexSpan
= document
.getElementById("sp"+spanNum
);
16 var resultSpan
= document
.createElement("span");
17 if (focusHappened
== focusWasExpected
) {
18 resultSpan
.setAttribute("style","color:green");
19 resultSpan
.innerHTML
= "PASSED";
21 resultSpan
.setAttribute("style","color:red");
22 resultSpan
.innerHTML
= "FAILED";
24 tabindexSpan
.parentNode
.insertBefore(resultSpan
, tabindexSpan
.parentNode
.firstChild
.nextSibling
);
25 tabindexSpan
.innerHTML
= ".tabIndex=" + tabindexSpan
.parentNode
.tabIndex
+ " getAttribute('tabindex')='" + tabindexSpan
.parentNode
.getAttribute('tabindex')+"'";
30 if (!window
.testRunner
)
33 var allParagraphs
= document
.getElementsByTagName("p");
34 for(var i
=0; i
< allParagraphs
.length
; ++i
) {
35 eventSender
.mouseMoveTo(allParagraphs
[i
].offsetLeft
+5,allParagraphs
[i
].offsetTop
+5);
36 eventSender
.mouseDown();
37 eventSender
.mouseUp();
39 testRunner
.dumpAsText();
40 testRunner
.notifyDone();
45 <body onload=
"autoTest()">
46 From HTML5 spec:
<blockquote>
47 The tabindex attribute, if specified, must have a value that is a valid
48 integer. If the attribute is specified, it must be parsed using the rules
49 for parsing integers. If parsing the value returns an error, the attribute
50 is ignored for the purposes of focus management (as if it wasn't specified).
53 <p tabindex=
" 10" onfocus=
"p1Focused=true" onclick=
"test(p1Focused,true,1)">This element should be focusable
<br>
54 <span id=
"sp1">Click to test manually
</span>
56 <p tabindex=
"one" onfocus=
"p2Focused=true" onclick=
"test(p2Focused,false,2)">This element shouldn't be focusable
<br>
57 <span id=
"sp2">Click to test manually
</span>
59 <p tabindex=
"007" onfocus=
"p3Focused=true" onclick=
"test(p3Focused,true,3)">This element should be focusable
<br>
60 <span id=
"sp3">Click to test manually
</span>
62 <p tabindex=
"1px" onfocus=
"p4Focused=true" onclick=
"test(p4Focused,true,4)">This element should be focusable
<br>
63 <span id=
"sp4">Click to test manually
</span>
65 <p tabindex=
"-0" onfocus=
"p5Focused=true" onclick=
"test(p5Focused,true,5)">This element should be focusable
<br>
66 <span id=
"sp5">Click to test manually
</span>
68 <p tabindex=
"" onfocus=
"p6Focused=true" onclick=
"test(p6Focused,false,6)">This element shouldn't be focusable
<br>
69 <span id=
"sp6">Click to test manually
</span>
71 <p tabindex=
"-004" onfocus=
"p7Focused=true" onclick=
"test(p7Focused,true,7)">This element should be focusable
<br>
72 <span id=
"sp7">Click to test manually
</span>
74 <pre id=
"result"></pre>