Skip to content

Commit 28c70e6

Browse files
namusyakanigeltao
authored andcommitted
html: port html5lib tests from html5lib/html5lib-tests
To reproduce this, execute following steps in order: 1. git clone [email protected]:html5lib/html5lib-tests.git && git checkout 6ddcf58bea5a01e616911050c173622f84297211 2. cp -Rv html5lib-tests/tree-construction/ testdata/webkit Change-Id: Id32798b1ff881afad82d87c2fef0841e5223c7e6 Reviewed-on: https://go-review.googlesource.com/c/net/+/263397 Trust: Kunpei Sakai <[email protected]> Trust: Nigel Tao <[email protected]> Run-TryBot: Kunpei Sakai <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Nigel Tao <[email protected]>
1 parent 942e2f4 commit 28c70e6

32 files changed

+1111
-14
lines changed

html/parse_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ func readParseTest(r *bufio.Reader) (*testAttrs, error) {
6666
}
6767
}
6868

69+
// Skip the new-errors list.
70+
if string(line) == "#new-errors\n" {
71+
for {
72+
line, err = r.ReadSlice('\n')
73+
if err != nil {
74+
return nil, err
75+
}
76+
if line[0] == '#' {
77+
break
78+
}
79+
}
80+
}
81+
6982
if ls := string(line); strings.HasPrefix(ls, "#script-") {
7083
switch {
7184
case strings.HasSuffix(ls, "-on\n"):

html/testdata/webkit/adoption01.dat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,20 @@
335335
| <b>
336336
| <b>
337337
| "x"
338+
339+
#data
340+
<b><em><foo><foob><fooc><aside></b></em>
341+
#errors
342+
(1,35): adoption-agency-1.3
343+
(1,40): adoption-agency-1.3
344+
(1,40): expected-closing-tag-but-got-eof
345+
#document-fragment
346+
div
347+
#document
348+
| <b>
349+
| <em>
350+
| <foo>
351+
| <foob>
352+
| <fooc>
353+
| <aside>
354+
| <b>

html/testdata/webkit/comments01.dat

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ FOO<!-- BAR --!>BAZ
1515
#errors
1616
(1,3): expected-doctype-but-got-chars
1717
(1,15): unexpected-bang-after-double-dash-in-comment
18+
#new-errors
19+
(1:16) incorrectly-closed-comment
1820
#document
1921
| <html>
2022
| <head>
@@ -23,12 +25,42 @@ FOO<!-- BAR --!>BAZ
2325
| <!-- BAR -->
2426
| "BAZ"
2527

28+
#data
29+
FOO<!-- BAR --! >BAZ
30+
#errors
31+
(1,3): expected-doctype-but-got-chars
32+
#new-errors
33+
(1:20) eof-in-comment
34+
#document
35+
| <html>
36+
| <head>
37+
| <body>
38+
| "FOO"
39+
| <!-- BAR --! >BAZ -->
40+
41+
#data
42+
FOO<!-- BAR --!
43+
>BAZ
44+
#errors
45+
(1,3): expected-doctype-but-got-chars
46+
#new-errors
47+
(1:20) eof-in-comment
48+
#document
49+
| <html>
50+
| <head>
51+
| <body>
52+
| "FOO"
53+
| <!-- BAR --!
54+
>BAZ -->
55+
2656
#data
2757
FOO<!-- BAR -- >BAZ
2858
#errors
2959
(1,3): expected-doctype-but-got-chars
3060
(1,15): unexpected-char-in-comment
3161
(1,21): eof-in-comment
62+
#new-errors
63+
(1:22) eof-in-comment
3264
#document
3365
| <html>
3466
| <head>
@@ -57,6 +89,8 @@ FOO<!-- BAR -- <QUX> -- MUX --!>BAZ
5789
(1,15): unexpected-char-in-comment
5890
(1,24): unexpected-char-in-comment
5991
(1,31): unexpected-bang-after-double-dash-in-comment
92+
#new-errors
93+
(1:32) incorrectly-closed-comment
6094
#document
6195
| <html>
6296
| <head>
@@ -73,6 +107,8 @@ FOO<!-- BAR -- <QUX> -- MUX -- >BAZ
73107
(1,24): unexpected-char-in-comment
74108
(1,31): unexpected-char-in-comment
75109
(1,35): eof-in-comment
110+
#new-errors
111+
(1:36) eof-in-comment
76112
#document
77113
| <html>
78114
| <head>
@@ -97,6 +133,8 @@ FOO<!--->BAZ
97133
#errors
98134
(1,3): expected-doctype-but-got-chars
99135
(1,9): incorrect-comment
136+
#new-errors
137+
(1:9) abrupt-closing-of-empty-comment
100138
#document
101139
| <html>
102140
| <head>
@@ -110,6 +148,8 @@ FOO<!-->BAZ
110148
#errors
111149
(1,3): expected-doctype-but-got-chars
112150
(1,8): incorrect-comment
151+
#new-errors
152+
(1:8) abrupt-closing-of-empty-comment
113153
#document
114154
| <html>
115155
| <head>
@@ -123,6 +163,8 @@ FOO<!-->BAZ
123163
#errors
124164
(1,1): expected-tag-name-but-got-question-mark
125165
(1,22): expected-doctype-but-got-chars
166+
#new-errors
167+
(1:2) unexpected-question-mark-instead-of-tag-name
126168
#document
127169
| <!-- ?xml version="1.0" -->
128170
| <html>
@@ -135,6 +177,8 @@ FOO<!-->BAZ
135177
#errors
136178
(1,1): expected-tag-name-but-got-question-mark
137179
(1,20): expected-doctype-but-got-eof
180+
#new-errors
181+
(1:2) unexpected-question-mark-instead-of-tag-name
138182
#document
139183
| <!-- ?xml version="1.0" -->
140184
| <html>
@@ -146,6 +190,8 @@ FOO<!-->BAZ
146190
#errors
147191
(1,1): expected-tag-name-but-got-question-mark
148192
(1,13): expected-doctype-but-got-eof
193+
#new-errors
194+
(1:2) unexpected-question-mark-instead-of-tag-name
149195
#document
150196
| <!-- ?xml version -->
151197
| <html>

html/testdata/webkit/doctype01.dat

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<!DOCTYPEhtml>Hello
2323
#errors
2424
(1,9): need-space-after-doctype
25+
#new-errors
26+
(1:10) missing-whitespace-before-doctype-name
2527
#document
2628
| <!DOCTYPE html>
2729
| <html>
@@ -35,6 +37,8 @@
3537
(1,9): need-space-after-doctype
3638
(1,10): expected-doctype-name-but-got-right-bracket
3739
(1,10): unknown-doctype
40+
#new-errors
41+
(1:10) missing-doctype-name
3842
#document
3943
| <!DOCTYPE >
4044
| <html>
@@ -47,6 +51,8 @@
4751
#errors
4852
(1,11): expected-doctype-name-but-got-right-bracket
4953
(1,11): unknown-doctype
54+
#new-errors
55+
(1:11) missing-doctype-name
5056
#document
5157
| <!DOCTYPE >
5258
| <html>
@@ -81,6 +87,8 @@
8187
#errors
8288
(1,17): expected-space-or-right-bracket-in-doctype
8389
(1,22): unknown-doctype
90+
#new-errors
91+
(1:18) invalid-character-sequence-after-doctype-name
8492
#document
8593
| <!DOCTYPE potato>
8694
| <html>
@@ -93,6 +101,8 @@
93101
#errors
94102
(1,17): expected-space-or-right-bracket-in-doctype
95103
(1,27): unknown-doctype
104+
#new-errors
105+
(1:18) invalid-character-sequence-after-doctype-name
96106
#document
97107
| <!DOCTYPE potato>
98108
| <html>
@@ -105,6 +115,8 @@
105115
#errors
106116
(1,24): unexpected-char-in-doctype
107117
(1,24): unknown-doctype
118+
#new-errors
119+
(1:24) missing-doctype-system-identifier
108120
#document
109121
| <!DOCTYPE potato>
110122
| <html>
@@ -117,6 +129,8 @@
117129
#errors
118130
(1,28): unexpected-char-in-doctype
119131
(1,28): unknown-doctype
132+
#new-errors
133+
(1:28) missing-doctype-system-identifier
120134
#document
121135
| <!DOCTYPE potato>
122136
| <html>
@@ -129,6 +143,8 @@
129143
#errors
130144
(1,34): unexpected-char-in-doctype
131145
(1,37): unknown-doctype
146+
#new-errors
147+
(1:34) missing-quote-before-doctype-system-identifier
132148
#document
133149
| <!DOCTYPE potato>
134150
| <html>
@@ -141,6 +157,8 @@
141157
#errors
142158
(1,25): unexpected-char-in-doctype
143159
(1,31): unknown-doctype
160+
#new-errors
161+
(1:25) missing-quote-before-doctype-system-identifier
144162
#document
145163
| <!DOCTYPE potato>
146164
| <html>
@@ -186,6 +204,8 @@
186204
#errors
187205
(1,24): unexpected-char-in-doctype
188206
(1,34): unknown-doctype
207+
#new-errors
208+
(1:24) missing-quote-before-doctype-system-identifier
189209
#document
190210
| <!DOCTYPE potato>
191211
| <html>
@@ -198,6 +218,8 @@
198218
#errors
199219
(1,17): expected-space-or-right-bracket-in-doctype
200220
(1,35): unknown-doctype
221+
#new-errors
222+
(1:18) invalid-character-sequence-after-doctype-name
201223
#document
202224
| <!DOCTYPE potato>
203225
| <html>
@@ -210,6 +232,8 @@
210232
#errors
211233
(1,24): unexpected-end-of-doctype
212234
(1,24): unknown-doctype
235+
#new-errors
236+
(1:24) missing-doctype-public-identifier
213237
#document
214238
| <!DOCTYPE potato>
215239
| <html>
@@ -222,6 +246,8 @@
222246
#errors
223247
(1,25): unexpected-end-of-doctype
224248
(1,25): unknown-doctype
249+
#new-errors
250+
(1:25) missing-doctype-public-identifier
225251
#document
226252
| <!DOCTYPE potato>
227253
| <html>
@@ -234,6 +260,8 @@
234260
#errors
235261
(1,24): unexpected-char-in-doctype
236262
(1,28): unknown-doctype
263+
#new-errors
264+
(1:24) missing-quote-before-doctype-public-identifier
237265
#document
238266
| <!DOCTYPE potato>
239267
| <html>
@@ -246,6 +274,8 @@
246274
#errors
247275
(1,25): unexpected-char-in-doctype
248276
(1,29): unknown-doctype
277+
#new-errors
278+
(1:25) missing-quote-before-doctype-public-identifier
249279
#document
250280
| <!DOCTYPE potato>
251281
| <html>
@@ -269,6 +299,8 @@
269299
#errors
270300
(1,29): unexpected-char-in-doctype
271301
(1,32): unknown-doctype
302+
#new-errors
303+
(1:29) missing-quote-before-doctype-system-identifier
272304
#document
273305
| <!DOCTYPE potato "go" "">
274306
| <html>
@@ -292,6 +324,8 @@
292324
#errors
293325
(1,38): unexpected-char-in-doctype
294326
(1,48): unknown-doctype
327+
#new-errors
328+
(1:38) missing-quote-before-doctype-system-identifier
295329
#document
296330
| <!DOCTYPE potato "W3C-//dfdf" "">
297331
| <html>
@@ -350,6 +384,8 @@
350384
#errors
351385
(1,23): expected-space-or-right-bracket-in-doctype
352386
(2,30): unknown-doctype
387+
#new-errors
388+
(1:24) invalid-character-sequence-after-doctype-name
353389
#document
354390
| <!DOCTYPE root-element>
355391
| <html>
@@ -385,6 +421,8 @@
385421
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
386422
#errors
387423
(1,50): unexpected-char-in-doctype
424+
#new-errors
425+
(1:50) missing-whitespace-between-doctype-public-and-system-identifiers
388426
#document
389427
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
390428
| <html>
@@ -395,6 +433,8 @@
395433
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'http://www.w3.org/TR/html4/strict.dtd'>
396434
#errors
397435
(1,50): unexpected-char-in-doctype
436+
#new-errors
437+
(1:50) missing-whitespace-between-doctype-public-and-system-identifiers
398438
#document
399439
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
400440
| <html>
@@ -406,6 +446,9 @@
406446
#errors
407447
(1,21): unexpected-char-in-doctype
408448
(1,49): unexpected-char-in-doctype
449+
#new-errors
450+
(1:22) missing-whitespace-after-doctype-public-keyword
451+
(1:49) missing-whitespace-between-doctype-public-and-system-identifiers
409452
#document
410453
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
411454
| <html>
@@ -417,6 +460,9 @@
417460
#errors
418461
(1,21): unexpected-char-in-doctype
419462
(1,49): unexpected-char-in-doctype
463+
#new-errors
464+
(1:22) missing-whitespace-after-doctype-public-keyword
465+
(1:49) missing-whitespace-between-doctype-public-and-system-identifiers
420466
#document
421467
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
422468
| <html>

html/testdata/webkit/domjs-unsafe.dat

472 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)