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


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>HTML Templates: Clearing stack back to a table row 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 row 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, elementId) {
     17 
     18    doc.body.innerHTML = '' +
     19        '<table id="tbl">' +
     20        '<tr id="tr">' +
     21        '<template id="tmpl1">' +
     22        // When parser meets <th>, <td>, </tr>, stack must be cleared
     23        // back to table row context.
     24        // But <template> tag should abort this
     25        templateInnerHTML +
     26        '</template>' +
     27        '<td id="td">' +
     28        '</td>' +
     29        '</tr>' +
     30        '</table>';
     31 
     32    var table = doc.querySelector('#tbl');
     33    var tr = doc.querySelector('#tr');
     34    var td = doc.querySelector('#td');
     35    var template = doc.querySelector('#tmpl1');
     36 
     37    assert_equals(table.rows.length, 1, 'Wrong number of table rows');
     38    assert_equals(table.rows[0].cells.length, 1, 'Wrong number of table cells');
     39    assert_equals(template.parentNode, tr, 'Wrong template parent');
     40    if (id !== null) {
     41        assert_not_equals(template.content.querySelector('#' + id), null,
     42                    'Element should present in the template content');
     43    }
     44    if (tagName !== null) {
     45        assert_equals(template.content.querySelector('#' + id).tagName, tagName,
     46                'Wrong element in the template content');
     47    }
     48    if (elementId) {
     49        assert_equals(doc.querySelector('#' + elementId), null,
     50                'Table should have no element with ID ' + elementId);
     51    }
     52 }
     53 
     54 
     55 var doc = newHTMLDocument();
     56 var parameters = [
     57    ['Clearing stack back to a table row context. Test <th>',
     58     doc, '<th id="th1">Table header</th>', 'th1', 'TH', 'th1'],
     59 
     60    ['Clearing stack back to a table row context. Test <td>',
     61     doc, '<td id="td1">Table cell</td>', 'td1', 'TD', 'td1'],
     62 
     63     ['Clearing stack back to a table row context. Test </tr>',
     64      doc, '</tr>', null, null]
     65 ];
     66 
     67 // Clearing stack back to a table body context.
     68 generate_tests(doTest, parameters);
     69 
     70 </script>
     71 </body>
     72 </html>