tor-browser

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

content-attribute.html (3932B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>HTML Templates: Content attribute of template element is read-only</title>
      5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
      7 <meta name="assert" content="Content attribute of template element is read-only">
      8 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <script src='/html/resources/common.js'></script>
     12 </head>
     13 <body>
     14 <div id="log"></div>
     15 <script type="text/javascript">
     16 
     17 test(function() {
     18    var doc = newHTMLDocument();
     19    var template = doc.createElement('template');
     20 
     21    assert_readonly(template, 'content',
     22            'Content attribute of template element should be read-only');
     23 
     24 }, 'Content attribute of template element is read-only. ' +
     25    'Test empty template');
     26 
     27 
     28 test(function() {
     29    var doc = newHTMLDocument();
     30    var template = doc.createElement('template');
     31    var el1 = doc.createElement('div');
     32    var el2 = doc.createElement('span');
     33    el1.appendChild(el2);
     34 
     35    template.content.appendChild(el1);
     36 
     37    assert_readonly(template, 'content',
     38            'Content attribute of template element should be read-only');
     39 
     40 }, 'Content attribute of template element is read-only. ' +
     41    'Test not empty template populated by appendchild()');
     42 
     43 
     44 test(function() {
     45    var doc = newHTMLDocument();
     46    doc.body.innerHTML = '<template>Text<div>DIV</div></template>';
     47 
     48    var template = doc.querySelector('template');
     49 
     50    assert_readonly(template, 'content',
     51            'Content attribute of template element should be read-only');
     52 
     53 }, 'Content attribute of template element is read-only. ' +
     54    'Test not empty template populated by innerHTML');
     55 
     56 
     57 test(function() {
     58    var doc = newHTMLDocument();
     59    doc.body.innerHTML = '<template id="template1" content="Some text as a content"></template>';
     60 
     61    var template = doc.querySelector('#template1');
     62 
     63    assert_readonly(template, 'content',
     64            'Content attribute of template element should be read-only');
     65 
     66 }, 'Content attribute of template element is read-only. ' +
     67    'Test that custom content attribute named \'content\' doesn\'t ' +
     68    'make content IDL attribute writable');
     69 
     70 
     71 test(function() {
     72    var doc = newHTMLDocument();
     73    doc.body.innerHTML = '<template id="template1" content="<div id=div1>Div content</div>"></template>';
     74 
     75    var template = doc.querySelector('#template1');
     76 
     77    assert_readonly(template, 'content',
     78            'Content attribute of template element should be read-only');
     79 
     80    assert_equals(template.content.childNodes.length, 0,
     81            'Content attribute of template element should be read-only');
     82 
     83 }, 'Content attribute of template element is read-only. ' +
     84    'Test that custom content attribute named \'content\' doesn\'t ' +
     85    'affect content IDL attribute');
     86 
     87 
     88 testInIFrame('../resources/template-contents-attribute.html', function(context) {
     89    var doc = context.iframes[0].contentDocument;
     90 
     91    var template = doc.body.querySelector('template');
     92 
     93    assert_readonly(template, 'content',
     94            'Content attribute of template element should be read-only');
     95 
     96 }, 'Content attribute of template element is read-only. '
     97    + 'Text value of content attribute of template tag should be ignored, '
     98    + 'when loading document from a file');
     99 
    100 
    101 testInIFrame('../resources/template-contents.html', function(context) {
    102    var doc = context.iframes[0].contentDocument;
    103 
    104    var template = doc.body.querySelector('template');
    105 
    106    assert_readonly(template, 'content',
    107            'Content attribute of template element should be read-only');
    108 
    109 }, 'Content attribute of template element is read-only. '
    110    + 'Test content attribute of a document loaded from a file');
    111 
    112 </script>
    113 </body>
    114 </html>