summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/content-attribute.html
blob: b4c11b841f15c76d145d8e890c7c3d5d231cf2f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html>
<head>
<title>HTML Templates: Content attribute of template element is read-only</title>
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
<meta name="assert" content="Content attribute of template element is read-only">
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src='/html/resources/common.js'></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">

test(function() {
    var doc = newHTMLDocument();
    var template = doc.createElement('template');

    assert_readonly(template, 'content',
            'Content attribute of template element should be read-only');

}, 'Content attribute of template element is read-only. ' +
    'Test empty template');


test(function() {
    var doc = newHTMLDocument();
    var template = doc.createElement('template');
    var el1 = doc.createElement('div');
    var el2 = doc.createElement('span');
    el1.appendChild(el2);

    template.content.appendChild(el1);

    assert_readonly(template, 'content',
            'Content attribute of template element should be read-only');

}, 'Content attribute of template element is read-only. ' +
    'Test not empty template populated by appendchild()');


test(function() {
    var doc = newHTMLDocument();
    doc.body.innerHTML = '<template>Text<div>DIV</div></template>';

    var template = doc.querySelector('template');

    assert_readonly(template, 'content',
            'Content attribute of template element should be read-only');

}, 'Content attribute of template element is read-only. ' +
    'Test not empty template populated by innerHTML');


test(function() {
    var doc = newHTMLDocument();
    doc.body.innerHTML = '<template id="template1" content="Some text as a content"></template>';

    var template = doc.querySelector('#template1');

    assert_readonly(template, 'content',
            'Content attribute of template element should be read-only');

}, 'Content attribute of template element is read-only. ' +
    'Test that custom content attribute named \'content\' doesn\'t ' +
    'make content IDL attribute writable');


test(function() {
    var doc = newHTMLDocument();
    doc.body.innerHTML = '<template id="template1" content="<div id=div1>Div content</div>"></template>';

    var template = doc.querySelector('#template1');

    assert_readonly(template, 'content',
            'Content attribute of template element should be read-only');

    assert_equals(template.content.childNodes.length, 0,
            'Content attribute of template element should be read-only');

}, 'Content attribute of template element is read-only. ' +
    'Test that custom content attribute named \'content\' doesn\'t ' +
    'affect content IDL attribute');


testInIFrame('../resources/template-contents-attribute.html', function(context) {
    var doc = context.iframes[0].contentDocument;

    var template = doc.body.querySelector('template');

    assert_readonly(template, 'content',
            'Content attribute of template element should be read-only');

}, 'Content attribute of template element is read-only. '
    + 'Text value of content attribute of template tag should be ignored, '
    + 'when loading document from a file');


testInIFrame('../resources/template-contents.html', function(context) {
    var doc = context.iframes[0].contentDocument;

    var template = doc.body.querySelector('template');

    assert_readonly(template, 'content',
            'Content attribute of template element should be read-only');

}, 'Content attribute of template element is read-only. '
    + 'Test content attribute of a document loaded from a file');

</script>
</body>
</html>