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-context.html (3288B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>HTML Templates: Clearing stack back to a table 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 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, templateInnerHTML, id, tagName, bodiesNum = null, footerIsNull,
     17        headerIsNull) {
     18 
     19    doc.body.innerHTML = '' +
     20        '<table id="tbl">' +
     21        '<template id="tmpl1">' +
     22        // When parser meets <caption>, <colgroup>, <tbody>, <tfoot>, <thead>, <col>
     23        // stack must be cleared back to table context.
     24        //But <template> tag should abort this process
     25        templateInnerHTML +
     26        '</template>' +
     27        '<tr id="tr">' +
     28        '<td id="td">' +
     29        '</td>' +
     30        '</tr>' +
     31        '</table>';
     32 
     33    var table = doc.querySelector('#tbl');
     34    var tr = doc.querySelector('#tr');
     35    var td = doc.querySelector('#td');
     36    var template = doc.querySelector('#tmpl1');
     37 
     38    assert_equals(table.rows.length, 1, 'Wrong number of table rows');
     39    assert_equals(table.rows[0].cells.length, 1, 'Wrong number of table cells');
     40    assert_equals(template.parentNode, table, 'Wrong template parent');
     41    assert_not_equals(template.content.querySelector('#' + id), null,
     42                'Element should present in the template content');
     43    assert_equals(doc.querySelector('#tbl').caption, null, 'Table should have no caption');
     44    assert_equals(template.content.querySelector('#' + id).tagName, tagName,
     45                'Wrong element in the template content');
     46    if (bodiesNum !== null) {
     47        assert_equals(table.tBodies.length, bodiesNum, 'Table should have '
     48                + bodiesNum + ' body');
     49    }
     50    if (footerIsNull) {
     51        assert_equals(table.tFoot, null, 'Table should have no footer');
     52    }
     53    if (headerIsNull) {
     54        assert_equals(table.tHead, null, 'Table should have no header');
     55    }
     56 }
     57 
     58 
     59 var doc = newHTMLDocument();
     60 var parameters = [
     61    ['Clearing stack back to a table context. Test <caption>',
     62     doc, '<caption id="caption1">Table caption</caption>', 'caption1', 'CAPTION'],
     63 
     64    ['Clearing stack back to a table context. Test <colgroup>',
     65     doc, '<colgroup id="colgroup1" width="100%"></colgroup>', 'colgroup1', 'COLGROUP'],
     66 
     67    ['Clearing stack back to a table context. Test <tbody>',
     68     doc, '<tbody id="tbody1"></tbody>', 'tbody1', 'TBODY', 1],
     69 
     70    ['Clearing stack back to a table context. Test <tfoot>',
     71     doc, '<tfoot id="tfoot1"></tfoot>', 'tfoot1', 'TFOOT', null, true],
     72 
     73    ['Clearing stack back to a table context. Test <thead>',
     74     doc, '<thead id="thead1"></thead>', 'thead1', 'THEAD', null, false, true],
     75 
     76    ['Clearing stack back to a table context. Test <col>',
     77     doc, '<col id="col1" width="100%"/>', 'col1', 'COL']
     78 ];
     79 
     80 // Clearing stack back to a table body context.
     81 generate_tests(doTest, parameters);
     82 
     83 </script>
     84 </body>
     85 </html>