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">
15 <script type="text/javascript">
17 function doTest(doc, tagToTest, templateInnerHTML, id, tagName, bodiesNum, footerIsNull,
18 footerId, headerIsNull, headerId) {
20 doc.body.innerHTML = '' +
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
34 '</' + tagToTest + '>' +
37 var table = doc.querySelector('#tbl');
38 var tr = doc.querySelector('#tr');
39 var td = doc.querySelector('#td');
40 var template = doc.querySelector('#tmpl1');
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');
45 assert_not_equals(template.content.querySelector('#' + id), null,
46 'Element should present in the template content');
48 if (tagName !== null) {
49 assert_equals(template.content.querySelector('#' + id).tagName, tagName,
50 'Wrong element in the template content');
53 assert_equals(table.caption, null, 'Table should have no caption');
56 assert_equals(table.tBodies.length, bodiesNum, 'Table should have '
57 + bodiesNum + ' body');
60 assert_equals(table.tFoot, null, 'Table should have no footer');
63 assert_not_equals(table.tFoot.id, footerId,
64 'Table should have no footer with id="' + footerId + '"');
67 assert_equals(table.tHead, null, 'Table should have no header');
70 assert_not_equals(table.tHead.id, headerId,
71 'Table should have no header with id="' + headerId + '"');
77 var doc = newHTMLDocument();
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'],
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'],
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'],
88 ['Clearing stack back to a table body context. Test </tbody>',
89 doc, 'tbody', '</tbody>', null, null],
91 ['Clearing stack back to a table body context. Test </thead>',
92 doc, 'thead', '</thead>', null, null],
94 ['Clearing stack back to a table body context. Test </tfoot>',
95 doc, 'tfoot', '</tfoot>', null, null],
97 ['Clearing stack back to a table body context. Test <caption> in <tbody>',
98 doc, 'tbody', '<caption id="caption1">Table Caption</caption>', 'caption1', 'CAPTION'],
100 ['Clearing stack back to a table body context. Test <caption> in <tfoot>',
101 doc, 'tfoot', '<caption id="caption2">Table Caption</caption>', 'caption2', 'CAPTION'],
103 ['Clearing stack back to a table body context. Test <caption> in <thead>',
104 doc, 'thead', '<caption id="caption3">Table Caption</caption>', 'caption3', 'CAPTION'],
106 ['Clearing stack back to a table body context. Test <col> in <tbody>',
107 doc, 'tbody', '<col id="col1" width="150"/>', 'col1', 'COL'],
109 ['Clearing stack back to a table body context. Test <col> in <tfoot>',
110 doc, 'tfoot', '<col id="col2" width="150"/>', 'col2', 'COL'],
112 ['Clearing stack back to a table body context. Test <col> in <thead>',
113 doc, 'thead', '<col id="col3" width="150"/>', 'col3', 'COL'],
115 ['Clearing stack back to a table body context. Test <colgroup> in <tbody>',
116 doc, 'tbody', '<colgroup id="colgroup1" width="150"/>', 'colgroup1', 'COLGROUP'],
118 ['Clearing stack back to a table body context. Test <colgroup> in <tfoot>',
119 doc, 'tfoot', '<colgroup id="colgroup2" width="150"/>', 'colgroup2', 'COLGROUP'],
121 ['Clearing stack back to a table body context. Test <colgroup> in <thead>',
122 doc, 'thead', '<colgroup id="colgroup3" width="150"/>', 'colgroup3', 'COLGROUP'],
124 ['Clearing stack back to a table body context. Test <tbody> in <tbody>',
125 doc, 'tbody', '<tbody id="tbody1"></tbody>', 'tbody1', 'TBODY', 1],
127 ['Clearing stack back to a table body context. Test <tbody> in <tfoot>',
128 doc, 'tfoot', '<tbody id="tbody2"></tbody>', 'tbody2', 'TBODY', 0],
130 ['Clearing stack back to a table body context. Test <tbody> in <thead>',
131 doc, 'thead', '<tbody id="tbody3"></tbody>', 'tbody3', 'TBODY', 0],
133 ['Clearing stack back to a table body context. Test <tfoot> in <tbody>',
134 doc, 'tbody', '<tfoot id="tfoot1"></tfoot>', 'tfoot1', 'TFOOT', null, true],
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'],
139 ['Clearing stack back to a table body context. Test <tfoot> in <thead>',
140 doc, 'thead', '<tfoot id="tfoot3"></tfoot>', 'tfoot3', 'TFOOT', null, true],
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],
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],
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'],
151 ['Clearing stack back to a table body context. Test </table> in <tbody>',
152 doc, 'tbody', '</table>', null, null, null, false, null, true],
154 ['Clearing stack back to a table body context. Test </table> in <tfoot>',
155 doc, 'tfoot', '</table>', null, null, null, false, null, true],
157 ['Clearing stack back to a table body context. Test </table> in <thead>',
158 doc, 'thead', '</table>', null, null],
160 ['Clearing stack back to a table body context. Test </tbody> in <thead>',
161 doc, 'thead', '</tbody>', null, null],
163 ['Clearing stack back to a table body context. Test </tbody> in <tfoot>',
164 doc, 'tfoot', '</tbody>', null, null],
166 ['Clearing stack back to a table body context. Test </thead> in <tbody>',
167 doc, 'tbody', '</thead>', null, null],
169 ['Clearing stack back to a table body context. Test </thead> in <tfoot>',
170 doc, 'tfoot', '</thead>', null, null],
172 ['Clearing stack back to a table body context. Test </tfoot> in <thead>',
173 doc, 'thead', '</tfoot>', null, null],
175 ['Clearing stack back to a table body context. Test </tfoot> in <tbody>',
176 doc, 'tbody', '</tfoot>', null, null]
179 generate_tests(doTest, parameters, 'Clearing stack back to a table body context.');