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.
94 lines
3.0 KiB
Plaintext
94 lines
3.0 KiB
Plaintext
{"tests": [
|
|
|
|
{"description":"PLAINTEXT content model flag",
|
|
"initialStates":["PLAINTEXT state"],
|
|
"lastStartTag":"plaintext",
|
|
"input":"<head>&body;",
|
|
"output":[["Character", "<head>&body;"]]},
|
|
|
|
{"description":"PLAINTEXT with seeming close tag",
|
|
"initialStates":["PLAINTEXT state"],
|
|
"lastStartTag":"plaintext",
|
|
"input":"</plaintext>&body;",
|
|
"output":[["Character", "</plaintext>&body;"]]},
|
|
|
|
{"description":"End tag closing RCDATA or RAWTEXT",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"foo</xmp>",
|
|
"output":[["Character", "foo"], ["EndTag", "xmp"]]},
|
|
|
|
{"description":"End tag closing RCDATA or RAWTEXT (case-insensitivity)",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"foo</xMp>",
|
|
"output":[["Character", "foo"], ["EndTag", "xmp"]]},
|
|
|
|
{"description":"End tag closing RCDATA or RAWTEXT (ending with space)",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"foo</xmp ",
|
|
"output":[["Character", "foo"]],
|
|
"errors":[
|
|
{ "code": "eof-in-tag", "line": 1, "col": 10 }
|
|
]},
|
|
|
|
{"description":"End tag closing RCDATA or RAWTEXT (ending with EOF)",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"foo</xmp",
|
|
"output":[["Character", "foo</xmp"]]},
|
|
|
|
{"description":"End tag closing RCDATA or RAWTEXT (ending with slash)",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"foo</xmp/",
|
|
"output":[["Character", "foo"]],
|
|
"errors":[
|
|
{ "code": "eof-in-tag", "line": 1, "col": 10 }
|
|
]},
|
|
|
|
{"description":"End tag not closing RCDATA or RAWTEXT (ending with left-angle-bracket)",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"foo</xmp<",
|
|
"output":[["Character", "foo</xmp<"]]},
|
|
|
|
{"description":"End tag with incorrect name in RCDATA or RAWTEXT",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"</foo>bar</xmp>",
|
|
"output":[["Character", "</foo>bar"], ["EndTag", "xmp"]]},
|
|
|
|
{"description":"Partial end tags leading straight into partial end tags",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"</xmp</xmp</xmp>",
|
|
"output":[["Character", "</xmp</xmp"], ["EndTag", "xmp"]]},
|
|
|
|
{"description":"End tag with incorrect name in RCDATA or RAWTEXT (starting like correct name)",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"</foo>bar</xmpaar>",
|
|
"output":[["Character", "</foo>bar</xmpaar>"]]},
|
|
|
|
{"description":"End tag closing RCDATA or RAWTEXT, switching back to PCDATA",
|
|
"initialStates":["RCDATA state", "RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"foo</xmp></baz>",
|
|
"output":[["Character", "foo"], ["EndTag", "xmp"], ["EndTag", "baz"]]},
|
|
|
|
{"description":"RAWTEXT w/ something looking like an entity",
|
|
"initialStates":["RAWTEXT state"],
|
|
"lastStartTag":"xmp",
|
|
"input":"&foo;",
|
|
"output":[["Character", "&foo;"]]},
|
|
|
|
{"description":"RCDATA w/ an entity",
|
|
"initialStates":["RCDATA state"],
|
|
"lastStartTag":"textarea",
|
|
"input":"<",
|
|
"output":[["Character", "<"]]}
|
|
|
|
]}
|