4 <title>HTML Templates: Template end tag without start one. Element should be ignored</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
7 <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">
8 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#in-head-addition">
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">
20 var doc = newHTMLDocument();
22 doc.head.innerHTML = '</template>';
24 assert_equals(doc.head.childNodes.length, 0, 'Element must be ignored');
26 }, '</template> tag in HTML head without start one should be ignored');
31 var doc = newHTMLDocument();
33 doc.head.innerHTML = '<template id="tmpl"></template></template>';
35 assert_equals(doc.head.childNodes.length, 1, 'Element must be ignored');
36 assert_not_equals(doc.querySelector('#tmpl'), null,
37 'Element should present it document head');
39 }, '</template> tag in HTML head without start one should be ignored. '
40 + 'Test valid <template> element and </template> tag after it');
45 var doc = newHTMLDocument();
47 doc.head.innerHTML = '</template><template id="tmpl"></template>';
49 assert_equals(doc.head.childNodes.length, 1, 'Element must be ignored');
50 assert_not_equals(doc.querySelector('#tmpl'), null,
51 'Element should present it document head');
53 }, '</template> tag in HTML head without start one should be ignored. '
54 + 'Test valid <template> element and </template> tag before it');
59 var doc = newHTMLDocument();
61 doc.head.innerHTML = '</template><template id="tmpl"></template><title></title>';
63 assert_equals(doc.head.childNodes.length, 2, 'Element must be ignored');
64 assert_not_equals(doc.querySelector('#tmpl'), null,
65 'Valid element should present it document head');
66 assert_not_equals(doc.querySelector('title'), null,
67 'Valid title element should present it document head');
69 }, '</template> tag in HTML head without start one should be ignored. '
70 + 'Test valid <template> element, <title> element and </template> tag before them');
75 var doc = newHTMLDocument();
77 doc.head.innerHTML = '<template id="tmpl"></template><title></title></template>';
79 assert_equals(doc.head.childNodes.length, 2, 'Element must be ignored');
80 assert_not_equals(doc.querySelector('#tmpl'), null,
81 'Valid element should present it document head');
82 assert_not_equals(doc.querySelector('title'), null,
83 'Valid title element should present it document head');
85 }, '</template> tag in HTML head without start one should be ignored. '
86 + 'Test valid <template> element, <title> element and </template> tag after them');
89 testInIFrame('../../resources/end-template-tag-in-head.html', function(context) {
90 var doc = context.iframes[0].contentDocument;
92 assert_equals(doc.head.querySelector('template'), null, '</template> must be ignored');
93 assert_not_equals(doc.head.querySelector('title'), null,
94 'Valid element should present it document head');
96 }, '</template> tag in HTML head without start one should be ignored. '
97 + 'Test HTML document loaded from file');