Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / w3c / web-platform-tests / html-templates / parsing-html-templates / additions-to-the-in-head-insertion-mode / template-end-tag-without-start-one.html
1 <!DOCTYPE html>
2 <html>
3 <head>
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">
13 </head>
14 <body>
15 <div id="log"></div>
16 <script type="text/javascript">
17
18
19 test(function () {
20     var doc = newHTMLDocument();
21
22     doc.head.innerHTML = '</template>';
23
24     assert_equals(doc.head.childNodes.length, 0, 'Element must be ignored');
25
26 }, '</template> tag in HTML head without start one should be ignored');
27
28
29
30 test(function () {
31     var doc = newHTMLDocument();
32
33     doc.head.innerHTML = '<template id="tmpl"></template></template>';
34
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');
38
39 }, '</template> tag in HTML head without start one should be ignored. '
40     + 'Test valid <template> element and </template> tag after it');
41
42
43
44 test(function () {
45     var doc = newHTMLDocument();
46
47     doc.head.innerHTML = '</template><template id="tmpl"></template>';
48
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');
52
53 }, '</template> tag in HTML head without start one should be ignored. '
54     + 'Test valid <template> element and </template> tag before it');
55
56
57
58 test(function () {
59     var doc = newHTMLDocument();
60
61     doc.head.innerHTML = '</template><template id="tmpl"></template><title></title>';
62
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');
68
69 }, '</template> tag in HTML head without start one should be ignored. '
70     + 'Test valid <template> element, <title> element and </template> tag before them');
71
72
73
74 test(function () {
75     var doc = newHTMLDocument();
76
77     doc.head.innerHTML = '<template id="tmpl"></template><title></title></template>';
78
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');
84
85 }, '</template> tag in HTML head without start one should be ignored. '
86     + 'Test valid <template> element, <title> element and </template> tag after them');
87
88
89 testInIFrame('../../resources/end-template-tag-in-head.html', function(context) {
90     var doc = context.iframes[0].contentDocument;
91
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');
95
96 }, '</template> tag in HTML head without start one should be ignored. '
97     + 'Test HTML document loaded from file');
98
99
100 </script>
101 </body>
102 </html>