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='../testcommon.js'></script>
12 <link rel="stylesheet" href="../../../../resources/testharness.css">
16 <script type="text/javascript">
19 var doc = newHTMLDocument();
20 var template = doc.createElement('template');
22 assert_readonly(template, 'content',
23 'Content attribute of template element should be read-only');
25 }, 'Content attribute of template element is read-only. ' +
26 'Test empty template');
30 var doc = newHTMLDocument();
31 var template = doc.createElement('template');
32 var el1 = doc.createElement('div');
33 var el2 = doc.createElement('span');
36 template.content.appendChild(el1);
38 assert_readonly(template, 'content',
39 'Content attribute of template element should be read-only');
41 }, 'Content attribute of template element is read-only. ' +
42 'Test not empty template populated by appendchild()');
46 var doc = newHTMLDocument();
47 doc.body.innerHTML = '<template>Text<div>DIV</div></template>';
49 var template = doc.querySelector('template');
51 assert_readonly(template, 'content',
52 'Content attribute of template element should be read-only');
54 }, 'Content attribute of template element is read-only. ' +
55 'Test not empty template populated by innerHTML');
59 var doc = newHTMLDocument();
60 doc.body.innerHTML = '<template id="template1" content="Some text as a content"></template>';
62 var template = doc.querySelector('#template1');
64 assert_readonly(template, 'content',
65 'Content attribute of template element should be read-only');
67 }, 'Content attribute of template element is read-only. ' +
68 'Test that custom content attribute named \'content\' doesn\'t ' +
69 'make content IDL attribute writable');
73 var doc = newHTMLDocument();
74 doc.body.innerHTML = '<template id="template1" content="<div id=div1>Div content</div>"></template>';
76 var template = doc.querySelector('#template1');
78 assert_readonly(template, 'content',
79 'Content attribute of template element should be read-only');
81 assert_equals(template.content.childNodes.length, 0,
82 'Content attribute of template element should be read-only');
84 }, 'Content attribute of template element is read-only. ' +
85 'Test that custom content attribute named \'content\' doesn\'t ' +
86 'affect content IDL attribute');
89 testInIFrame('../resources/template-contents-attribute.html', function(context) {
90 var doc = context.iframes[0].contentDocument;
92 var template = doc.body.querySelector('template');
94 assert_readonly(template, 'content',
95 'Content attribute of template element should be read-only');
97 }, 'Content attribute of template element is read-only. '
98 + 'Text value of content attribute of template tag should be ignored, '
99 + 'when loading document from a file');
102 testInIFrame('../resources/template-contents.html', function(context) {
103 var doc = context.iframes[0].contentDocument;
105 var template = doc.body.querySelector('template');
107 assert_readonly(template, 'content',
108 'Content attribute of template element should be read-only');
110 }, 'Content attribute of template element is read-only. '
111 + 'Test content attribute of a document loaded from a file');