| <script> |
| if (window.testRunner) |
| testRunner.waitUntilDone(); |
| |
| var p1Focused = false; |
| var p2Focused = false; |
| var p3Focused = false; |
| var p4Focused = false; |
| var p5Focused = false; |
| var p6Focused = false; |
| var p7Focused = false; |
| |
| function test(focusHappened, focusWasExpected, spanNum) |
| { |
| var tabindexSpan = document.getElementById("sp"+spanNum); |
| var resultSpan = document.createElement("span"); |
| if (focusHappened == focusWasExpected) { |
| resultSpan.setAttribute("style","color:green"); |
| resultSpan.innerHTML = "PASSED"; |
| } else { |
| resultSpan.setAttribute("style","color:red"); |
| resultSpan.innerHTML = "FAILED"; |
| } |
| tabindexSpan.parentNode.insertBefore(resultSpan, tabindexSpan.parentNode.firstChild.nextSibling); |
| tabindexSpan.innerHTML = ".tabIndex=" + tabindexSpan.parentNode.tabIndex + " getAttribute('tabindex')='" + tabindexSpan.parentNode.getAttribute('tabindex')+"'"; |
| } |
| |
| function autoTest() |
| { |
| if (!window.testRunner) |
| return; |
| |
| var allParagraphs = document.getElementsByTagName("p"); |
| for(var i=0; i < allParagraphs.length; ++i) { |
| eventSender.mouseMoveTo(allParagraphs[i].offsetLeft+5,allParagraphs[i].offsetTop+5); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| } |
| testRunner.dumpAsText(); |
| testRunner.notifyDone(); |
| } |
| |
| </script> |
| |
| <body onload="autoTest()"> |
| From HTML5 spec:<blockquote> |
| The tabindex attribute, if specified, must have a value that is a valid |
| integer. If the attribute is specified, it must be parsed using the rules |
| for parsing integers. If parsing the value returns an error, the attribute |
| is ignored for the purposes of focus management (as if it wasn't specified). |
| </blockquote> |
| |
| <p tabindex=" 10" onfocus="p1Focused=true" onclick="test(p1Focused,true,1)">This element should be focusable <br> |
| <span id="sp1">Click to test manually</span> |
| </p> |
| <p tabindex="one" onfocus="p2Focused=true" onclick="test(p2Focused,false,2)">This element shouldn't be focusable <br> |
| <span id="sp2">Click to test manually</span> |
| </p> |
| <p tabindex="007" onfocus="p3Focused=true" onclick="test(p3Focused,true,3)">This element should be focusable <br> |
| <span id="sp3">Click to test manually</span> |
| </p> |
| <p tabindex="1px" onfocus="p4Focused=true" onclick="test(p4Focused,true,4)">This element should be focusable <br> |
| <span id="sp4">Click to test manually</span> |
| </p> |
| <p tabindex="-0" onfocus="p5Focused=true" onclick="test(p5Focused,true,5)">This element should be focusable <br> |
| <span id="sp5">Click to test manually</span> |
| </p> |
| <p tabindex="" onfocus="p6Focused=true" onclick="test(p6Focused,false,6)">This element shouldn't be focusable <br> |
| <span id="sp6">Click to test manually</span> |
| </p> |
| <p tabindex="-004" onfocus="p7Focused=true" onclick="test(p7Focused,true,7)">This element should be focusable <br> |
| <span id="sp7">Click to test manually</span> |
| </p> |
| <pre id="result"></pre> |
| </body> |