WPT: 93,88% del corpus del tokenizer, e due difetti veri trovati subito
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.
This commit is contained in:
1 parent
36dbc691d9
commit
e2b238d424
28 files changed
+62302
-44
No files matched your search
@@ -0,0 +1,36 @@
|
||||
{"tests": [
|
||||
|
||||
{"description":"Commented close tag in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!--</xmp>--></xmp>",
|
||||
"output":[["Character", "foo<!--"], ["EndTag", "xmp"], ["Character", "-->"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"Bogus comment in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!-->baz</xmp>",
|
||||
"output":[["Character", "foo<!-->baz"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"End tag surrounded by bogus comment in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!--></xmp><!-->baz</xmp>",
|
||||
"output":[["Character", "foo<!-->"], ["EndTag", "xmp"], ["Comment", ""], ["Character", "baz"], ["EndTag", "xmp"]],
|
||||
"errors":[
|
||||
{ "code": "abrupt-closing-of-empty-comment", "line": 1, "col": 19 }
|
||||
]},
|
||||
|
||||
{"description":"Commented entities in RCDATA",
|
||||
"initialStates":["RCDATA state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":" & <!-- & --> & </xmp>",
|
||||
"output":[["Character", " & <!-- & --> & "], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"Incorrect comment ending sequences in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!-- x --x>x-- >x--!>x--<></xmp>",
|
||||
"output":[["Character", "foo<!-- x --x>x-- >x--!>x--<>"], ["EndTag", "xmp"]]}
|
||||
|
||||
]}
|
||||
Reference in new issue
Block a user