summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/interaction/focus/focusgroup/tentative/grid-navigation/colspan.html
blob: c9daeffaeb130b89c224c2bdb66432f63ee40de5 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: focusgroup - Validate that we deal correctly with colspans.</title>
<link rel="author" title="Microsoft" href="http://www.microsoft.com/">
<link rel="help" href="https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/Focusgroup/explainer.md">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/focusgroup-utils.js"></script>

<table focusgroup="grid">
  <tr>
    <td id=r1c1 tabindex=0>r1c1</td>
    <td id=r1c2 tabindex=-1 colspan=2>r1c2</td>
    <td id=r1c4 tabindex=-1>r1c4</td>
  </tr>
  <tr>
    <td id=r2c1 tabindex=-1>r2c1</td>
    <td id=r2c2 tabindex=-1>r2c2</td>
    <td id=r2c3 tabindex=-1>r2c3</td>
    <td id=r2c4 tabindex=-1>r2c4</td>
  </tr>
</table>

<script>

  promise_test(async t => {
    var r1c1 = document.getElementById("r1c1");
    var r1c2 = document.getElementById("r1c2");
    var r1c4 = document.getElementById("r1c4");

    await focusAndKeyPress(r1c1, kArrowRight);
    assert_equals(document.activeElement, r1c2);

    await focusAndKeyPress(r1c2, kArrowRight);
    assert_equals(document.activeElement, r1c4);
  }, "A right arrow press should move the focus to the next column, dealing correctly with colspans.");

  promise_test(async t => {
    var r1c1 = document.getElementById("r1c1");
    var r1c2 = document.getElementById("r1c2");
    var r1c4 = document.getElementById("r1c4");
    var r2c1 = document.getElementById("r2c1");
    var r2c2 = document.getElementById("r2c2");
    var r2c4 = document.getElementById("r2c4");

    await focusAndKeyPress(r1c1, kArrowDown);
    assert_equals(document.activeElement, r2c1);

    await focusAndKeyPress(r1c2, kArrowDown);
    assert_equals(document.activeElement, r2c2);

    await focusAndKeyPress(r1c4, kArrowDown);
    assert_equals(document.activeElement, r2c4);
  }, "A down arrow press should move the focus to the right cell on the next row, dealing correctly with colspans.");

  promise_test(async t => {
    var r1c1 = document.getElementById("r1c1");
    var r1c2 = document.getElementById("r1c2");
    var r1c4 = document.getElementById("r1c4");

    await focusAndKeyPress(r1c4, kArrowLeft);
    assert_equals(document.activeElement, r1c2);

    await focusAndKeyPress(r1c2, kArrowLeft);
    assert_equals(document.activeElement, r1c1);
  }, "A left arrow press should move to the previous column, dealing correctly with the colspans.");

  promise_test(async t => {
    var r1c1 = document.getElementById("r1c1");
    var r1c2 = document.getElementById("r1c2");
    var r1c4 = document.getElementById("r1c4");
    var r2c1 = document.getElementById("r2c1");
    var r2c2 = document.getElementById("r2c2");
    var r2c3 = document.getElementById("r2c3");
    var r2c4 = document.getElementById("r2c4");

    await focusAndKeyPress(r2c1, kArrowUp);
    assert_equals(document.activeElement, r1c1);

    await focusAndKeyPress(r2c2, kArrowUp);
    assert_equals(document.activeElement, r1c2);

    await focusAndKeyPress(r2c3, kArrowUp);
    assert_equals(document.activeElement, r1c2);

    await focusAndKeyPress(r2c4, kArrowUp);
    assert_equals(document.activeElement, r1c4);
  }, "An up arrow press should move the focus to the right cell on the previous row, dealing correctly with colspans.");

</script>