tor-browser

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

template-is-not-a-foster-parent-element.html (2454B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>HTML Templates: Template is not a foster parent element</title>
      5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <meta name="assert" content="When template element shouldn't be a foster parent then regular rules of foster parenting should be applied">
      7 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#foster-parent-addition">
      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 
     17 test(function () {
     18    var doc = newHTMLDocument();
     19 
     20    doc.body.innerHTML = '' +
     21    '<div id="tmplParent">' +
     22        '<template id="tmpl1">' +
     23            '<div id="fosterParent">' +
     24                '<table id="tbl">' +
     25                    '<tr><td>Cell 1</td></tr>' +
     26                // Misplaced <div>. It should be foster parented
     27                '<div id="orphanDiv">Orphan div content</div>' +
     28                    '<tr><td>Cell 2</td></tr>' +
     29                '</table>' +
     30            '</div>' +
     31        '</template>' +
     32    '</div>';
     33 
     34    var template = doc.querySelector('#tmpl1');
     35    var fosterParent = template.content.querySelector('#fosterParent');
     36    var div = template.content.querySelector('#orphanDiv');
     37 
     38    assert_equals(div.parentNode, fosterParent, 'Wrong foster parent element');
     39 
     40 }, 'Template is not a foster parent element. '
     41    + 'Test the case when <template> is higher in stack of open elements');
     42 
     43 
     44 
     45 test(function () {
     46    var doc = newHTMLDocument();
     47 
     48    doc.body.innerHTML = '' +
     49            '<div id="fosterParent">' +
     50                '<table id="tbl">' +
     51                    '<tr><td><template id="tmpl1">Template content</template></td></tr>' +
     52                // Misplaced <div>. It should be foster parented
     53                '<div id="orphanDiv">Orphan div content</div>' +
     54                    '<tr><td>Cell 2</td></tr>' +
     55                '</table>' +
     56            '</div>' +
     57    '</div>';
     58 
     59    var t = doc.querySelector('#tmpl1');
     60    var fosterParent = doc.querySelector('#fosterParent');
     61    var div = doc.querySelector('#orphanDiv');
     62 
     63    assert_equals(div.parentNode, fosterParent, 'Wrong foster parent element');
     64 
     65 }, 'Template is not a foster parent element. '
     66    + 'Test the case when <template> is lower in stack of open elements');
     67 
     68 </script>
     69 </body>
     70 </html>