summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/table/test_struct_table.html
blob: 98b9549354c69851a3efe8f59bf9d005f9f50d12 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html>

<head>
  <title>Table accessible tree and table interface tests for HTML tables</title>
  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>
  <script type="application/javascript"
          src="../table.js"></script>

  <script type="application/javascript">
    function doTest()
    {
      //////////////////////////////////////////////////////////////////////////
      // column headers from thead and tfoot

      cellsArray = [
        [kColHeaderCell, kColHeaderCell, kColSpanned],
        [kRowSpanned,    kColHeaderCell, kColHeaderCell],
        [kDataCell,      kDataCell,      kDataCell],
        [kColHeaderCell, kColHeaderCell, kColHeaderCell]
      ];

      testTableStruct("table1", cellsArray);

      //////////////////////////////////////////////////////////////////////////
      // row and column headers from thead and @scope

      var cellsArray = [
        [kColHeaderCell, kColHeaderCell, kColHeaderCell],
        [kRowHeaderCell, kDataCell, kDataCell],
        [kRowHeaderCell, kDataCell, kDataCell]
      ];

      testTableStruct("table2", cellsArray);

      //////////////////////////////////////////////////////////////////////////
      // caption and @summary

      cellsArray = [
        [kColHeaderCell, kColHeaderCell, kColHeaderCell, kColHeaderCell],
        [kRowHeaderCell, kDataCell,      kDataCell,      kDataCell],
        [kRowHeaderCell, kDataCell,      kDataCell,      kDataCell]
      ];

      testTableStruct("table3", cellsArray, kNoColumnHeader,
                      "Test Table",
                      "this is a test table for nsIAccessibleTable");

      //////////////////////////////////////////////////////////////////////////
      // row and column spans

      cellsArray = [
        [kDataCell, kDataCell,   kDataCell,   kColSpanned, kDataCell, kDataCell,   kDataCell, kDataCell],
        [kDataCell, kDataCell,   kDataCell,   kDataCell,   kDataCell, kDataCell,   kDataCell, kRowSpanned],
        [kDataCell, kDataCell,   kColSpanned, kDataCell,   kDataCell, kDataCell,   kDataCell, kRowSpanned],
        [kDataCell, kRowSpanned, kSpanned,    kDataCell,   kDataCell, kRowSpanned, kDataCell, kRowSpanned]
      ];

      testTableStruct("table4", cellsArray);

      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
</head>
<body>

  <a target="_blank"
     title="Fix our nsHTMLAccessibleTable class so GetIndexAt and GetRowAtIndex and GetColumnAtIndex behave consistently"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
  <a target="_blank"
     title="GetCellDataAt callers that expect an error if no cell is found are wrong"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=417912">Mozilla Bug 417912</a>
  <a target="_blank"
     title="create accessibles for HTML tr"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=493695">Mozilla Bug 493695</a>
  <a target="_blank"
     title="implement IAccessibleTable2"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424">Mozilla Bug 512424</a>

  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <table id="table1">
    <thead>
      <tr>
        <th rowspan="2">col1</th><th colspan="2">col2</th>
      </tr>
      <tr>
        <th>col2sub1</th><th>col2sub2</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>cell1</td><td>cell2</td><td>cell3</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <th>col1</th><th>col2</th><th>col3</th>
      </tr>
    </tfoot>
  </table>

  <table id="table2">
    <thead>
      <tr>
        <th id="table1_0">col1</th>
        <th id="table1_1">col2</th>
        <td id="table1_2" scope="col">col3</td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th id="table1_3">row1</th>
        <td id="table1_4">cell1</td>
        <td id="table1_5">cell2</td>
      </tr>
      <tr>
        <td id="table1_6" scope="row">row2</td>
        <td id="table1_7">cell3</td>
        <td id="table1_8">cell4</td>
      </tr>
    </tbody>
  </table>

  <table id="table3" border="1"
         summary="this is a test table for nsIAccessibleTable">
    <caption>Test Table</caption>
    <thead>
      <tr>
        <th></th>
        <th>columnHeader_1</th>
        <th id ="col2a">columnHeader_2</th>
        <th>columnHeader_3</th>
      </tr>
    </thead>
    <tr>
      <th id="row2a">rowHeader_1</th>
      <td id="row2b">row1_column1</td>
      <td id ="col2b">row1_column2</td>
      <td id="row2c">row1_column3</td>
    </tr>
    <tr>
      <th>rowHeader_2</th>
      <td>row2_column1</td>
      <td id ="col2c">row2_column2</td>
      <td>row2_column3</td>
    </tr>
  </table>

  <table id="table4" cellpadding="2" cellspacing="2" border="1" width="50%">
    <tbody>
      <tr>
        <td><br></td>
        <td><br></td>
        <td rowspan="1" colspan="2"><br></td>
        <td><br></td>
        <td><br></td>
        <td><br></td>
        <td rowspan="4" colspan="1"><br></td>
      </tr>
      <tr>
        <td><br></td>
        <td><br></td>
        <td><br></td>
        <td><br></td>
        <td><br></td>
        <td><br></td>
        <td><br></td>
      </tr>
      <tr>
        <td><br></td>
        <td rowspan="2" colspan="2">c1</td>
        <td><br></td>
        <td><br></td>
        <td rowspan="2" colspan="1"><br></td>
        <td><br></td>
      </tr>
      <tr>
        <td><br></td>
        <td><br></td>
        <td><br></td>
        <td><br></td>
      </tr>
    </tbody>
  </table>

</body>
</html>