Auto merge of #25223 - pshaughn:xmlerrortype, r=Manishearth

Changed error type on qname, per spec

<!-- Please describe your changes on the following line: -->
As specified in https://dom.spec.whatwg.org/#validate invalid QNames when creating a namespaced document/element/attribute get an invalid character exception, not a namespace exception.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25110

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2020-02-12 17:55:06 -05:00 committed by GitHub
commit 69152c7c96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 3 additions and 289 deletions

View file

@ -10,15 +10,10 @@ use html5ever::{LocalName, Namespace, Prefix};
/// Validate a qualified name. See https://dom.spec.whatwg.org/#validate for details.
pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult {
// Step 2.
match xml_name_type(qualified_name) {
XMLName::InvalidXMLName => {
// Step 1.
Err(Error::InvalidCharacter)
},
XMLName::Name => {
// Step 2.
Err(Error::Namespace)
},
XMLName::InvalidXMLName => Err(Error::InvalidCharacter),
XMLName::Name => Err(Error::InvalidCharacter), // see whatwg/dom#671
XMLName::QName => Ok(()),
}
}

View file

@ -12,78 +12,12 @@
[createDocument test: "http://example.com/","ெ:a",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: null,":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: null,"foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: null,"f:o:o",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: null,":",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "",":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "","foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: undefined,":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: undefined,"foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: undefined,"f::oo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/",":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","f:o:o",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","f::oo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","a:0",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","a:ெ",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","prefix::local",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "/",":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "/","foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://www.w3.org/XML/1998/namespace",":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://www.w3.org/XML/1998/namespace","foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://www.w3.org/2000/xmlns/",":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://www.w3.org/2000/xmlns/","foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "foo:",":foo",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "foo:","foo:",null,"INVALID_CHARACTER_ERR"]
expected: FAIL
[createDocument test: "http://example.com/","a:̀",null,"INVALID_CHARACTER_ERR"]
expected: FAIL

View file

@ -1,11 +0,0 @@
[DOMImplementation-createDocumentType.html]
type: testharness
[createDocumentType(":foo", "", "") should throw INVALID_CHARACTER_ERR]
expected: FAIL
[createDocumentType("foo:", "", "") should throw INVALID_CHARACTER_ERR]
expected: FAIL
[createDocumentType("prefix::local", "", "") should throw INVALID_CHARACTER_ERR]
expected: FAIL

View file

@ -102,123 +102,6 @@
[createElementNS test in XML document: "foo:","foo:","NAMESPACE_ERR"]
expected: FAIL
[createElementNS test in HTML document: null,":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: null,":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: null,":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: null,"foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: null,"foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: null,"foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: null,"f:o:o","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: null,"f:o:o","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: null,"f:o:o","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: null,":","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: null,":","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: null,":","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: undefined,":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: undefined,":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: undefined,":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: undefined,"foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: undefined,"foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: undefined,"foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: undefined,"f::oo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: undefined,"f::oo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: undefined,"f::oo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://example.com/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","f:o:o","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","f:o:o","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","f:o:o","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","a:0","INVALID_CHARACTER_ERR"]
expected: FAIL
@ -237,87 +120,6 @@
[createElementNS test in XHTML document: "http://example.com/","a:ெ","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://www.w3.org/XML/1998/namespace",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://www.w3.org/XML/1998/namespace",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://www.w3.org/XML/1998/namespace",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://www.w3.org/XML/1998/namespace","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://www.w3.org/XML/1998/namespace","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://www.w3.org/XML/1998/namespace","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://www.w3.org/2000/xmlns/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://www.w3.org/2000/xmlns/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://www.w3.org/2000/xmlns/",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://www.w3.org/2000/xmlns/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "http://www.w3.org/2000/xmlns/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "http://www.w3.org/2000/xmlns/","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "foo:",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "foo:",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "foo:",":foo","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "foo:","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XML document: "foo:","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in XHTML document: "foo:","foo:","INVALID_CHARACTER_ERR"]
expected: FAIL
[createElementNS test in HTML document: "http://example.com/","a:̀","INVALID_CHARACTER_ERR"]
expected: FAIL

View file

@ -1,6 +0,0 @@
[attributes.html]
type: testharness
[When qualifiedName does not match the QName production, an INVALID_CHARACTER_ERR exception is to be thrown.]
expected: FAIL