Il WPT vero non è agganciabile: i suoi test di parsing sono pagine che girano in testharness.js e vogliono DOMParser, createHTMLDocument e un event loop asincrono — cose che il motore non ha. Il corpus `html5lib-tests/tokenizer` è invece la sorgente da cui WPT genera quei test, e misurarlo dà un numero confrontabile invece di un'affermazione. - engine/src/bin/wpt.rs: legge i .test, esegue i casi, confronta i token, stampa percentuali per file e totale; `--min N` fa fallire la CI sotto soglia (93%) - engine/scripts/scarica-corpus.sh: rigenera il corpus (1,7 MB, nel repository perché la CI non deve dipendere dalla rete) Il corpus ha trovato subito due difetti: 1. **Il tokenizer si BLOCCAVA** su `<h/a='b'>`, `<a/\0>` e `<z/0 <>`: nel ciclo degli attributi, una `/` non seguita da `>` produceva un nome vuoto e `j` non avanzava mai. Ora il carattere si scarta e si prosegue (e `<h/a='b'>` vale `<h a='b'>`, come dice la specifica). Un blocco, non un token sbagliato. 2. **Ogni `<!…>` diventava un doctype**, anche `<!>`, `<!ciao>`, `<! `, `<?…>`: doveva essere un **commento spurio**. Era il grosso dei fallimenti in test3. Più: entità HTML nominate complete (2231 voci generate da entities.json del WHATWG, forme legacy e multi-carattere comprese) e DOCTYPE con nome, PUBLIC/SYSTEM e segnalazione degli errori. Numeri: 48,42% al primo giro, 82,09% con le entità, 93,88% con commento spurio e doctype (6247 casi su 6654 eseguibili, 166 saltati). Restano fuori gli stati iniziali diversi da quello dei dati (RCDATA, CDATA, script, PLAINTEXT), lastStartTag e la serializzazione: dichiarati, non nascosti. Effetti collaterali utili: le entità complete migliorano ogni pagina reale con simboli tipografici; il commento spurio rende il parsing di `<![CDATA[` e delle dichiarazioni PHP-like meno sbagliato di prima.
354 lines
9.8 KiB
Plaintext
354 lines
9.8 KiB
Plaintext
{"tests": [
|
|
|
|
{"description":"Correct Doctype lowercase",
|
|
"input":"<!DOCTYPE html>",
|
|
"output":[["DOCTYPE", "html", null, null, true]]},
|
|
|
|
|
|
{"description":"Correct Doctype uppercase",
|
|
"input":"<!DOCTYPE HTML>",
|
|
"output":[["DOCTYPE", "html", null, null, true]]},
|
|
|
|
{"description":"Correct Doctype mixed case",
|
|
"input":"<!DOCTYPE HtMl>",
|
|
"output":[["DOCTYPE", "html", null, null, true]]},
|
|
|
|
{"description":"Correct Doctype case with EOF",
|
|
"input":"<!DOCTYPE HtMl",
|
|
"output":[["DOCTYPE", "html", null, null, false]],
|
|
"errors":[
|
|
{ "code": "eof-in-doctype", "line": 1, "col": 15 }
|
|
]},
|
|
|
|
{"description":"Truncated doctype start",
|
|
"input":"<!DOC>",
|
|
"output":[["Comment", "DOC"]],
|
|
"errors":[
|
|
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 }
|
|
]},
|
|
|
|
{"description":"Doctype in error",
|
|
"input":"<!DOCTYPE foo>",
|
|
"output":[["DOCTYPE", "foo", null, null, true]]},
|
|
|
|
{"description":"Single Start Tag",
|
|
"input":"<h>",
|
|
"output":[["StartTag", "h", {}]]},
|
|
|
|
{"description":"Empty end tag",
|
|
"input":"</>",
|
|
"output":[],
|
|
"errors":[
|
|
{ "code": "missing-end-tag-name", "line": 1, "col": 3 }
|
|
]},
|
|
|
|
{"description":"Empty start tag",
|
|
"input":"<>",
|
|
"output":[["Character", "<>"]],
|
|
"errors":[
|
|
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 2 }
|
|
]},
|
|
|
|
{"description":"Start Tag w/attribute",
|
|
"input":"<h a='b'>",
|
|
"output":[["StartTag", "h", {"a":"b"}]]},
|
|
|
|
{"description":"Start Tag w/attribute no quotes",
|
|
"input":"<h a=b>",
|
|
"output":[["StartTag", "h", {"a":"b"}]]},
|
|
|
|
{"description":"Start/End Tag",
|
|
"input":"<h></h>",
|
|
"output":[["StartTag", "h", {}], ["EndTag", "h"]]},
|
|
|
|
{"description":"Two unclosed start tags",
|
|
"input":"<p>One<p>Two",
|
|
"output":[["StartTag", "p", {}], ["Character", "One"], ["StartTag", "p", {}], ["Character", "Two"]]},
|
|
|
|
{"description":"End Tag w/attribute",
|
|
"input":"<h></h a='b'>",
|
|
"output":[["StartTag", "h", {}], ["EndTag", "h"]],
|
|
"errors":[
|
|
{ "code": "end-tag-with-attributes", "line": 1, "col": 13 }
|
|
]},
|
|
|
|
{"description":"Multiple atts",
|
|
"input":"<h a='b' c='d'>",
|
|
"output":[["StartTag", "h", {"a":"b", "c":"d"}]]},
|
|
|
|
{"description":"Multiple atts no space",
|
|
"input":"<h a='b'c='d'>",
|
|
"output":[["StartTag", "h", {"a":"b", "c":"d"}]],
|
|
"errors":[
|
|
{ "code": "missing-whitespace-between-attributes", "line": 1, "col": 9 }
|
|
]},
|
|
|
|
{"description":"Repeated attr",
|
|
"input":"<h a='b' a='d'>",
|
|
"output":[["StartTag", "h", {"a":"b"}]],
|
|
"errors":[
|
|
{ "code": "duplicate-attribute", "line": 1, "col": 11 }
|
|
]},
|
|
|
|
{"description":"Simple comment",
|
|
"input":"<!--comment-->",
|
|
"output":[["Comment", "comment"]]},
|
|
|
|
{"description":"Comment, Central dash no space",
|
|
"input":"<!----->",
|
|
"output":[["Comment", "-"]]},
|
|
|
|
{"description":"Comment, two central dashes",
|
|
"input":"<!-- --comment -->",
|
|
"output":[["Comment", " --comment "]]},
|
|
|
|
{"description":"Comment, central less-than bang",
|
|
"input":"<!--<!-->",
|
|
"output":[["Comment", "<!"]]},
|
|
|
|
{"description":"Unfinished comment",
|
|
"input":"<!--comment",
|
|
"output":[["Comment", "comment"]],
|
|
"errors":[
|
|
{ "code": "eof-in-comment", "line": 1, "col": 12 }
|
|
]},
|
|
|
|
{"description":"Unfinished comment after start of nested comment",
|
|
"input":"<!-- <!--",
|
|
"output":[["Comment", " <!"]],
|
|
"errors":[
|
|
{ "code": "eof-in-comment", "line": 1, "col": 10 }
|
|
]},
|
|
|
|
{"description":"Start of a comment",
|
|
"input":"<!-",
|
|
"output":[["Comment", "-"]],
|
|
"errors":[
|
|
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 }
|
|
]},
|
|
|
|
{"description":"Short comment",
|
|
"input":"<!-->",
|
|
"output":[["Comment", ""]],
|
|
"errors":[
|
|
{ "code": "abrupt-closing-of-empty-comment", "line": 1, "col": 5 }
|
|
]},
|
|
|
|
{"description":"Short comment two",
|
|
"input":"<!--->",
|
|
"output":[["Comment", ""]],
|
|
"errors":[
|
|
{ "code": "abrupt-closing-of-empty-comment", "line": 1, "col": 6 }
|
|
]},
|
|
|
|
{"description":"Short comment three",
|
|
"input":"<!---->",
|
|
"output":[["Comment", ""]]},
|
|
|
|
{"description":"< in comment",
|
|
"input":"<!-- <test-->",
|
|
"output":[["Comment", " <test"]]},
|
|
|
|
{"description":"<< in comment",
|
|
"input":"<!--<<-->",
|
|
"output":[["Comment", "<<"]]},
|
|
|
|
{"description":"<! in comment",
|
|
"input":"<!-- <!test-->",
|
|
"output":[["Comment", " <!test"]]},
|
|
|
|
{"description":"<!- in comment",
|
|
"input":"<!-- <!-test-->",
|
|
"output":[["Comment", " <!-test"]]},
|
|
|
|
{"description":"Nested comment",
|
|
"input":"<!-- <!--test-->",
|
|
"output":[["Comment", " <!--test"]],
|
|
"errors":[
|
|
{ "code": "nested-comment", "line": 1, "col": 10 }
|
|
]},
|
|
|
|
{"description":"Nested comment with extra <",
|
|
"input":"<!-- <<!--test-->",
|
|
"output":[["Comment", " <<!--test"]],
|
|
"errors":[
|
|
{ "code": "nested-comment", "line": 1, "col": 11 }
|
|
]},
|
|
|
|
{"description":"< in script data",
|
|
"initialStates":["Script data state"],
|
|
"input":"<test-->",
|
|
"output":[["Character", "<test-->"]]},
|
|
|
|
{"description":"<! in script data",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!test-->",
|
|
"output":[["Character", "<!test-->"]]},
|
|
|
|
{"description":"<!- in script data",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!-test-->",
|
|
"output":[["Character", "<!-test-->"]]},
|
|
|
|
{"description":"Escaped script data",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!--test-->",
|
|
"output":[["Character", "<!--test-->"]]},
|
|
|
|
{"description":"< in script HTML comment",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!-- < test -->",
|
|
"output":[["Character", "<!-- < test -->"]]},
|
|
|
|
{"description":"</ in script HTML comment",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!-- </ test -->",
|
|
"output":[["Character", "<!-- </ test -->"]]},
|
|
|
|
{"description":"Start tag in script HTML comment",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!-- <test> -->",
|
|
"output":[["Character", "<!-- <test> -->"]]},
|
|
|
|
{"description":"End tag in script HTML comment",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!-- </test> -->",
|
|
"output":[["Character", "<!-- </test> -->"]]},
|
|
|
|
{"description":"- in script HTML comment double escaped",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!--<script>-</script>-->",
|
|
"output":[["Character", "<!--<script>-</script>-->"]]},
|
|
|
|
{"description":"-- in script HTML comment double escaped",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!--<script>--</script>-->",
|
|
"output":[["Character", "<!--<script>--</script>-->"]]},
|
|
|
|
{"description":"--- in script HTML comment double escaped",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!--<script>---</script>-->",
|
|
"output":[["Character", "<!--<script>---</script>-->"]]},
|
|
|
|
{"description":"- spaced in script HTML comment double escaped",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!--<script> - </script>-->",
|
|
"output":[["Character", "<!--<script> - </script>-->"]]},
|
|
|
|
{"description":"-- spaced in script HTML comment double escaped",
|
|
"initialStates":["Script data state"],
|
|
"input":"<!--<script> -- </script>-->",
|
|
"output":[["Character", "<!--<script> -- </script>-->"]]},
|
|
|
|
{"description":"Ampersand EOF",
|
|
"input":"&",
|
|
"output":[["Character", "&"]]},
|
|
|
|
{"description":"Ampersand ampersand EOF",
|
|
"input":"&&",
|
|
"output":[["Character", "&&"]]},
|
|
|
|
{"description":"Ampersand space EOF",
|
|
"input":"& ",
|
|
"output":[["Character", "& "]]},
|
|
|
|
{"description":"Unfinished entity",
|
|
"input":"&f",
|
|
"output":[["Character", "&f"]]},
|
|
|
|
{"description":"Ampersand, number sign",
|
|
"input":"&#",
|
|
"output":[["Character", "&#"]],
|
|
"errors":[
|
|
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 3 }
|
|
]},
|
|
|
|
{"description":"Unfinished numeric entity",
|
|
"input":"&#x",
|
|
"output":[["Character", "&#x"]],
|
|
"errors":[
|
|
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 4 }
|
|
]},
|
|
|
|
{"description":"Entity with trailing semicolon (1)",
|
|
"input":"I'm ¬it",
|
|
"output":[["Character","I'm \u00ACit"]]},
|
|
|
|
{"description":"Entity with trailing semicolon (2)",
|
|
"input":"I'm ∉",
|
|
"output":[["Character","I'm \u2209"]]},
|
|
|
|
{"description":"Entity without trailing semicolon (1)",
|
|
"input":"I'm ¬it",
|
|
"output":[["Character","I'm \u00ACit"]],
|
|
"errors": [
|
|
{"code" : "missing-semicolon-after-character-reference", "line": 1, "col": 9 }
|
|
]},
|
|
|
|
{"description":"Entity without trailing semicolon (2)",
|
|
"input":"I'm ¬in",
|
|
"output":[["Character","I'm \u00ACin"]],
|
|
"errors": [
|
|
{"code" : "missing-semicolon-after-character-reference", "line": 1, "col": 9 }
|
|
]},
|
|
|
|
{"description":"Partial entity match at end of file",
|
|
"input":"I'm &no",
|
|
"output":[["Character","I'm &no"]]},
|
|
|
|
{"description":"Non-ASCII character reference name",
|
|
"input":"&\u00AC;",
|
|
"output":[["Character", "&\u00AC;"]]},
|
|
|
|
{"description":"ASCII decimal entity",
|
|
"input":"$",
|
|
"output":[["Character","$"]]},
|
|
|
|
{"description":"ASCII hexadecimal entity",
|
|
"input":"?",
|
|
"output":[["Character","?"]]},
|
|
|
|
{"description":"Hexadecimal entity in attribute",
|
|
"input":"<h a='?'></h>",
|
|
"output":[["StartTag", "h", {"a":"?"}], ["EndTag", "h"]]},
|
|
|
|
{"description":"Entity in attribute without semicolon ending in x",
|
|
"input":"<h a='¬x'>",
|
|
"output":[["StartTag", "h", {"a":"¬x"}]]},
|
|
|
|
{"description":"Entity in attribute without semicolon ending in 1",
|
|
"input":"<h a='¬1'>",
|
|
"output":[["StartTag", "h", {"a":"¬1"}]]},
|
|
|
|
{"description":"Entity in attribute without semicolon ending in i",
|
|
"input":"<h a='¬i'>",
|
|
"output":[["StartTag", "h", {"a":"¬i"}]]},
|
|
|
|
{"description":"Entity in attribute without semicolon",
|
|
"input":"<h a='©'>",
|
|
"output":[["StartTag", "h", {"a":"\u00A9"}]],
|
|
"errors": [
|
|
{"code" : "missing-semicolon-after-character-reference", "line": 1, "col": 12 }
|
|
]},
|
|
|
|
{"description":"Unquoted attribute ending in ampersand",
|
|
"input":"<s o=& t>",
|
|
"output":[["StartTag","s",{"o":"&","t":""}]]},
|
|
|
|
{"description":"Unquoted attribute at end of tag with final character of &, with tag followed by characters",
|
|
"input":"<a a=a&>foo",
|
|
"output":[["StartTag", "a", {"a":"a&"}], ["Character", "foo"]]},
|
|
|
|
{"description":"plaintext element",
|
|
"input":"<plaintext>foobar",
|
|
"output":[["StartTag","plaintext",{}], ["Character","foobar"]]},
|
|
|
|
{"description":"Open angled bracket in unquoted attribute value state",
|
|
"input":"<a a=f<>",
|
|
"output":[["StartTag", "a", {"a":"f<"}]],
|
|
"errors":[
|
|
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 7 }
|
|
]}
|
|
|
|
]}
|