accessible/tests/mochitest/tree/test_table.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/tree/test_table.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,246 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>HTML table tests</title>
     1.8 +  <link rel="stylesheet" type="text/css"
     1.9 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.10 +
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +
    1.14 +  <script type="application/javascript"
    1.15 +          src="../common.js"></script>
    1.16 +  <script type="application/javascript"
    1.17 +          src="../role.js"></script>
    1.18 +
    1.19 +  <script type="application/javascript">
    1.20 +    function doTest()
    1.21 +    {
    1.22 +      //////////////////////////////////////////////////////////////////////////
    1.23 +      // tables having captions
    1.24 +
    1.25 +      // Two captions, first is used, second is ignored.
    1.26 +      var accTree =
    1.27 +        { TABLE: [
    1.28 +          { CAPTION: [
    1.29 +            {
    1.30 +              role: ROLE_TEXT_LEAF,
    1.31 +              name: "caption"
    1.32 +             }
    1.33 +          ] },
    1.34 +          { ROW: [
    1.35 +            { COLUMNHEADER: [ { TEXT_LEAF: [ ] } ] },
    1.36 +            { COLUMNHEADER: [ { TEXT_LEAF: [ ] } ] }
    1.37 +          ] },
    1.38 +          { ROW: [
    1.39 +            { CELL: [ { TEXT_LEAF: [ ] } ] },
    1.40 +            { CELL: [ { TEXT_LEAF: [ ] } ] }
    1.41 +          ] },
    1.42 +          { ROW: [
    1.43 +            { CELL: [ { TEXT_LEAF: [ ] } ] },
    1.44 +            { CELL: [ { TEXT_LEAF: [ ] } ] }
    1.45 +          ] },
    1.46 +          { ROW: [
    1.47 +            { CELL: [ { TEXT_LEAF: [ ] } ] },
    1.48 +            { CELL: [ { TEXT_LEAF: [ ] } ] }
    1.49 +          ] }
    1.50 +        ] };
    1.51 +
    1.52 +      testAccessibleTree("table", accTree);
    1.53 +
    1.54 +      // One caption, empty text, caption is ignored.
    1.55 +      accTree =
    1.56 +        { TABLE: [
    1.57 +          { ROW: [
    1.58 +            { CELL: [ { TEXT_LEAF: [ ] } ] },
    1.59 +            { CELL: [ { TEXT_LEAF: [ ] } ] }
    1.60 +          ] }
    1.61 +        ] };
    1.62 +
    1.63 +      testAccessibleTree("table_caption_empty", accTree);
    1.64 +
    1.65 +      // Two captions, first has empty text, both are ignored.
    1.66 +      accTree =
    1.67 +        { TABLE: [
    1.68 +          { ROW: [
    1.69 +            { CELL: [ { TEXT_LEAF: [ ] } ] },
    1.70 +            { CELL: [ { TEXT_LEAF: [ ] } ] }
    1.71 +          ] }
    1.72 +        ] };
    1.73 +
    1.74 +      testAccessibleTree("table_caption_firstempty", accTree);
    1.75 +
    1.76 +      // One caption, placed in the end of table. In use.
    1.77 +      accTree =
    1.78 +        { TABLE: [
    1.79 +          { CAPTION: [
    1.80 +            {
    1.81 +              role: ROLE_TEXT_LEAF,
    1.82 +              name: "caption"
    1.83 +             }
    1.84 +          ] },
    1.85 +          { ROW: [
    1.86 +            { CELL: [ { TEXT_LEAF: [ ] } ] },
    1.87 +            { CELL: [ { TEXT_LEAF: [ ] } ] }
    1.88 +          ] }
    1.89 +        ] };
    1.90 +
    1.91 +      testAccessibleTree("table_caption_intheend", accTree);
    1.92 +
    1.93 +      //////////////////////////////////////////////////////////////////////////
    1.94 +      // table2 (consist of one column)
    1.95 +
    1.96 +      accTree = {
    1.97 +        role: ROLE_TABLE,
    1.98 +        children: [
    1.99 +          {
   1.100 +            role: ROLE_ROW,
   1.101 +            children: [
   1.102 +              {
   1.103 +                role: ROLE_COLUMNHEADER
   1.104 +              }
   1.105 +            ]
   1.106 +          },
   1.107 +          {
   1.108 +            role: ROLE_ROW,
   1.109 +            children: [
   1.110 +              {
   1.111 +                role: ROLE_CELL
   1.112 +              }
   1.113 +            ]
   1.114 +          }
   1.115 +        ]
   1.116 +      };
   1.117 +
   1.118 +      testAccessibleTree("table2", accTree);
   1.119 +
   1.120 +      //////////////////////////////////////////////////////////////////////////
   1.121 +      // table3 (consist of one row)
   1.122 +
   1.123 +      accTree = {
   1.124 +        role: ROLE_TABLE,
   1.125 +        children: [
   1.126 +          {
   1.127 +            role: ROLE_ROW,
   1.128 +            children: [
   1.129 +              {
   1.130 +                role: ROLE_ROWHEADER
   1.131 +              },
   1.132 +              {
   1.133 +                role: ROLE_CELL
   1.134 +              }
   1.135 +            ]
   1.136 +          }
   1.137 +        ]
   1.138 +      };
   1.139 +
   1.140 +      testAccessibleTree("table3", accTree);
   1.141 +
   1.142 +      /////////////////////////////////////////////////////////////////////////
   1.143 +      // table4 (display: table-row)
   1.144 +      accTree = 
   1.145 +        { TABLE: [
   1.146 +          { ROW: [
   1.147 +            { CELL: [
   1.148 +              { TEXT_LEAF: [ ] }
   1.149 +            ] }
   1.150 +          ] } ]
   1.151 +        };
   1.152 +      testAccessibleTree("table4", accTree);
   1.153 +
   1.154 +      SimpleTest.finish();
   1.155 +    }
   1.156 +
   1.157 +    SimpleTest.waitForExplicitFinish();
   1.158 +    addA11yLoadEvent(doTest);
   1.159 +  </script>
   1.160 +</head>
   1.161 +<body>
   1.162 +
   1.163 +  <a target="_blank"
   1.164 +     title="When a table has only one column per row and that column happens to be a column header its role is exposed wrong"
   1.165 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=529621">
   1.166 +    Mozilla Bug 529621
   1.167 +  </a>
   1.168 +  <a target="_blank"
   1.169 +     title="when div has display style table-row"
   1.170 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=727722">
   1.171 +    Mozilla Bug 727722
   1.172 +  </a>
   1.173 +  <p id="display"></p>
   1.174 +  <div id="content" style="display: none"></div>
   1.175 +  <pre id="test">
   1.176 +  </pre>
   1.177 +
   1.178 +  <table id="table">
   1.179 +    <thead>
   1.180 +      <tr>
   1.181 +        <th>col1</th><th>col2</th>
   1.182 +      </tr>
   1.183 +    </thead>
   1.184 +    <caption>caption</caption>
   1.185 +    <tbody>
   1.186 +      <tr>
   1.187 +        <td>cell1</td><td>cell2</td>
   1.188 +      </tr>
   1.189 +    </tbody>
   1.190 +    <tr>
   1.191 +      <td>cell3</td><td>cell4</td>
   1.192 +    </tr>
   1.193 +    <caption>caption2</caption>
   1.194 +    <tfoot>
   1.195 +      <tr>
   1.196 +        <td>cell5</td><td>cell6</td>
   1.197 +      </tr>
   1.198 +    </tfoot>
   1.199 +  </table>
   1.200 +
   1.201 +  <table id="table_caption_empty">
   1.202 +    <caption></caption>
   1.203 +    <tr>
   1.204 +      <td>cell1</td><td>cell2</td>
   1.205 +    </tr>
   1.206 +  </table>
   1.207 +
   1.208 +  <table id="table_caption_firstempty">
   1.209 +    <caption></caption>
   1.210 +    <tr>
   1.211 +      <td>cell1</td><td>cell2</td>
   1.212 +    </tr>
   1.213 +    <caption>caption</caption>
   1.214 +  </table>
   1.215 +
   1.216 +  <table id="table_caption_intheend">
   1.217 +    <tr>
   1.218 +      <td>cell1</td><td>cell2</td>
   1.219 +    </tr>
   1.220 +    <caption>caption</caption>
   1.221 +  </table>
   1.222 +
   1.223 +  <table id="table2">
   1.224 +    <thead>
   1.225 +      <tr>
   1.226 +        <th>colheader</th>
   1.227 +      </tr>
   1.228 +    </thead>
   1.229 +    <tbody>
   1.230 +      <tr>
   1.231 +        <td>bla</td>
   1.232 +      </tr>
   1.233 +    </tbody>
   1.234 +  </table>
   1.235 +
   1.236 +  <table id="table3">
   1.237 +    <tr>
   1.238 +      <th>rowheader</th>
   1.239 +      <td>cell</td>
   1.240 +    </tr>
   1.241 +  </table>
   1.242 +
   1.243 +  <table id="table4">
   1.244 +    <div style="display: table-row">
   1.245 +      <td>cell1</td>
   1.246 +    </div>
   1.247 +  </table>
   1.248 +</body>
   1.249 +</html>

mercurial