Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / parser / tabindex-parsing.html
blob95c0a36c4bd3e953492985e2c8ea2ec65187371e
1 <script>
2 if (window.testRunner)
3 testRunner.waitUntilDone();
5 var p1Focused = false;
6 var p2Focused = false;
7 var p3Focused = false;
8 var p4Focused = false;
9 var p5Focused = false;
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";
20 } else {
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')+"'";
28 function autoTest()
30 if (!window.testRunner)
31 return;
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();
43 </script>
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).
51 </blockquote>
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>
55 </p>
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>
58 </p>
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>
61 </p>
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>
64 </p>
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>
67 </p>
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>
70 </p>
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>
73 </p>
74 <pre id="result"></pre>
75 </body>