tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

clearing-stack-back-to-a-table-body-context.html (7815B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>HTML Templates: Clearing stack back to a table body context</title>
      5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <meta name="assert" content="Clearing the stack back to a table body context must be aborted if the current node is template">
      7 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#clearing-the-stack">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="/html/resources/common.js"></script>
     11 </head>
     12 <body>
     13 <div id="log"></div>
     14 <script type="text/javascript">
     15 
     16 function doTest(doc, tagToTest, templateInnerHTML, id, tagName, bodiesNum = null, footerIsNull,
     17        footerId, headerIsNull, headerId) {
     18 
     19    doc.body.innerHTML = '' +
     20        '<table id="tbl">' +
     21        '<' + tagToTest + '>' +
     22        '<template id="tmpl1">' +
     23        // When parser meets <tr>, </tbody>, </tfoot>, </thead>, <caption>, <col>,
     24        // <colgroup>, <tbody>, <tfoot>, <thead>, </table>
     25        // stack must be cleared back to table body context. But <template> tag should
     26        // abort this
     27        templateInnerHTML +
     28        '</template>' +
     29        '<tr id="tr">' +
     30        '<td id="td">' +
     31        '</td>' +
     32        '</tr>' +
     33        '</' + tagToTest + '>' +
     34        '</table>';
     35 
     36    var table = doc.querySelector('#tbl');
     37    var tr = doc.querySelector('#tr');
     38    var td = doc.querySelector('#td');
     39    var template = doc.querySelector('#tmpl1');
     40 
     41    assert_equals(table.rows.length, 1, 'Wrong number of table rows');
     42    assert_equals(table.rows[0].cells.length, 1, 'Wrong number of table cells');
     43    if (id !== null) {
     44        assert_not_equals(template.content.querySelector('#' + id), null,
     45                'Element should present in the template content');
     46    }
     47    if (tagName !== null) {
     48        assert_equals(template.content.querySelector('#' + id).tagName, tagName,
     49                'Wrong element in the template content');
     50    }
     51 
     52    assert_equals(table.caption, null, 'Table should have no caption');
     53 
     54    if (bodiesNum !== null) {
     55        assert_equals(table.tBodies.length, bodiesNum, 'Table should have '
     56                + bodiesNum + ' body');
     57    }
     58    if (footerIsNull) {
     59        assert_equals(table.tFoot, null, 'Table should have no footer');
     60    }
     61    if (footerId) {
     62        assert_not_equals(table.tFoot.id, footerId,
     63                'Table should have no footer with id="' + footerId + '"');
     64    }
     65    if (headerIsNull) {
     66        assert_equals(table.tHead, null, 'Table should have no header');
     67    }
     68    if (headerId) {
     69        assert_not_equals(table.tHead.id, headerId,
     70                'Table should have no header with id="' + headerId + '"');
     71    }
     72 }
     73 
     74 
     75 
     76 var doc = newHTMLDocument();
     77 var parameters = [
     78    ['Clearing stack back to a table body context. Test <tr> in <tbody>',
     79     doc, 'tbody', '<tr id="tr1"><td>Cell content</td></tr>', 'tr1', 'TR'],
     80 
     81    ['Clearing stack back to a table body context. Test <tr> in <thead>',
     82     doc, 'thead', '<tr id="tr2"><td>Cell content</td></tr>', 'tr2', 'TR'],
     83 
     84    ['Clearing stack back to a table body context. Test <tr> in <tfoot>',
     85     doc, 'tfoot', '<tr id="tr3"><td>Cell content</td></tr>', 'tr3', 'TR'],
     86 
     87    ['Clearing stack back to a table body context. Test </tbody>',
     88     doc, 'tbody', '</tbody>', null, null],
     89 
     90    ['Clearing stack back to a table body context. Test </thead>',
     91     doc, 'thead', '</thead>', null, null],
     92 
     93    ['Clearing stack back to a table body context. Test </tfoot>',
     94     doc, 'tfoot', '</tfoot>', null, null],
     95 
     96    ['Clearing stack back to a table body context. Test <caption> in <tbody>',
     97     doc, 'tbody', '<caption id="caption1">Table Caption</caption>', 'caption1', 'CAPTION'],
     98 
     99    ['Clearing stack back to a table body context. Test <caption> in <tfoot>',
    100     doc, 'tfoot', '<caption id="caption2">Table Caption</caption>', 'caption2', 'CAPTION'],
    101 
    102    ['Clearing stack back to a table body context. Test <caption> in <thead>',
    103     doc, 'thead', '<caption id="caption3">Table Caption</caption>', 'caption3', 'CAPTION'],
    104 
    105    ['Clearing stack back to a table body context. Test <col> in <tbody>',
    106     doc, 'tbody', '<col id="col1" width="150"/>', 'col1', 'COL'],
    107 
    108    ['Clearing stack back to a table body context. Test <col> in <tfoot>',
    109     doc, 'tfoot', '<col id="col2" width="150"/>', 'col2', 'COL'],
    110 
    111    ['Clearing stack back to a table body context. Test <col> in <thead>',
    112     doc, 'thead', '<col id="col3" width="150"/>', 'col3', 'COL'],
    113 
    114    ['Clearing stack back to a table body context. Test <colgroup> in <tbody>',
    115     doc, 'tbody', '<colgroup id="colgroup1" width="150"></colgroup>', 'colgroup1', 'COLGROUP'],
    116 
    117    ['Clearing stack back to a table body context. Test <colgroup> in <tfoot>',
    118     doc, 'tfoot', '<colgroup id="colgroup2" width="150"></colgroup>', 'colgroup2', 'COLGROUP'],
    119 
    120    ['Clearing stack back to a table body context. Test <colgroup> in <thead>',
    121     doc, 'thead', '<colgroup id="colgroup3" width="150"></colgroup>', 'colgroup3', 'COLGROUP'],
    122 
    123    ['Clearing stack back to a table body context. Test <tbody> in <tbody>',
    124     doc, 'tbody', '<tbody id="tbody1"></tbody>', 'tbody1', 'TBODY', 1],
    125 
    126    ['Clearing stack back to a table body context. Test <tbody> in <tfoot>',
    127     doc, 'tfoot', '<tbody id="tbody2"></tbody>', 'tbody2', 'TBODY', 0],
    128 
    129    ['Clearing stack back to a table body context. Test <tbody> in <thead>',
    130     doc, 'thead', '<tbody id="tbody3"></tbody>', 'tbody3', 'TBODY', 0],
    131 
    132    ['Clearing stack back to a table body context. Test <tfoot> in <tbody>',
    133     doc, 'tbody', '<tfoot id="tfoot1"></tfoot>', 'tfoot1', 'TFOOT', null, true],
    134 
    135    ['Clearing stack back to a table body context. Test <tfoot> in <tfoot>',
    136     doc, 'tfoot', '<tfoot id="tfoot2"></tfoot>', 'tfoot2', 'TFOOT', null, false, 'tfoot2'],
    137 
    138    ['Clearing stack back to a table body context. Test <tfoot> in <thead>',
    139     doc, 'thead', '<tfoot id="tfoot3"></tfoot>', 'tfoot3', 'TFOOT', null, true],
    140 
    141    ['Clearing stack back to a table body context. Test <thead> in <tbody>',
    142     doc, 'tbody', '<thead id="thead1"></thead>', 'thead1', 'THEAD', null, false, null, true],
    143 
    144    ['Clearing stack back to a table body context. Test <thead> in <tfoot>',
    145     doc, 'tfoot', '<thead id="thead2"></thead>', 'thead2', 'THEAD', null, false, null, true],
    146 
    147    ['Clearing stack back to a table body context. Test <thead> in <thead>',
    148     doc, 'thead', '<thead id="thead3"></thead>', 'thead3', 'THEAD', null, false, null, false, 'thead3'],
    149 
    150    ['Clearing stack back to a table body context. Test </table> in <tbody>',
    151     doc, 'tbody', '</table>', null, null, null, false, null, true],
    152 
    153    ['Clearing stack back to a table body context. Test </table> in <tfoot>',
    154     doc, 'tfoot', '</table>', null, null, null, false, null, true],
    155 
    156    ['Clearing stack back to a table body context. Test </table> in <thead>',
    157     doc, 'thead', '</table>', null, null],
    158 
    159    ['Clearing stack back to a table body context. Test </tbody> in <thead>',
    160     doc, 'thead', '</tbody>', null, null],
    161 
    162    ['Clearing stack back to a table body context. Test </tbody> in <tfoot>',
    163     doc, 'tfoot', '</tbody>', null, null],
    164 
    165    ['Clearing stack back to a table body context. Test </thead> in <tbody>',
    166     doc, 'tbody', '</thead>', null, null],
    167 
    168    ['Clearing stack back to a table body context. Test </thead> in <tfoot>',
    169     doc, 'tfoot', '</thead>', null, null],
    170 
    171    ['Clearing stack back to a table body context. Test </tfoot> in <thead>',
    172     doc, 'thead', '</tfoot>', null, null],
    173 
    174    ['Clearing stack back to a table body context. Test </tfoot> in <tbody>',
    175     doc, 'tbody', '</tfoot>', null, null]
    176 ];
    177 
    178 // Clearing stack back to a table body context.
    179 generate_tests(doTest, parameters);
    180 
    181 </script>
    182 </body>
    183 </html>