tor-browser

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

template-contents-owner-test-002.html (2502B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>HTML Templates: The template contents owner document (there's browsing context)</title>
      5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <meta name="assert" content="If template's enclosing document has browsing context, then templates content owner must be a new Document node without browsing context">
      7 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#definitions">
      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 testInIFrame(null, function(context) {
     18    var doc = context.iframes[0].contentDocument;
     19    var template = doc.createElement('template');
     20 
     21    var div = doc.createElement('div');
     22    div.setAttribute('id', 'div1');
     23 
     24    template.appendChild(div);
     25 
     26    doc.body.appendChild(template);
     27 
     28    // doc has browsing context. There should be another document as a template
     29    // content owner
     30    assert_not_equals(template.content.ownerDocument, doc, 'Wrong template owner document');
     31 
     32 }, 'The template contents owner document must be different from template owner document,' +
     33     ' which has browsing context. Template element is created by createElement()');
     34 
     35 
     36 
     37 testInIFrame(null, function(context) {
     38    var doc = context.iframes[0].contentDocument;
     39 
     40    doc.body.innerHTML = '<template><div>some text</div></template>';
     41 
     42    var template = doc.querySelector('template');
     43 
     44    // doc has browsing context. There should be another document as a template
     45    // content owner
     46    assert_not_equals(template.content.ownerDocument, doc, 'Wrong template owner document');
     47 
     48 }, 'The template contents owner document must be different from template owner document,' +
     49     ' which has browsing context. Template element is created via innerHTML');
     50 
     51 
     52 
     53 testInIFrame('../resources/template-contents.html', function(context) {
     54    var doc = context.iframes[0].contentDocument;
     55 
     56    var template = doc.querySelector('template');
     57 
     58    // doc has browsing context. There should be another document as a template
     59    // content owner
     60    assert_not_equals(template.content.ownerDocument, doc, 'Wrong template owner document');
     61 
     62 }, 'The template contents owner document must be different from template owner document,' +
     63     ' which has browsing context. Template element is created by HTML parser');
     64 
     65 </script>
     66 </body>
     67 </html>