Skip to content

Commit

Permalink
html: port html5lib tests from html5lib/html5lib-tests
Browse files Browse the repository at this point in the history
To reproduce this, execute following steps in order:

1. git clone git@github.com: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 <namusyaka@gmail.com>
Trust: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Kunpei Sakai <namusyaka@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
  • Loading branch information
namusyaka authored and nigeltao committed Oct 29, 2020
1 parent 942e2f4 commit 28c70e6
Show file tree
Hide file tree
Showing 32 changed files with 1,111 additions and 14 deletions.
13 changes: 13 additions & 0 deletions html/parse_test.go
Expand Up @@ -66,6 +66,19 @@ func readParseTest(r *bufio.Reader) (*testAttrs, error) {
}
}

// Skip the new-errors list.
if string(line) == "#new-errors\n" {
for {
line, err = r.ReadSlice('\n')
if err != nil {
return nil, err
}
if line[0] == '#' {
break
}
}
}

if ls := string(line); strings.HasPrefix(ls, "#script-") {
switch {
case strings.HasSuffix(ls, "-on\n"):
Expand Down
17 changes: 17 additions & 0 deletions html/testdata/webkit/adoption01.dat
Expand Up @@ -335,3 +335,20 @@
| <b>
| <b>
| "x"

#data
<b><em><foo><foob><fooc><aside></b></em>
#errors
(1,35): adoption-agency-1.3
(1,40): adoption-agency-1.3
(1,40): expected-closing-tag-but-got-eof
#document-fragment
div
#document
| <b>
| <em>
| <foo>
| <foob>
| <fooc>
| <aside>
| <b>
46 changes: 46 additions & 0 deletions html/testdata/webkit/comments01.dat
Expand Up @@ -15,6 +15,8 @@ FOO<!-- BAR --!>BAZ
#errors
(1,3): expected-doctype-but-got-chars
(1,15): unexpected-bang-after-double-dash-in-comment
#new-errors
(1:16) incorrectly-closed-comment
#document
| <html>
| <head>
Expand All @@ -23,12 +25,42 @@ FOO<!-- BAR --!>BAZ
| <!-- BAR -->
| "BAZ"

#data
FOO<!-- BAR --! >BAZ
#errors
(1,3): expected-doctype-but-got-chars
#new-errors
(1:20) eof-in-comment
#document
| <html>
| <head>
| <body>
| "FOO"
| <!-- BAR --! >BAZ -->

#data
FOO<!-- BAR --!
>BAZ
#errors
(1,3): expected-doctype-but-got-chars
#new-errors
(1:20) eof-in-comment
#document
| <html>
| <head>
| <body>
| "FOO"
| <!-- BAR --!
>BAZ -->

#data
FOO<!-- BAR -- >BAZ
#errors
(1,3): expected-doctype-but-got-chars
(1,15): unexpected-char-in-comment
(1,21): eof-in-comment
#new-errors
(1:22) eof-in-comment
#document
| <html>
| <head>
Expand Down Expand Up @@ -57,6 +89,8 @@ FOO<!-- BAR -- <QUX> -- MUX --!>BAZ
(1,15): unexpected-char-in-comment
(1,24): unexpected-char-in-comment
(1,31): unexpected-bang-after-double-dash-in-comment
#new-errors
(1:32) incorrectly-closed-comment
#document
| <html>
| <head>
Expand All @@ -73,6 +107,8 @@ FOO<!-- BAR -- <QUX> -- MUX -- >BAZ
(1,24): unexpected-char-in-comment
(1,31): unexpected-char-in-comment
(1,35): eof-in-comment
#new-errors
(1:36) eof-in-comment
#document
| <html>
| <head>
Expand All @@ -97,6 +133,8 @@ FOO<!--->BAZ
#errors
(1,3): expected-doctype-but-got-chars
(1,9): incorrect-comment
#new-errors
(1:9) abrupt-closing-of-empty-comment
#document
| <html>
| <head>
Expand All @@ -110,6 +148,8 @@ FOO<!-->BAZ
#errors
(1,3): expected-doctype-but-got-chars
(1,8): incorrect-comment
#new-errors
(1:8) abrupt-closing-of-empty-comment
#document
| <html>
| <head>
Expand All @@ -123,6 +163,8 @@ FOO<!-->BAZ
#errors
(1,1): expected-tag-name-but-got-question-mark
(1,22): expected-doctype-but-got-chars
#new-errors
(1:2) unexpected-question-mark-instead-of-tag-name
#document
| <!-- ?xml version="1.0" -->
| <html>
Expand All @@ -135,6 +177,8 @@ FOO<!-->BAZ
#errors
(1,1): expected-tag-name-but-got-question-mark
(1,20): expected-doctype-but-got-eof
#new-errors
(1:2) unexpected-question-mark-instead-of-tag-name
#document
| <!-- ?xml version="1.0" -->
| <html>
Expand All @@ -146,6 +190,8 @@ FOO<!-->BAZ
#errors
(1,1): expected-tag-name-but-got-question-mark
(1,13): expected-doctype-but-got-eof
#new-errors
(1:2) unexpected-question-mark-instead-of-tag-name
#document
| <!-- ?xml version -->
| <html>
Expand Down
46 changes: 46 additions & 0 deletions html/testdata/webkit/doctype01.dat
Expand Up @@ -22,6 +22,8 @@
<!DOCTYPEhtml>Hello
#errors
(1,9): need-space-after-doctype
#new-errors
(1:10) missing-whitespace-before-doctype-name
#document
| <!DOCTYPE html>
| <html>
Expand All @@ -35,6 +37,8 @@
(1,9): need-space-after-doctype
(1,10): expected-doctype-name-but-got-right-bracket
(1,10): unknown-doctype
#new-errors
(1:10) missing-doctype-name
#document
| <!DOCTYPE >
| <html>
Expand All @@ -47,6 +51,8 @@
#errors
(1,11): expected-doctype-name-but-got-right-bracket
(1,11): unknown-doctype
#new-errors
(1:11) missing-doctype-name
#document
| <!DOCTYPE >
| <html>
Expand Down Expand Up @@ -81,6 +87,8 @@
#errors
(1,17): expected-space-or-right-bracket-in-doctype
(1,22): unknown-doctype
#new-errors
(1:18) invalid-character-sequence-after-doctype-name
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -93,6 +101,8 @@
#errors
(1,17): expected-space-or-right-bracket-in-doctype
(1,27): unknown-doctype
#new-errors
(1:18) invalid-character-sequence-after-doctype-name
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -105,6 +115,8 @@
#errors
(1,24): unexpected-char-in-doctype
(1,24): unknown-doctype
#new-errors
(1:24) missing-doctype-system-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -117,6 +129,8 @@
#errors
(1,28): unexpected-char-in-doctype
(1,28): unknown-doctype
#new-errors
(1:28) missing-doctype-system-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -129,6 +143,8 @@
#errors
(1,34): unexpected-char-in-doctype
(1,37): unknown-doctype
#new-errors
(1:34) missing-quote-before-doctype-system-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -141,6 +157,8 @@
#errors
(1,25): unexpected-char-in-doctype
(1,31): unknown-doctype
#new-errors
(1:25) missing-quote-before-doctype-system-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand Down Expand Up @@ -186,6 +204,8 @@
#errors
(1,24): unexpected-char-in-doctype
(1,34): unknown-doctype
#new-errors
(1:24) missing-quote-before-doctype-system-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -198,6 +218,8 @@
#errors
(1,17): expected-space-or-right-bracket-in-doctype
(1,35): unknown-doctype
#new-errors
(1:18) invalid-character-sequence-after-doctype-name
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -210,6 +232,8 @@
#errors
(1,24): unexpected-end-of-doctype
(1,24): unknown-doctype
#new-errors
(1:24) missing-doctype-public-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -222,6 +246,8 @@
#errors
(1,25): unexpected-end-of-doctype
(1,25): unknown-doctype
#new-errors
(1:25) missing-doctype-public-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -234,6 +260,8 @@
#errors
(1,24): unexpected-char-in-doctype
(1,28): unknown-doctype
#new-errors
(1:24) missing-quote-before-doctype-public-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -246,6 +274,8 @@
#errors
(1,25): unexpected-char-in-doctype
(1,29): unknown-doctype
#new-errors
(1:25) missing-quote-before-doctype-public-identifier
#document
| <!DOCTYPE potato>
| <html>
Expand All @@ -269,6 +299,8 @@
#errors
(1,29): unexpected-char-in-doctype
(1,32): unknown-doctype
#new-errors
(1:29) missing-quote-before-doctype-system-identifier
#document
| <!DOCTYPE potato "go" "">
| <html>
Expand All @@ -292,6 +324,8 @@
#errors
(1,38): unexpected-char-in-doctype
(1,48): unknown-doctype
#new-errors
(1:38) missing-quote-before-doctype-system-identifier
#document
| <!DOCTYPE potato "W3C-//dfdf" "">
| <html>
Expand Down Expand Up @@ -350,6 +384,8 @@
#errors
(1,23): expected-space-or-right-bracket-in-doctype
(2,30): unknown-doctype
#new-errors
(1:24) invalid-character-sequence-after-doctype-name
#document
| <!DOCTYPE root-element>
| <html>
Expand Down Expand Up @@ -385,6 +421,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
#errors
(1,50): unexpected-char-in-doctype
#new-errors
(1:50) missing-whitespace-between-doctype-public-and-system-identifiers
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
Expand All @@ -395,6 +433,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'http://www.w3.org/TR/html4/strict.dtd'>
#errors
(1,50): unexpected-char-in-doctype
#new-errors
(1:50) missing-whitespace-between-doctype-public-and-system-identifiers
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
Expand All @@ -406,6 +446,9 @@
#errors
(1,21): unexpected-char-in-doctype
(1,49): unexpected-char-in-doctype
#new-errors
(1:22) missing-whitespace-after-doctype-public-keyword
(1:49) missing-whitespace-between-doctype-public-and-system-identifiers
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
Expand All @@ -417,6 +460,9 @@
#errors
(1,21): unexpected-char-in-doctype
(1,49): unexpected-char-in-doctype
#new-errors
(1:22) missing-whitespace-after-doctype-public-keyword
(1:49) missing-whitespace-between-doctype-public-and-system-identifiers
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
Expand Down
Binary file modified html/testdata/webkit/domjs-unsafe.dat
Binary file not shown.

0 comments on commit 28c70e6

Please sign in to comment.