summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/parsing/template/clearing-the-stack-back-to-a-given-context/clearing-stack-back-to-a-table-body-context.html
blob: a150faa1d7ee85091e46c0315c0f1472c7e90507 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html>
<head>
<title>HTML Templates: Clearing stack back to a table body context</title>
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<meta name="assert" content="Clearing the stack back to a table body context must be aborted if the current node is template">
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#clearing-the-stack">
<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">

function doTest(doc, tagToTest, templateInnerHTML, id, tagName, bodiesNum, footerIsNull,
        footerId, headerIsNull, headerId) {

    doc.body.innerHTML = '' +
        '<table id="tbl">' +
        '<' + tagToTest + '>' +
        '<template id="tmpl1">' +
        // When parser meets <tr>, </tbody>, </tfoot>, </thead>, <caption>, <col>,
        // <colgroup>, <tbody>, <tfoot>, <thead>, </table>
        // stack must be cleared back to table body context. But <template> tag should
        // abort this
        templateInnerHTML +
        '</template>' +
        '<tr id="tr">' +
        '<td id="td">' +
        '</td>' +
        '</tr>' +
        '</' + tagToTest + '>' +
        '</table>';

    var table = doc.querySelector('#tbl');
    var tr = doc.querySelector('#tr');
    var td = doc.querySelector('#td');
    var template = doc.querySelector('#tmpl1');

    assert_equals(table.rows.length, 1, 'Wrong number of table rows');
    assert_equals(table.rows[0].cells.length, 1, 'Wrong number of table cells');
    if (id !== null) {
        assert_not_equals(template.content.querySelector('#' + id), null,
                'Element should present in the template content');
    }
    if (tagName !== null) {
        assert_equals(template.content.querySelector('#' + id).tagName, tagName,
                'Wrong element in the template content');
    }

    assert_equals(table.caption, null, 'Table should have no caption');

    if (bodiesNum) {
        assert_equals(table.tBodies.length, bodiesNum, 'Table should have '
                + bodiesNum + ' body');
    }
    if (footerIsNull) {
        assert_equals(table.tFoot, null, 'Table should have no footer');
    }
    if (footerId) {
        assert_not_equals(table.tFoot.id, footerId,
                'Table should have no footer with id="' + footerId + '"');
    }
    if (headerIsNull) {
        assert_equals(table.tHead, null, 'Table should have no header');
    }
    if (headerId) {
        assert_not_equals(table.tHead.id, headerId,
                'Table should have no header with id="' + headerId + '"');
    }
}



var doc = newHTMLDocument();
var parameters = [
    ['Clearing stack back to a table body context. Test <tr> in <tbody>',
     doc, 'tbody', '<tr id="tr1"><td>Cell content</td></tr>', 'tr1', 'TR'],

    ['Clearing stack back to a table body context. Test <tr> in <thead>',
     doc, 'thead', '<tr id="tr2"><td>Cell content</td></tr>', 'tr2', 'TR'],

    ['Clearing stack back to a table body context. Test <tr> in <tfoot>',
     doc, 'tfoot', '<tr id="tr3"><td>Cell content</td></tr>', 'tr3', 'TR'],

    ['Clearing stack back to a table body context. Test </tbody>',
     doc, 'tbody', '</tbody>', null, null],

    ['Clearing stack back to a table body context. Test </thead>',
     doc, 'thead', '</thead>', null, null],

    ['Clearing stack back to a table body context. Test </tfoot>',
     doc, 'tfoot', '</tfoot>', null, null],

    ['Clearing stack back to a table body context. Test <caption> in <tbody>',
     doc, 'tbody', '<caption id="caption1">Table Caption</caption>', 'caption1', 'CAPTION'],

    ['Clearing stack back to a table body context. Test <caption> in <tfoot>',
     doc, 'tfoot', '<caption id="caption2">Table Caption</caption>', 'caption2', 'CAPTION'],

    ['Clearing stack back to a table body context. Test <caption> in <thead>',
     doc, 'thead', '<caption id="caption3">Table Caption</caption>', 'caption3', 'CAPTION'],

    ['Clearing stack back to a table body context. Test <col> in <tbody>',
     doc, 'tbody', '<col id="col1" width="150"/>', 'col1', 'COL'],

    ['Clearing stack back to a table body context. Test <col> in <tfoot>',
     doc, 'tfoot', '<col id="col2" width="150"/>', 'col2', 'COL'],

    ['Clearing stack back to a table body context. Test <col> in <thead>',
     doc, 'thead', '<col id="col3" width="150"/>', 'col3', 'COL'],

    ['Clearing stack back to a table body context. Test <colgroup> in <tbody>',
     doc, 'tbody', '<colgroup id="colgroup1" width="150"/>', 'colgroup1', 'COLGROUP'],

    ['Clearing stack back to a table body context. Test <colgroup> in <tfoot>',
     doc, 'tfoot', '<colgroup id="colgroup2" width="150"/>', 'colgroup2', 'COLGROUP'],

    ['Clearing stack back to a table body context. Test <colgroup> in <thead>',
     doc, 'thead', '<colgroup id="colgroup3" width="150"/>', 'colgroup3', 'COLGROUP'],

    ['Clearing stack back to a table body context. Test <tbody> in <tbody>',
     doc, 'tbody', '<tbody id="tbody1"></tbody>', 'tbody1', 'TBODY', 1],

    ['Clearing stack back to a table body context. Test <tbody> in <tfoot>',
     doc, 'tfoot', '<tbody id="tbody2"></tbody>', 'tbody2', 'TBODY', 0],

    ['Clearing stack back to a table body context. Test <tbody> in <thead>',
     doc, 'thead', '<tbody id="tbody3"></tbody>', 'tbody3', 'TBODY', 0],

    ['Clearing stack back to a table body context. Test <tfoot> in <tbody>',
     doc, 'tbody', '<tfoot id="tfoot1"></tfoot>', 'tfoot1', 'TFOOT', null, true],

    ['Clearing stack back to a table body context. Test <tfoot> in <tfoot>',
     doc, 'tfoot', '<tfoot id="tfoot2"></tfoot>', 'tfoot2', 'TFOOT', null, false, 'tfoot2'],

    ['Clearing stack back to a table body context. Test <tfoot> in <thead>',
     doc, 'thead', '<tfoot id="tfoot3"></tfoot>', 'tfoot3', 'TFOOT', null, true],

    ['Clearing stack back to a table body context. Test <thead> in <tbody>',
     doc, 'tbody', '<thead id="thead1"></thead>', 'thead1', 'THEAD', null, false, null, true],

    ['Clearing stack back to a table body context. Test <thead> in <tfoot>',
     doc, 'tfoot', '<thead id="thead2"></thead>', 'thead2', 'THEAD', null, false, null, true],

    ['Clearing stack back to a table body context. Test <thead> in <thead>',
     doc, 'thead', '<thead id="thead3"></thead>', 'thead3', 'THEAD', null, false, null, false, 'thead3'],

    ['Clearing stack back to a table body context. Test </table> in <tbody>',
     doc, 'tbody', '</table>', null, null, null, false, null, true],

    ['Clearing stack back to a table body context. Test </table> in <tfoot>',
     doc, 'tfoot', '</table>', null, null, null, false, null, true],

    ['Clearing stack back to a table body context. Test </table> in <thead>',
     doc, 'thead', '</table>', null, null],

    ['Clearing stack back to a table body context. Test </tbody> in <thead>',
     doc, 'thead', '</tbody>', null, null],

    ['Clearing stack back to a table body context. Test </tbody> in <tfoot>',
     doc, 'tfoot', '</tbody>', null, null],

    ['Clearing stack back to a table body context. Test </thead> in <tbody>',
     doc, 'tbody', '</thead>', null, null],

    ['Clearing stack back to a table body context. Test </thead> in <tfoot>',
     doc, 'tfoot', '</thead>', null, null],

    ['Clearing stack back to a table body context. Test </tfoot> in <thead>',
     doc, 'thead', '</tfoot>', null, null],

    ['Clearing stack back to a table body context. Test </tfoot> in <tbody>',
     doc, 'tbody', '</tfoot>', null, null]
];

generate_tests(doTest, parameters, 'Clearing stack back to a table body context.');

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