summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/focus/sequential-focus-navigation-and-the-tabindex-attribute/focus-tabindex-order-manual.html
blob: c837626293c6fb7685f3933247c5eefa38b6bb67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!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>