accessible/tests/mochitest/tree/test_table.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4   <title>HTML table tests</title>
     5   <link rel="stylesheet" type="text/css"
     6         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     8   <script type="application/javascript"
     9           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    11   <script type="application/javascript"
    12           src="../common.js"></script>
    13   <script type="application/javascript"
    14           src="../role.js"></script>
    16   <script type="application/javascript">
    17     function doTest()
    18     {
    19       //////////////////////////////////////////////////////////////////////////
    20       // tables having captions
    22       // Two captions, first is used, second is ignored.
    23       var accTree =
    24         { TABLE: [
    25           { CAPTION: [
    26             {
    27               role: ROLE_TEXT_LEAF,
    28               name: "caption"
    29              }
    30           ] },
    31           { ROW: [
    32             { COLUMNHEADER: [ { TEXT_LEAF: [ ] } ] },
    33             { COLUMNHEADER: [ { TEXT_LEAF: [ ] } ] }
    34           ] },
    35           { ROW: [
    36             { CELL: [ { TEXT_LEAF: [ ] } ] },
    37             { CELL: [ { TEXT_LEAF: [ ] } ] }
    38           ] },
    39           { ROW: [
    40             { CELL: [ { TEXT_LEAF: [ ] } ] },
    41             { CELL: [ { TEXT_LEAF: [ ] } ] }
    42           ] },
    43           { ROW: [
    44             { CELL: [ { TEXT_LEAF: [ ] } ] },
    45             { CELL: [ { TEXT_LEAF: [ ] } ] }
    46           ] }
    47         ] };
    49       testAccessibleTree("table", accTree);
    51       // One caption, empty text, caption is ignored.
    52       accTree =
    53         { TABLE: [
    54           { ROW: [
    55             { CELL: [ { TEXT_LEAF: [ ] } ] },
    56             { CELL: [ { TEXT_LEAF: [ ] } ] }
    57           ] }
    58         ] };
    60       testAccessibleTree("table_caption_empty", accTree);
    62       // Two captions, first has empty text, both are ignored.
    63       accTree =
    64         { TABLE: [
    65           { ROW: [
    66             { CELL: [ { TEXT_LEAF: [ ] } ] },
    67             { CELL: [ { TEXT_LEAF: [ ] } ] }
    68           ] }
    69         ] };
    71       testAccessibleTree("table_caption_firstempty", accTree);
    73       // One caption, placed in the end of table. In use.
    74       accTree =
    75         { TABLE: [
    76           { CAPTION: [
    77             {
    78               role: ROLE_TEXT_LEAF,
    79               name: "caption"
    80              }
    81           ] },
    82           { ROW: [
    83             { CELL: [ { TEXT_LEAF: [ ] } ] },
    84             { CELL: [ { TEXT_LEAF: [ ] } ] }
    85           ] }
    86         ] };
    88       testAccessibleTree("table_caption_intheend", accTree);
    90       //////////////////////////////////////////////////////////////////////////
    91       // table2 (consist of one column)
    93       accTree = {
    94         role: ROLE_TABLE,
    95         children: [
    96           {
    97             role: ROLE_ROW,
    98             children: [
    99               {
   100                 role: ROLE_COLUMNHEADER
   101               }
   102             ]
   103           },
   104           {
   105             role: ROLE_ROW,
   106             children: [
   107               {
   108                 role: ROLE_CELL
   109               }
   110             ]
   111           }
   112         ]
   113       };
   115       testAccessibleTree("table2", accTree);
   117       //////////////////////////////////////////////////////////////////////////
   118       // table3 (consist of one row)
   120       accTree = {
   121         role: ROLE_TABLE,
   122         children: [
   123           {
   124             role: ROLE_ROW,
   125             children: [
   126               {
   127                 role: ROLE_ROWHEADER
   128               },
   129               {
   130                 role: ROLE_CELL
   131               }
   132             ]
   133           }
   134         ]
   135       };
   137       testAccessibleTree("table3", accTree);
   139       /////////////////////////////////////////////////////////////////////////
   140       // table4 (display: table-row)
   141       accTree = 
   142         { TABLE: [
   143           { ROW: [
   144             { CELL: [
   145               { TEXT_LEAF: [ ] }
   146             ] }
   147           ] } ]
   148         };
   149       testAccessibleTree("table4", accTree);
   151       SimpleTest.finish();
   152     }
   154     SimpleTest.waitForExplicitFinish();
   155     addA11yLoadEvent(doTest);
   156   </script>
   157 </head>
   158 <body>
   160   <a target="_blank"
   161      title="When a table has only one column per row and that column happens to be a column header its role is exposed wrong"
   162      href="https://bugzilla.mozilla.org/show_bug.cgi?id=529621">
   163     Mozilla Bug 529621
   164   </a>
   165   <a target="_blank"
   166      title="when div has display style table-row"
   167      href="https://bugzilla.mozilla.org/show_bug.cgi?id=727722">
   168     Mozilla Bug 727722
   169   </a>
   170   <p id="display"></p>
   171   <div id="content" style="display: none"></div>
   172   <pre id="test">
   173   </pre>
   175   <table id="table">
   176     <thead>
   177       <tr>
   178         <th>col1</th><th>col2</th>
   179       </tr>
   180     </thead>
   181     <caption>caption</caption>
   182     <tbody>
   183       <tr>
   184         <td>cell1</td><td>cell2</td>
   185       </tr>
   186     </tbody>
   187     <tr>
   188       <td>cell3</td><td>cell4</td>
   189     </tr>
   190     <caption>caption2</caption>
   191     <tfoot>
   192       <tr>
   193         <td>cell5</td><td>cell6</td>
   194       </tr>
   195     </tfoot>
   196   </table>
   198   <table id="table_caption_empty">
   199     <caption></caption>
   200     <tr>
   201       <td>cell1</td><td>cell2</td>
   202     </tr>
   203   </table>
   205   <table id="table_caption_firstempty">
   206     <caption></caption>
   207     <tr>
   208       <td>cell1</td><td>cell2</td>
   209     </tr>
   210     <caption>caption</caption>
   211   </table>
   213   <table id="table_caption_intheend">
   214     <tr>
   215       <td>cell1</td><td>cell2</td>
   216     </tr>
   217     <caption>caption</caption>
   218   </table>
   220   <table id="table2">
   221     <thead>
   222       <tr>
   223         <th>colheader</th>
   224       </tr>
   225     </thead>
   226     <tbody>
   227       <tr>
   228         <td>bla</td>
   229       </tr>
   230     </tbody>
   231   </table>
   233   <table id="table3">
   234     <tr>
   235       <th>rowheader</th>
   236       <td>cell</td>
   237     </tr>
   238   </table>
   240   <table id="table4">
   241     <div style="display: table-row">
   242       <td>cell1</td>
   243     </div>
   244   </table>
   245 </body>
   246 </html>

mercurial