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.
274 lines
8.5 KiB
Plaintext
274 lines
8.5 KiB
Plaintext
{"tests": [
|
|
|
|
{"description":"DOCTYPE without name",
|
|
"input":"<!DOCTYPE>",
|
|
"output":[["DOCTYPE", null, null, null, false]],
|
|
"errors":[
|
|
{ "code": "missing-doctype-name", "line": 1, "col": 10 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE without space before name",
|
|
"input":"<!DOCTYPEhtml>",
|
|
"output":[["DOCTYPE", "html", null, null, true]],
|
|
"errors":[
|
|
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 }
|
|
]},
|
|
|
|
{"description":"Incorrect DOCTYPE without a space before name",
|
|
"input":"<!DOCTYPEfoo>",
|
|
"output":[["DOCTYPE", "foo", null, null, true]],
|
|
"errors":[
|
|
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE with publicId",
|
|
"input":"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML Transitional 4.01//EN\">",
|
|
"output":[["DOCTYPE", "html", "-//W3C//DTD HTML Transitional 4.01//EN", null, true]]},
|
|
|
|
{"description":"DOCTYPE with EOF after PUBLIC",
|
|
"input":"<!DOCTYPE html PUBLIC",
|
|
"output":[["DOCTYPE", "html", null, null, false]],
|
|
"errors": [
|
|
{ "code": "eof-in-doctype", "col": 22, "line": 1 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE with EOF after PUBLIC '",
|
|
"input":"<!DOCTYPE html PUBLIC '",
|
|
"output":[["DOCTYPE", "html", "", null, false]],
|
|
"errors": [
|
|
{ "code": "eof-in-doctype", "col": 24, "line": 1 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE with EOF after PUBLIC 'x",
|
|
"input":"<!DOCTYPE html PUBLIC 'x",
|
|
"output":[["DOCTYPE", "html", "x", null, false]],
|
|
"errors": [
|
|
{ "code": "eof-in-doctype", "col": 25, "line": 1 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE with systemId",
|
|
"input":"<!DOCTYPE html SYSTEM \"-//W3C//DTD HTML Transitional 4.01//EN\">",
|
|
"output":[["DOCTYPE", "html", null, "-//W3C//DTD HTML Transitional 4.01//EN", true]]},
|
|
|
|
{"description":"DOCTYPE with single-quoted systemId",
|
|
"input":"<!DOCTYPE html SYSTEM '-//W3C//DTD HTML Transitional 4.01//EN'>",
|
|
"output":[["DOCTYPE", "html", null, "-//W3C//DTD HTML Transitional 4.01//EN", true]]},
|
|
|
|
{"description":"DOCTYPE with publicId and systemId",
|
|
"input":"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML Transitional 4.01//EN\" \"-//W3C//DTD HTML Transitional 4.01//EN\">",
|
|
"output":[["DOCTYPE", "html", "-//W3C//DTD HTML Transitional 4.01//EN", "-//W3C//DTD HTML Transitional 4.01//EN", true]]},
|
|
|
|
{"description":"DOCTYPE with > in double-quoted publicId",
|
|
"input":"<!DOCTYPE html PUBLIC \">x",
|
|
"output":[["DOCTYPE", "html", "", null, false], ["Character", "x"]],
|
|
"errors": [
|
|
{ "code": "abrupt-doctype-public-identifier", "col": 24, "line": 1 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE with > in single-quoted publicId",
|
|
"input":"<!DOCTYPE html PUBLIC '>x",
|
|
"output":[["DOCTYPE", "html", "", null, false], ["Character", "x"]],
|
|
"errors": [
|
|
{ "code": "abrupt-doctype-public-identifier", "col": 24, "line": 1 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE with > in double-quoted systemId",
|
|
"input":"<!DOCTYPE html PUBLIC \"foo\" \">x",
|
|
"output":[["DOCTYPE", "html", "foo", "", false], ["Character", "x"]],
|
|
"errors": [
|
|
{ "code": "abrupt-doctype-system-identifier", "col": 30, "line": 1 }
|
|
]},
|
|
|
|
{"description":"DOCTYPE with > in single-quoted systemId",
|
|
"input":"<!DOCTYPE html PUBLIC 'foo' '>x",
|
|
"output":[["DOCTYPE", "html", "foo", "", false], ["Character", "x"]],
|
|
"errors": [
|
|
{ "code": "abrupt-doctype-system-identifier", "col": 30, "line": 1 }
|
|
]},
|
|
|
|
{"description":"Incomplete doctype",
|
|
"input":"<!DOCTYPE html ",
|
|
"output":[["DOCTYPE", "html", null, null, false]],
|
|
"errors":[
|
|
{ "code": "eof-in-doctype", "line": 1, "col": 16 }
|
|
]},
|
|
|
|
{"description":"Numeric entity representing the NUL character",
|
|
"input":"�",
|
|
"output":[["Character", "\uFFFD"]],
|
|
"errors":[
|
|
{ "code": "null-character-reference", "line": 1, "col": 8 }
|
|
]},
|
|
|
|
{"description":"Hexadecimal entity representing the NUL character",
|
|
"input":"�",
|
|
"output":[["Character", "\uFFFD"]],
|
|
"errors":[
|
|
{ "code": "null-character-reference", "line": 1, "col": 9 }
|
|
]},
|
|
|
|
{"description":"Numeric entity representing a codepoint after 1114111 (U+10FFFF)",
|
|
"input":"�",
|
|
"output":[["Character", "\uFFFD"]],
|
|
"errors":[
|
|
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 11 }
|
|
]},
|
|
|
|
{"description":"Hexadecimal entity representing a codepoint after 1114111 (U+10FFFF)",
|
|
"input":"�",
|
|
"output":[["Character", "\uFFFD"]],
|
|
"errors":[
|
|
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 13 }
|
|
]},
|
|
|
|
{"description":"Hexadecimal entity pair representing a surrogate pair",
|
|
"input":"��",
|
|
"output":[["Character", "\uFFFD\uFFFD"]],
|
|
"errors":[
|
|
{ "code": "surrogate-character-reference", "line": 1, "col": 9 },
|
|
{ "code": "surrogate-character-reference", "line": 1, "col": 17 }
|
|
]},
|
|
|
|
{"description":"Hexadecimal entity with mixed uppercase and lowercase",
|
|
"input":"ꯍ",
|
|
"output":[["Character", "\uABCD"]]},
|
|
|
|
{"description":"Entity without a name",
|
|
"input":"&;",
|
|
"output":[["Character", "&;"]]},
|
|
|
|
{"description":"Unescaped ampersand in attribute value",
|
|
"input":"<h a='&'>",
|
|
"output":[["StartTag", "h", { "a":"&" }]]},
|
|
|
|
|
|
{"description":"StartTag containing <",
|
|
"input":"<a<b>",
|
|
"output":[["StartTag", "a<b", { }]]},
|
|
|
|
{"description":"Non-void element containing trailing /",
|
|
"input":"<h/>",
|
|
"output":[["StartTag","h",{},true]]},
|
|
|
|
{"description":"Void element with permitted slash",
|
|
"input":"<br/>",
|
|
"output":[["StartTag","br",{},true]]},
|
|
|
|
{"description":"Void element with permitted slash (with attribute)",
|
|
"input":"<br foo='bar'/>",
|
|
"output":[["StartTag","br",{"foo":"bar"},true]]},
|
|
|
|
{"description":"StartTag containing /",
|
|
"input":"<h/a='b'>",
|
|
"output":[["StartTag", "h", { "a":"b" }]],
|
|
"errors":[
|
|
{ "code": "unexpected-solidus-in-tag", "line": 1, "col": 4 }
|
|
]},
|
|
|
|
{"description":"Double-quoted attribute value",
|
|
"input":"<h a=\"b\">",
|
|
"output":[["StartTag", "h", { "a":"b" }]]},
|
|
|
|
{"description":"Unescaped </",
|
|
"input":"</",
|
|
"output":[["Character", "</"]],
|
|
"errors":[
|
|
{ "code": "eof-before-tag-name", "line": 1, "col": 3 }
|
|
]},
|
|
|
|
{"description":"Illegal end tag name",
|
|
"input":"</1>",
|
|
"output":[["Comment", "1"]],
|
|
"errors":[
|
|
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 }
|
|
]},
|
|
|
|
{"description":"Processing instruction",
|
|
"input":"<?namespace>",
|
|
"output":[["ProcessingInstruction", "namespace", ""]]},
|
|
|
|
{"description":"A processing instruction delimited by ?> doesn't contain the delimiting ?",
|
|
"input":"<?foo bar?>",
|
|
"output":[["ProcessingInstruction", "foo", "bar"]]},
|
|
|
|
{"description":"A processing instruction's data delimited by ?> contains the correct amount of ?",
|
|
"input":"<?foo bar??>",
|
|
"output":[["ProcessingInstruction", "foo", "bar?"]]},
|
|
|
|
{"description":"Unescaped <",
|
|
"input":"foo < bar",
|
|
"output":[["Character", "foo < bar"]],
|
|
"errors":[
|
|
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 6 }
|
|
]},
|
|
|
|
{"description":"Null Byte Replacement",
|
|
"input":"\u0000",
|
|
"output":[["Character", "\u0000"]],
|
|
"errors":[
|
|
{ "code": "unexpected-null-character", "line": 1, "col": 1 }
|
|
]},
|
|
|
|
{"description":"Comment with dash",
|
|
"input":"<!---x",
|
|
"output":[["Comment", "-x"]],
|
|
"errors":[
|
|
{ "code": "eof-in-comment", "line": 1, "col": 7 }
|
|
]},
|
|
|
|
{"description":"Entity + newline",
|
|
"input":"\nx\n>\n",
|
|
"output":[["Character","\nx\n>\n"]]},
|
|
|
|
{"description":"Start tag with no attributes but space before the greater-than sign",
|
|
"input":"<h >",
|
|
"output":[["StartTag", "h", {}]]},
|
|
|
|
{"description":"Empty attribute followed by uppercase attribute",
|
|
"input":"<h a B=''>",
|
|
"output":[["StartTag", "h", {"a":"", "b":""}]]},
|
|
|
|
{"description":"Double-quote after attribute name",
|
|
"input":"<h a \">",
|
|
"output":[["StartTag", "h", {"a":"", "\"":""}]],
|
|
"errors":[
|
|
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 6 }
|
|
]},
|
|
|
|
{"description":"Single-quote after attribute name",
|
|
"input":"<h a '>",
|
|
"output":[["StartTag", "h", {"a":"", "'":""}]],
|
|
"errors":[
|
|
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 6 }
|
|
]},
|
|
|
|
{"description":"Empty end tag with following characters",
|
|
"input":"a</>bc",
|
|
"output":[["Character", "abc"]],
|
|
"errors":[
|
|
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
|
]},
|
|
|
|
{"description":"Empty end tag with following tag",
|
|
"input":"a</><b>c",
|
|
"output":[["Character", "a"], ["StartTag", "b", {}], ["Character", "c"]],
|
|
"errors":[
|
|
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
|
]},
|
|
|
|
{"description":"Empty end tag with following comment",
|
|
"input":"a</><!--b-->c",
|
|
"output":[["Character", "a"], ["Comment", "b"], ["Character", "c"]],
|
|
"errors":[
|
|
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
|
]},
|
|
|
|
{"description":"Empty end tag with following end tag",
|
|
"input":"a</></b>c",
|
|
"output":[["Character", "a"], ["EndTag", "b"], ["Character", "c"]],
|
|
"errors":[
|
|
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
|
]}
|
|
|
|
]}
|