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.
312 lines
12 KiB
Plaintext
312 lines
12 KiB
Plaintext
{
|
|
"tests": [
|
|
{
|
|
"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":"≂̸",
|
|
"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=\"≂̸\">",
|
|
"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 ]]>",
|
|
"initialStates":["CDATA section state"],
|
|
"output":[["Character", "foo "]]
|
|
},
|
|
{
|
|
"description":"CDATA followed by HTML content",
|
|
"input":"foo ]]> ",
|
|
"initialStates":["CDATA section state"],
|
|
"output":[["Character", "foo  "]]
|
|
},
|
|
{
|
|
"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 }
|
|
]
|
|
},
|
|
{
|
|
"description": "HTML tag in script data",
|
|
"input": "<b>hello world</b>",
|
|
"initialStates": ["Script data state"],
|
|
"output": [["Character", "<b>hello world</b>"]]
|
|
}
|
|
]
|
|
}
|