summaryrefslogtreecommitdiff
path: root/tests/html5lib-tests/tokenizer/domjs.test
blob: 1373b27fbd95b5a6070af1d2bd5792697bf72f6e (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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
{
    "tests": [
        {
            "description":"CR in bogus comment state",
            "input":"<?\u000d",
            "output":[["Comment", "?\u000a"]],
            "errors":[
                { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 }
            ]
        },
        {
            "description":"CRLF in bogus comment state",
            "input":"<?\u000d\u000a",
            "output":[["Comment", "?\u000a"]],
            "errors":[
                { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 }
            ]
        },
        {
            "description":"CRLFLF in bogus comment state",
            "input":"<?\u000d\u000a\u000a",
            "output":[["Comment", "?\u000a\u000a"]],
            "errors":[
                { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 }
            ]
        },
        {
            "description":"Raw NUL replacement",
            "doubleEscaped":true,
            "initialStates":["RCDATA state", "RAWTEXT state", "PLAINTEXT state", "Script data state"],
            "input":"\\u0000",
            "output":[["Character", "\\uFFFD"]],
            "errors":[
                { "code": "unexpected-null-character", "line": 1, "col": 1 }
            ]
        },
        {
            "description":"NUL in CDATA section",
            "doubleEscaped":true,
            "initialStates":["CDATA section state"],
            "input":"\\u0000]]>",
            "output":[["Character", "\\u0000"]]
        },
        {
           "description":"NUL in script HTML comment",
           "doubleEscaped":true,
           "initialStates":["Script data state"],
           "input":"<!--test\\u0000--><!--test-\\u0000--><!--test--\\u0000-->",
           "output":[["Character", "<!--test\\uFFFD--><!--test-\\uFFFD--><!--test--\\uFFFD-->"]],
           "errors":[
               { "code": "unexpected-null-character", "line": 1, "col": 9 },
               { "code": "unexpected-null-character", "line": 1, "col": 22 },
               { "code": "unexpected-null-character", "line": 1, "col": 36 }
           ]
        },
        {
           "description":"NUL in script HTML comment - double escaped",
           "doubleEscaped":true,
           "initialStates":["Script data state"],
           "input":"<!--<script>\\u0000--><!--<script>-\\u0000--><!--<script>--\\u0000-->",
           "output":[["Character", "<!--<script>\\uFFFD--><!--<script>-\\uFFFD--><!--<script>--\\uFFFD-->"]],
           "errors":[
                { "code": "unexpected-null-character", "line": 1, "col": 13 },
                { "code": "unexpected-null-character", "line": 1, "col": 30 },
                { "code": "unexpected-null-character", "line": 1, "col": 48 }
           ]
        },
        {
           "description":"EOF in script HTML comment",
           "initialStates":["Script data state"],
           "input":"<!--test",
           "output":[["Character", "<!--test"]],
           "errors":[
               { "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 9 }
           ]
        },
        {
           "description":"EOF in script HTML comment after dash",
           "initialStates":["Script data state"],
           "input":"<!--test-",
           "output":[["Character", "<!--test-"]],
           "errors":[
               { "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 10 }
           ]
        },
        {
           "description":"EOF in script HTML comment after dash dash",
           "initialStates":["Script data state"],
           "input":"<!--test--",
           "output":[["Character", "<!--test--"]],
           "errors":[
               { "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 11 }
           ]
        },
        {
           "description":"EOF in script HTML comment double escaped after dash",
           "initialStates":["Script data state"],
           "input":"<!--<script>-",
           "output":[["Character", "<!--<script>-"]],
           "errors":[
               { "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 14 }
           ]
        },
        {
           "description":"EOF in script HTML comment double escaped after dash dash",
           "initialStates":["Script data state"],
           "input":"<!--<script>--",
           "output":[["Character", "<!--<script>--"]],
           "errors":[
               { "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 15 }
           ]
        },
        {
           "description":"EOF in script HTML comment - double escaped",
           "initialStates":["Script data state"],
           "input":"<!--<script>",
           "output":[["Character", "<!--<script>"]],
           "errors":[
               { "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 13 }
           ]
        },
        {
            "description":"Dash in script HTML comment",
            "initialStates":["Script data state"],
            "input":"<!-- - -->",
            "output":[["Character", "<!-- - -->"]]
        },
        {
            "description":"Dash less-than in script HTML comment",
            "initialStates":["Script data state"],
            "input":"<!-- -< -->",
            "output":[["Character", "<!-- -< -->"]]
        },
        {
            "description":"Dash at end of script HTML comment",
            "initialStates":["Script data state"],
            "input":"<!--test--->",
            "output":[["Character", "<!--test--->"]]
        },
        {
            "description":"</script> in script HTML comment",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!-- </script> --></script>",
            "output":[["Character", "<!-- "], ["EndTag", "script"], ["Character", " -->"], ["EndTag", "script"]]
        },
        {
            "description":"</script> in script HTML comment - double escaped",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!-- <script></script> --></script>",
            "output":[["Character", "<!-- <script></script> -->"], ["EndTag", "script"]]
        },
        {
            "description":"</script> in script HTML comment - double escaped with nested <script>",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!-- <script><script></script></script> --></script>",
            "output":[["Character", "<!-- <script><script></script>"], ["EndTag", "script"], ["Character", " -->"], ["EndTag", "script"]]
        },
        {
            "description":"</script> in script HTML comment - double escaped with abrupt end",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!-- <script>--></script> --></script>",
            "output":[["Character", "<!-- <script>-->"], ["EndTag", "script"], ["Character", " -->"], ["EndTag", "script"]]
        },
        {
            "description":"Incomplete start tag in script HTML comment double escaped",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!--<scrip></script>-->",
            "output":[["Character", "<!--<scrip>"], ["EndTag", "script"], ["Character", "-->"]]
        },
        {
            "description":"Unclosed start tag in script HTML comment double escaped",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!--<script</script>-->",
            "output":[["Character", "<!--<script"], ["EndTag", "script"], ["Character", "-->"]]
        },
        {
            "description":"Incomplete end tag in script HTML comment double escaped",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!--<script></scrip>-->",
            "output":[["Character", "<!--<script></scrip>-->"]]
        },
        {
            "description":"Unclosed end tag in script HTML comment double escaped",
            "initialStates":["Script data state"],
            "lastStartTag":"script",
            "input":"<!--<script></script-->",
            "output":[["Character", "<!--<script></script-->"]]
        },
        {
            "description":"leading U+FEFF must pass through",
            "initialStates":["Data state", "RCDATA state", "RAWTEXT state", "Script data state"],
            "doubleEscaped":true,
            "input":"\\uFEFFfoo\\uFEFFbar",
            "output":[["Character", "\\uFEFFfoo\\uFEFFbar"]]
        },
        {
            "description":"Non BMP-charref in RCDATA",
            "initialStates":["RCDATA state"],
            "input":"&NotEqualTilde;",
            "output":[["Character", "\u2242\u0338"]]
        },
        {
            "description":"Bad charref in RCDATA",
            "initialStates":["RCDATA state"],
            "input":"&NotEqualTild;",
            "output":[["Character", "&NotEqualTild;"]],
            "errors":[
               { "code": "unknown-named-character-reference", "line": 1, "col": 14 }
            ]
        },
        {
            "description":"lowercase endtags",
            "initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
            "lastStartTag":"xmp",
            "input":"</XMP>",
            "output":[["EndTag","xmp"]]
        },
        {
            "description":"bad endtag (space before name)",
            "initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
            "lastStartTag":"xmp",
            "input":"</ XMP>",
            "output":[["Character","</ XMP>"]]
        },
        {
            "description":"bad endtag (not matching last start tag)",
            "initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
            "lastStartTag":"xmp",
            "input":"</xm>",
            "output":[["Character","</xm>"]]
        },
        {
            "description":"bad endtag (without close bracket)",
            "initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
            "lastStartTag":"xmp",
            "input":"</xm ",
            "output":[["Character","</xm "]]
        },
        {
            "description":"bad endtag (trailing solidus)",
            "initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
            "lastStartTag":"xmp",
            "input":"</xm/",
            "output":[["Character","</xm/"]]
        },
        {
            "description":"Non BMP-charref in attribute",
            "input":"<p id=\"&NotEqualTilde;\">",
            "output":[["StartTag", "p", {"id":"\u2242\u0338"}]]
        },
        {
            "description":"--!NUL in comment ",
            "doubleEscaped":true,
            "input":"<!----!\\u0000-->",
            "output":[["Comment", "--!\\uFFFD"]],
            "errors":[
                { "code": "unexpected-null-character", "line": 1, "col": 8 }
            ]
        },
        {
            "description":"space EOF after doctype ",
            "input":"<!DOCTYPE html ",
            "output":[["DOCTYPE", "html", null, null , false]],
            "errors":[
                { "code": "eof-in-doctype", "line": 1, "col": 16 }
            ]
        },
        {
            "description":"CDATA in HTML content",
            "input":"<![CDATA[foo]]>",
            "output":[["Comment", "[CDATA[foo]]"]],
            "errors":[
                { "code": "cdata-in-html-content", "line": 1, "col": 9 }
            ]
        },
        {
            "description":"CDATA content",
            "input":"foo&#32;]]>",
            "initialStates":["CDATA section state"],
            "output":[["Character", "foo&#32;"]]
        },
        {
            "description":"CDATA followed by HTML content",
            "input":"foo&#32;]]>&#32;",
            "initialStates":["CDATA section state"],
            "output":[["Character", "foo&#32; "]]
        },
        {
            "description":"CDATA with extra bracket",
            "input":"foo]]]>",
            "initialStates":["CDATA section state"],
            "output":[["Character", "foo]"]]
        },
        {
            "description":"CDATA without end marker",
            "input":"foo",
            "initialStates":["CDATA section state"],
            "output":[["Character", "foo"]],
            "errors":[
                { "code": "eof-in-cdata", "line": 1, "col": 4 }
            ]
        },
        {
            "description":"CDATA with single bracket ending",
            "input":"foo]",
            "initialStates":["CDATA section state"],
            "output":[["Character", "foo]"]],
            "errors":[
                { "code": "eof-in-cdata", "line": 1, "col": 5 }
            ]
        },
        {
            "description":"CDATA with two brackets ending",
            "input":"foo]]",
            "initialStates":["CDATA section state"],
            "output":[["Character", "foo]]"]],
            "errors":[
                { "code": "eof-in-cdata", "line": 1, "col": 6 }
            ]
        }

    ]
}