summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/parsing/template/additions-to-the-in-head-insertion-mode/template-end-tag-without-start-one.html
blob: ccb43341bc0d6cee5cfd9669ab07a4f986122c38 (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
<!DOCTYPE html>
<html>
<head>
<title>HTML Templates: Template end tag without start one. Element should be ignored</title>
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
<meta name="assert" content="If parser in 'in head' insertion mode meets template end tag and if the stack of open elements has no template element in html scope, then this is a parse error; ignore the token">
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#in-head-addition">
<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();

    doc.head.innerHTML = '</template>';

    assert_equals(doc.head.childNodes.length, 0, 'Element must be ignored');

}, '</template> tag in HTML head without start one should be ignored');



test(function () {
    var doc = newHTMLDocument();

    doc.head.innerHTML = '<template id="tmpl"></template></template>';

    assert_equals(doc.head.childNodes.length, 1, 'Element must be ignored');
    assert_not_equals(doc.querySelector('#tmpl'), null,
            'Element should present it document head');

}, '</template> tag in HTML head without start one should be ignored. '
    + 'Test valid <template> element and </template> tag after it');



test(function () {
    var doc = newHTMLDocument();

    doc.head.innerHTML = '</template><template id="tmpl"></template>';

    assert_equals(doc.head.childNodes.length, 1, 'Element must be ignored');
    assert_not_equals(doc.querySelector('#tmpl'), null,
            'Element should present it document head');

}, '</template> tag in HTML head without start one should be ignored. '
    + 'Test valid <template> element and </template> tag before it');



test(function () {
    var doc = newHTMLDocument();

    doc.head.innerHTML = '</template><template id="tmpl"></template><title></title>';

    assert_equals(doc.head.childNodes.length, 2, 'Element must be ignored');
    assert_not_equals(doc.querySelector('#tmpl'), null,
            'Valid element should present it document head');
    assert_not_equals(doc.querySelector('title'), null,
            'Valid title element should present it document head');

}, '</template> tag in HTML head without start one should be ignored. '
    + 'Test valid <template> element, <title> element and </template> tag before them');



test(function () {
    var doc = newHTMLDocument();

    doc.head.innerHTML = '<template id="tmpl"></template><title></title></template>';

    assert_equals(doc.head.childNodes.length, 2, 'Element must be ignored');
    assert_not_equals(doc.querySelector('#tmpl'), null,
            'Valid element should present it document head');
    assert_not_equals(doc.querySelector('title'), null,
            'Valid title element should present it document head');

}, '</template> tag in HTML head without start one should be ignored. '
    + 'Test valid <template> element, <title> element and </template> tag after them');


testInIFrame('/html/semantics/scripting-1/the-template-element/resources/end-template-tag-in-head.html', function(context) {
    var doc = context.iframes[0].contentDocument;

    assert_equals(doc.head.querySelector('template'), null, '</template> must be ignored');
    assert_not_equals(doc.head.querySelector('title'), null,
            'Valid element should present it document head');

}, '</template> tag in HTML head without start one should be ignored. '
    + 'Test HTML document loaded from file');


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