script: Update name validation for attribute, element, and doctype (#37747)

A recent update in the spec (https://github.com/whatwg/dom/pull/1079)
introduced new rules for name validation of attribute, element, and
doctype. This PR implements the new name validation rules in
`components/script/dom/bindings/domname.rs`. The old XML name validation
rules are not fully removed because there remains a few usage of it in
`ProcessingInstructions` and `xpath`.

Testing: Covered by WPT tests
Fixes: #37746

---------

Signed-off-by: minghuaw <michael.wu1107@gmail.com>
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
This commit is contained in:
minghuaw 2025-07-11 10:45:52 +08:00 committed by GitHub
parent e14556959d
commit 5b507dc871
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 380 additions and 872 deletions

View file

@ -1,216 +0,0 @@
[DOMImplementation-createDocument.html]
[createDocument test: null,";foo",null,null]
expected: FAIL
[createDocument test: metadata for null,";foo",null]
expected: FAIL
[createDocument test: characterSet aliases for null,";foo",null]
expected: FAIL
[createDocument test: null,"f}oo",null,null]
expected: FAIL
[createDocument test: metadata for null,"f}oo",null]
expected: FAIL
[createDocument test: characterSet aliases for null,"f}oo",null]
expected: FAIL
[createDocument test: null,"foo}",null,null]
expected: FAIL
[createDocument test: metadata for null,"foo}",null]
expected: FAIL
[createDocument test: characterSet aliases for null,"foo}",null]
expected: FAIL
[createDocument test: null,"\\ufffffoo",null,null]
expected: FAIL
[createDocument test: metadata for null,"\\ufffffoo",null]
expected: FAIL
[createDocument test: characterSet aliases for null,"\\ufffffoo",null]
expected: FAIL
[createDocument test: null,"f\\uffffoo",null,null]
expected: FAIL
[createDocument test: metadata for null,"f\\uffffoo",null]
expected: FAIL
[createDocument test: characterSet aliases for null,"f\\uffffoo",null]
expected: FAIL
[createDocument test: null,"foo\\uffff",null,null]
expected: FAIL
[createDocument test: metadata for null,"foo\\uffff",null]
expected: FAIL
[createDocument test: characterSet aliases for null,"foo\\uffff",null]
expected: FAIL
[createDocument test: null,"f<oo",null,null]
expected: FAIL
[createDocument test: metadata for null,"f<oo",null]
expected: FAIL
[createDocument test: characterSet aliases for null,"f<oo",null]
expected: FAIL
[createDocument test: null,":foo",null,null]
expected: FAIL
[createDocument test: metadata for null,":foo",null]
expected: FAIL
[createDocument test: characterSet aliases for null,":foo",null]
expected: FAIL
[createDocument test: null,"f:o:o",null,"NAMESPACE_ERR"]
expected: FAIL
[createDocument test: "",":foo",null,null]
expected: FAIL
[createDocument test: metadata for "",":foo",null]
expected: FAIL
[createDocument test: characterSet aliases for "",":foo",null]
expected: FAIL
[createDocument test: undefined,":foo",null,null]
expected: FAIL
[createDocument test: metadata for undefined,":foo",null]
expected: FAIL
[createDocument test: characterSet aliases for undefined,":foo",null]
expected: FAIL
[createDocument test: undefined,"f::oo",null,"NAMESPACE_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","fo<o",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","fo<o",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","fo<o",null]
expected: FAIL
[createDocument test: "http://example.com/",":foo",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/",":foo",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/",":foo",null]
expected: FAIL
[createDocument test: "http://example.com/","f:o:o",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","f:o:o",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","f:o:o",null]
expected: FAIL
[createDocument test: "http://example.com/","f::oo",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","f::oo",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","f::oo",null]
expected: FAIL
[createDocument test: "http://example.com/","0:a",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","0:a",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","0:a",null]
expected: FAIL
[createDocument test: "http://example.com/","a:;",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","a:;",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","a:;",null]
expected: FAIL
[createDocument test: "http://example.com/","a:̀",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","a:̀",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","a:̀",null]
expected: FAIL
[createDocument test: "http://example.com/","̀:a",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","̀:a",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","̀:a",null]
expected: FAIL
[createDocument test: "http://example.com/",";:a",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/",";:a",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/",";:a",null]
expected: FAIL
[createDocument test: "http://example.com/","prefix::local",null,null]
expected: FAIL
[createDocument test: metadata for "http://example.com/","prefix::local",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://example.com/","prefix::local",null]
expected: FAIL
[createDocument test: "/",":foo",null,null]
expected: FAIL
[createDocument test: metadata for "/",":foo",null]
expected: FAIL
[createDocument test: characterSet aliases for "/",":foo",null]
expected: FAIL
[createDocument test: "http://www.w3.org/XML/1998/namespace",":foo",null,null]
expected: FAIL
[createDocument test: metadata for "http://www.w3.org/XML/1998/namespace",":foo",null]
expected: FAIL
[createDocument test: characterSet aliases for "http://www.w3.org/XML/1998/namespace",":foo",null]
expected: FAIL
[createDocument test: "http://www.w3.org/2000/xmlns/",":foo",null,"NAMESPACE_ERR"]
expected: FAIL
[createDocument test: "foo:",":foo",null,null]
expected: FAIL
[createDocument test: metadata for "foo:",":foo",null]
expected: FAIL
[createDocument test: characterSet aliases for "foo:",":foo",null]
expected: FAIL

View file

@ -1,141 +0,0 @@
[DOMImplementation-createDocumentType.html]
[createDocumentType("", "", "") should work]
expected: FAIL
[createDocumentType("1foo", "", "") should work]
expected: FAIL
[createDocumentType("@foo", "", "") should work]
expected: FAIL
[createDocumentType("foo@", "", "") should work]
expected: FAIL
[createDocumentType("f@oo", "", "") should work]
expected: FAIL
[createDocumentType("edi:{", "", "") should work]
expected: FAIL
[createDocumentType("edi:}", "", "") should work]
expected: FAIL
[createDocumentType("edi:~", "", "") should work]
expected: FAIL
[createDocumentType("edi:'", "", "") should work]
expected: FAIL
[createDocumentType("edi:!", "", "") should work]
expected: FAIL
[createDocumentType("edi:@", "", "") should work]
expected: FAIL
[createDocumentType("edi:#", "", "") should work]
expected: FAIL
[createDocumentType("edi:$", "", "") should work]
expected: FAIL
[createDocumentType("edi:%", "", "") should work]
expected: FAIL
[createDocumentType("edi:^", "", "") should work]
expected: FAIL
[createDocumentType("edi:&", "", "") should work]
expected: FAIL
[createDocumentType("edi:*", "", "") should work]
expected: FAIL
[createDocumentType("edi:(", "", "") should work]
expected: FAIL
[createDocumentType("edi:)", "", "") should work]
expected: FAIL
[createDocumentType("edi:+", "", "") should work]
expected: FAIL
[createDocumentType("edi:=", "", "") should work]
expected: FAIL
[createDocumentType("edi:[", "", "") should work]
expected: FAIL
[createDocumentType("edi:\]", "", "") should work]
expected: FAIL
[createDocumentType("edi:\\\\", "", "") should work]
expected: FAIL
[createDocumentType("edi:/", "", "") should work]
expected: FAIL
[createDocumentType("edi:;", "", "") should work]
expected: FAIL
[createDocumentType("edi:`", "", "") should work]
expected: FAIL
[createDocumentType("edi:<", "", "") should work]
expected: FAIL
[createDocumentType("edi:,", "", "") should work]
expected: FAIL
[createDocumentType("edi:\\"", "", "") should work]
expected: FAIL
[createDocumentType("{", "", "") should work]
expected: FAIL
[createDocumentType("}", "", "") should work]
expected: FAIL
[createDocumentType("'", "", "") should work]
expected: FAIL
[createDocumentType("~", "", "") should work]
expected: FAIL
[createDocumentType("`", "", "") should work]
expected: FAIL
[createDocumentType("@", "", "") should work]
expected: FAIL
[createDocumentType("#", "", "") should work]
expected: FAIL
[createDocumentType("$", "", "") should work]
expected: FAIL
[createDocumentType("%", "", "") should work]
expected: FAIL
[createDocumentType("^", "", "") should work]
expected: FAIL
[createDocumentType("&", "", "") should work]
expected: FAIL
[createDocumentType("*", "", "") should work]
expected: FAIL
[createDocumentType("(", "", "") should work]
expected: FAIL
[createDocumentType(")", "", "") should work]
expected: FAIL
[createDocumentType(":foo", "", "") should work]
expected: FAIL
[createDocumentType("foo:", "", "") should work]
expected: FAIL
[createDocumentType("prefix::local", "", "") should work]
expected: FAIL

View file

@ -1,42 +0,0 @@
[Document-createAttribute.html]
[HTML document.createAttribute("invalid^Name")]
expected: FAIL
[XML document.createAttribute("invalid^Name")]
expected: FAIL
[HTML document.createAttribute("\\\\")]
expected: FAIL
[XML document.createAttribute("\\\\")]
expected: FAIL
[HTML document.createAttribute("'")]
expected: FAIL
[XML document.createAttribute("'")]
expected: FAIL
[HTML document.createAttribute("\\"")]
expected: FAIL
[XML document.createAttribute("\\"")]
expected: FAIL
[HTML document.createAttribute("0")]
expected: FAIL
[XML document.createAttribute("0")]
expected: FAIL
[HTML document.createAttribute("0:a")]
expected: FAIL
[XML document.createAttribute("0:a")]
expected: FAIL
[HTML document.createAttribute("~")]
expected: FAIL
[XML document.createAttribute("~")]
expected: FAIL

View file

@ -1,72 +0,0 @@
[Document-createElement.html]
[createElement("̀foo") in HTML document]
expected: FAIL
[createElement("̀foo") in XML document]
expected: FAIL
[createElement("̀foo") in XHTML document]
expected: FAIL
[createElement("f}oo") in HTML document]
expected: FAIL
[createElement("f}oo") in XML document]
expected: FAIL
[createElement("f}oo") in XHTML document]
expected: FAIL
[createElement("foo}") in HTML document]
expected: FAIL
[createElement("foo}") in XML document]
expected: FAIL
[createElement("foo}") in XHTML document]
expected: FAIL
[createElement("\\ufffffoo") in HTML document]
expected: FAIL
[createElement("\\ufffffoo") in XML document]
expected: FAIL
[createElement("\\ufffffoo") in XHTML document]
expected: FAIL
[createElement("f\\uffffoo") in HTML document]
expected: FAIL
[createElement("f\\uffffoo") in XML document]
expected: FAIL
[createElement("f\\uffffoo") in XHTML document]
expected: FAIL
[createElement("foo\\uffff") in HTML document]
expected: FAIL
[createElement("foo\\uffff") in XML document]
expected: FAIL
[createElement("foo\\uffff") in XHTML document]
expected: FAIL
[createElement("f<oo") in HTML document]
expected: FAIL
[createElement("f<oo") in XML document]
expected: FAIL
[createElement("f<oo") in XHTML document]
expected: FAIL
[createElement("̀") in HTML document]
expected: FAIL
[createElement("̀") in XML document]
expected: FAIL
[createElement("̀") in XHTML document]
expected: FAIL

View file

@ -1,234 +0,0 @@
[Document-createElementNS.html]
[createElementNS test in HTML document: null,";foo",null]
expected: FAIL
[createElementNS test in XML document: null,";foo",null]
expected: FAIL
[createElementNS test in XHTML document: null,";foo",null]
expected: FAIL
[createElementNS test in HTML document: null,"f}oo",null]
expected: FAIL
[createElementNS test in XML document: null,"f}oo",null]
expected: FAIL
[createElementNS test in XHTML document: null,"f}oo",null]
expected: FAIL
[createElementNS test in HTML document: null,"foo}",null]
expected: FAIL
[createElementNS test in XML document: null,"foo}",null]
expected: FAIL
[createElementNS test in XHTML document: null,"foo}",null]
expected: FAIL
[createElementNS test in HTML document: null,"\\ufffffoo",null]
expected: FAIL
[createElementNS test in XML document: null,"\\ufffffoo",null]
expected: FAIL
[createElementNS test in XHTML document: null,"\\ufffffoo",null]
expected: FAIL
[createElementNS test in HTML document: null,"f\\uffffoo",null]
expected: FAIL
[createElementNS test in XML document: null,"f\\uffffoo",null]
expected: FAIL
[createElementNS test in XHTML document: null,"f\\uffffoo",null]
expected: FAIL
[createElementNS test in HTML document: null,"foo\\uffff",null]
expected: FAIL
[createElementNS test in XML document: null,"foo\\uffff",null]
expected: FAIL
[createElementNS test in XHTML document: null,"foo\\uffff",null]
expected: FAIL
[createElementNS test in HTML document: null,"f<oo",null]
expected: FAIL
[createElementNS test in XML document: null,"f<oo",null]
expected: FAIL
[createElementNS test in XHTML document: null,"f<oo",null]
expected: FAIL
[createElementNS test in HTML document: null,":foo",null]
expected: FAIL
[createElementNS test in XML document: null,":foo",null]
expected: FAIL
[createElementNS test in XHTML document: null,":foo",null]
expected: FAIL
[createElementNS test in HTML document: null,"f:o:o","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in XML document: null,"f:o:o","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in XHTML document: null,"f:o:o","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in HTML document: "",":foo",null]
expected: FAIL
[createElementNS test in XML document: "",":foo",null]
expected: FAIL
[createElementNS test in XHTML document: "",":foo",null]
expected: FAIL
[createElementNS test in HTML document: undefined,":foo",null]
expected: FAIL
[createElementNS test in XML document: undefined,":foo",null]
expected: FAIL
[createElementNS test in XHTML document: undefined,":foo",null]
expected: FAIL
[createElementNS test in HTML document: undefined,"f::oo","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in XML document: undefined,"f::oo","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in XHTML document: undefined,"f::oo","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","fo<o",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","fo<o",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","fo<o",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/",":foo",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/",":foo",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/",":foo",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","f:o:o",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","f:o:o",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","f:o:o",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","f::oo",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","f::oo",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","f::oo",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","0:a",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","0:a",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","0:a",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","a:;",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","a:;",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","a:;",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","a:̀",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","a:̀",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","a:̀",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","̀:a",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","̀:a",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","̀:a",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/",";:a",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/",";:a",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/",";:a",null]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","prefix::local",null]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","prefix::local",null]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","prefix::local",null]
expected: FAIL
[createElementNS test in HTML document: "/",":foo",null]
expected: FAIL
[createElementNS test in XML document: "/",":foo",null]
expected: FAIL
[createElementNS test in XHTML document: "/",":foo",null]
expected: FAIL
[createElementNS test in HTML document: "http://www.w3.org/XML/1998/namespace",":foo",null]
expected: FAIL
[createElementNS test in XML document: "http://www.w3.org/XML/1998/namespace",":foo",null]
expected: FAIL
[createElementNS test in XHTML document: "http://www.w3.org/XML/1998/namespace",":foo",null]
expected: FAIL
[createElementNS test in HTML document: "http://www.w3.org/2000/xmlns/",":foo","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://www.w3.org/2000/xmlns/",":foo","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://www.w3.org/2000/xmlns/",":foo","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in HTML document: "foo:",":foo",null]
expected: FAIL
[createElementNS test in XML document: "foo:",":foo",null]
expected: FAIL
[createElementNS test in XHTML document: "foo:",":foo",null]
expected: FAIL

View file

@ -1,6 +0,0 @@
[attributes.html]
[Basic functionality should be intact. (toggleAttribute)]
expected: FAIL
[Basic functionality should be intact.]
expected: FAIL

View file

@ -1,15 +0,0 @@
[name-validation.html]
[Valid and invalid characters in createElement.]
expected: FAIL
[Valid and invalid characters in createElementNS and createDocument.]
expected: FAIL
[Valid and invalid characters in setAttribute, toggleAttribute, and createAttribute.]
expected: FAIL
[Valid and invalid characters in setAttributeNS and createAttributeNS.]
expected: FAIL
[Valid and invalid characters in createDocumentType.]
expected: FAIL