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 / clearing-the-stack-back-to-a-given-context / clearing-stack-back-to-a-table-body-context.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>HTML Templates: Clearing stack back to a table body context</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="Clearing the stack back to a table body context must be aborted if the current node is template">
7 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#clearing-the-stack">
8 <script src="../../../../../resources/testharness.js"></script>
9 <script src="../../../../../resources/testharnessreport.js"></script>
10 <script src='../../testcommon.js'></script>
11 <link rel="stylesheet" href="../../../../../resources/testharness.css">
12 </head>
13 <body>
14 <div id="log"></div>
15 <script type="text/javascript">
16
17 function doTest(doc, tagToTest, templateInnerHTML, id, tagName, bodiesNum, footerIsNull,
18         footerId, headerIsNull, headerId) {
19
20     doc.body.innerHTML = '' +
21         '<table id="tbl">' +
22         '<' + tagToTest + '>' +
23         '<template id="tmpl1">' +
24         // When parser meets <tr>, </tbody>, </tfoot>, </thead>, <caption>, <col>,
25         // <colgroup>, <tbody>, <tfoot>, <thead>, </table>
26         // stack must be cleared back to table body context. But <template> tag should
27         // abort this
28         templateInnerHTML +
29         '</template>' +
30         '<tr id="tr">' +
31         '<td id="td">' +
32         '</td>' +
33         '</tr>' +
34         '</' + tagToTest + '>' +
35         '</table>';
36
37     var table = doc.querySelector('#tbl');
38     var tr = doc.querySelector('#tr');
39     var td = doc.querySelector('#td');
40     var template = doc.querySelector('#tmpl1');
41
42     assert_equals(table.rows.length, 1, 'Wrong number of table rows');
43     assert_equals(table.rows[0].cells.length, 1, 'Wrong number of table cells');
44     if (id !== null) {
45         assert_not_equals(template.content.querySelector('#' + id), null,
46                 'Element should present in the template content');
47     }
48     if (tagName !== null) {
49         assert_equals(template.content.querySelector('#' + id).tagName, tagName,
50                 'Wrong element in the template content');
51     }
52
53     assert_equals(table.caption, null, 'Table should have no caption');
54
55     if (bodiesNum) {
56         assert_equals(table.tBodies.length, bodiesNum, 'Table should have '
57                 + bodiesNum + ' body');
58     }
59     if (footerIsNull) {
60         assert_equals(table.tFoot, null, 'Table should have no footer');
61     }
62     if (footerId) {
63         assert_not_equals(table.tFoot.id, footerId,
64                 'Table should have no footer with id="' + footerId + '"');
65     }
66     if (headerIsNull) {
67         assert_equals(table.tHead, null, 'Table should have no header');
68     }
69     if (headerId) {
70         assert_not_equals(table.tHead.id, headerId,
71                 'Table should have no header with id="' + headerId + '"');
72     }
73 }
74
75
76
77 var doc = newHTMLDocument();
78 var parameters = [
79     ['Clearing stack back to a table body context. Test <tr> in <tbody>',
80      doc, 'tbody', '<tr id="tr1"><td>Cell content</td></tr>', 'tr1', 'TR'],
81
82     ['Clearing stack back to a table body context. Test <tr> in <thead>',
83      doc, 'thead', '<tr id="tr2"><td>Cell content</td></tr>', 'tr2', 'TR'],
84
85     ['Clearing stack back to a table body context. Test <tr> in <tfoot>',
86      doc, 'tfoot', '<tr id="tr3"><td>Cell content</td></tr>', 'tr3', 'TR'],
87
88     ['Clearing stack back to a table body context. Test </tbody>',
89      doc, 'tbody', '</tbody>', null, null],
90
91     ['Clearing stack back to a table body context. Test </thead>',
92      doc, 'thead', '</thead>', null, null],
93
94     ['Clearing stack back to a table body context. Test </tfoot>',
95      doc, 'tfoot', '</tfoot>', null, null],
96
97     ['Clearing stack back to a table body context. Test <caption> in <tbody>',
98      doc, 'tbody', '<caption id="caption1">Table Caption</caption>', 'caption1', 'CAPTION'],
99
100     ['Clearing stack back to a table body context. Test <caption> in <tfoot>',
101      doc, 'tfoot', '<caption id="caption2">Table Caption</caption>', 'caption2', 'CAPTION'],
102
103     ['Clearing stack back to a table body context. Test <caption> in <thead>',
104      doc, 'thead', '<caption id="caption3">Table Caption</caption>', 'caption3', 'CAPTION'],
105
106     ['Clearing stack back to a table body context. Test <col> in <tbody>',
107      doc, 'tbody', '<col id="col1" width="150"/>', 'col1', 'COL'],
108
109     ['Clearing stack back to a table body context. Test <col> in <tfoot>',
110      doc, 'tfoot', '<col id="col2" width="150"/>', 'col2', 'COL'],
111
112     ['Clearing stack back to a table body context. Test <col> in <thead>',
113      doc, 'thead', '<col id="col3" width="150"/>', 'col3', 'COL'],
114
115     ['Clearing stack back to a table body context. Test <colgroup> in <tbody>',
116      doc, 'tbody', '<colgroup id="colgroup1" width="150"/>', 'colgroup1', 'COLGROUP'],
117
118     ['Clearing stack back to a table body context. Test <colgroup> in <tfoot>',
119      doc, 'tfoot', '<colgroup id="colgroup2" width="150"/>', 'colgroup2', 'COLGROUP'],
120
121     ['Clearing stack back to a table body context. Test <colgroup> in <thead>',
122      doc, 'thead', '<colgroup id="colgroup3" width="150"/>', 'colgroup3', 'COLGROUP'],
123
124     ['Clearing stack back to a table body context. Test <tbody> in <tbody>',
125      doc, 'tbody', '<tbody id="tbody1"></tbody>', 'tbody1', 'TBODY', 1],
126
127     ['Clearing stack back to a table body context. Test <tbody> in <tfoot>',
128      doc, 'tfoot', '<tbody id="tbody2"></tbody>', 'tbody2', 'TBODY', 0],
129
130     ['Clearing stack back to a table body context. Test <tbody> in <thead>',
131      doc, 'thead', '<tbody id="tbody3"></tbody>', 'tbody3', 'TBODY', 0],
132
133     ['Clearing stack back to a table body context. Test <tfoot> in <tbody>',
134      doc, 'tbody', '<tfoot id="tfoot1"></tfoot>', 'tfoot1', 'TFOOT', null, true],
135
136     ['Clearing stack back to a table body context. Test <tfoot> in <tfoot>',
137      doc, 'tfoot', '<tfoot id="tfoot2"></tfoot>', 'tfoot2', 'TFOOT', null, false, 'tfoot2'],
138
139     ['Clearing stack back to a table body context. Test <tfoot> in <thead>',
140      doc, 'thead', '<tfoot id="tfoot3"></tfoot>', 'tfoot3', 'TFOOT', null, true],
141
142     ['Clearing stack back to a table body context. Test <thead> in <tbody>',
143      doc, 'tbody', '<thead id="thead1"></thead>', 'thead1', 'THEAD', null, false, null, true],
144
145     ['Clearing stack back to a table body context. Test <thead> in <tfoot>',
146      doc, 'tfoot', '<thead id="thead2"></thead>', 'thead2', 'THEAD', null, false, null, true],
147
148     ['Clearing stack back to a table body context. Test <thead> in <thead>',
149      doc, 'thead', '<thead id="thead3"></thead>', 'thead3', 'THEAD', null, false, null, false, 'thead3'],
150
151     ['Clearing stack back to a table body context. Test </table> in <tbody>',
152      doc, 'tbody', '</table>', null, null, null, false, null, true],
153
154     ['Clearing stack back to a table body context. Test </table> in <tfoot>',
155      doc, 'tfoot', '</table>', null, null, null, false, null, true],
156
157     ['Clearing stack back to a table body context. Test </table> in <thead>',
158      doc, 'thead', '</table>', null, null],
159
160     ['Clearing stack back to a table body context. Test </tbody> in <thead>',
161      doc, 'thead', '</tbody>', null, null],
162
163     ['Clearing stack back to a table body context. Test </tbody> in <tfoot>',
164      doc, 'tfoot', '</tbody>', null, null],
165
166     ['Clearing stack back to a table body context. Test </thead> in <tbody>',
167      doc, 'tbody', '</thead>', null, null],
168
169     ['Clearing stack back to a table body context. Test </thead> in <tfoot>',
170      doc, 'tfoot', '</thead>', null, null],
171
172     ['Clearing stack back to a table body context. Test </tfoot> in <thead>',
173      doc, 'thead', '</tfoot>', null, null],
174
175     ['Clearing stack back to a table body context. Test </tfoot> in <tbody>',
176      doc, 'tbody', '</tfoot>', null, null]
177 ];
178
179 generate_tests(doTest, parameters, 'Clearing stack back to a table body context.');
180
181 </script>
182 </body>
183 </html>