| <!DOCTYPE html> |
| <meta charset="utf-8"> |
| <title>HTML Test: focus - the sequential focus navigation order</title> |
| <link rel="author" title="Intel" href="http://www.intel.com/"> |
| <link rel="help" href="https://html.spec.whatwg.org/multipage/#sequential-focus-navigation-and-the-tabindex-attribute"> |
| <meta assert="flag" content="interact"> |
| <meta assert="assert" content="Check the sequential focus navigation order"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <h2>Steps:</h2> |
| <ol> |
| <li>Press 'Tab' key at least 10 times in 20 seconds.(Long press the 'Tab' key will be better.)</li> |
| </ol> |
| <h2>Expect results:</h2> |
| <p>PASS</p> |
| <div id="log"></div> |
| <form id="fm"> |
| <button id="btn0">tabindex(omitted)</button> |
| <button id="btn1" tabindex="">tabindex(empty)</button> |
| <button id="btn2" tabindex="a">tabindex(a)</button> |
| <button id="btn3" tabindex="-1">tabindex(-1)</button> |
| <button id="btn4" tabindex="0">tabindex(0)</button> |
| <button id="btn5" tabindex="3">tabindex(3)</button> |
| <button id="btn6" tabindex="2">tabindex(2)</button> |
| <button id="btn7" tabindex="2">tabindex(2)</button> |
| <button id="btn8" tabindex="2">tabindex(2)</button> |
| <button id="btn9" tabindex="1">tabindex(1)</button> |
| </form> |
| <script> |
| |
| //This test can be automated once we have an uniform way to use webdriver. |
| var i = 0, |
| expectation = ["btn9", "btn6", "btn7", "btn8", "btn5", "btn0", "btn1", "btn2", "btn4"], |
| results = [], |
| t = async_test("The element with a zero tabindex must be focused by press 'Tab' key"); |
| |
| setup(function () { |
| document.body.focus(); |
| }, {timeout: 20000}); |
| |
| document.forms.fm.addEventListener("focus", function (evt) { |
| results.push(evt.target.id); |
| if (i >= 9) { |
| t.step(function () { |
| assert_array_equals(results, expectation); |
| }); |
| } |
| }, true); |
| |
| document.addEventListener("keydown", function (evt) { |
| if (evt.keyCode === 9) { |
| i += 1; |
| if (i === 10) { |
| t.done(); |
| } |
| } |
| }, true); |
| |
| </script> |