mirror of
https://github.com/lexmount/moli.git
synced 2026-10-20 00:01:39 +00:00
fix(domparser): align XML parse documents with HTML
This commit is contained in:
@@ -2556,7 +2556,6 @@ domparsing/DOMParser-parseFromString-url-moretests.html
|
||||
domparsing/DOMParser-parseFromString-url-pushstate.html
|
||||
domparsing/DOMParser-parseFromString-url.html
|
||||
domparsing/DOMParser-parseFromString-xml-internal-subset.html
|
||||
domparsing/DOMParser-parseFromString-xml.html
|
||||
domparsing/XMLSerializer-serializeToString.html
|
||||
domparsing/insert_adjacent_html.html
|
||||
domparsing/tentative/all-stream-methods-with-trusted-types-no-policy.html
|
||||
|
||||
@@ -4102,6 +4102,7 @@ domparsing/DOMParser-parseFromString-html.html
|
||||
domparsing/DOMParser-parseFromString-stylesheets.html
|
||||
domparsing/DOMParser-parseFromString-xml-doctype.html
|
||||
domparsing/DOMParser-parseFromString-xml-parsererror.html
|
||||
domparsing/DOMParser-parseFromString-xml.html
|
||||
domparsing/createContextualFragment-in-detached-xml-document-crash.html
|
||||
domparsing/createContextualFragment.html
|
||||
domparsing/domparser-spurious-attributes.html
|
||||
|
||||
@@ -25,10 +25,21 @@ const PARSER_ERROR_DETAIL_STYLE: &str = "font-family:monospace;font-size:12px";
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum DetachedDocumentKind {
|
||||
Document,
|
||||
Html,
|
||||
Xml,
|
||||
}
|
||||
|
||||
impl DetachedDocumentKind {
|
||||
fn bridge_kind(self) -> &'static str {
|
||||
match self {
|
||||
Self::Document => "plain",
|
||||
Self::Html => "html",
|
||||
Self::Xml => "xml",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, webidl::WebIdlEnum)]
|
||||
#[webidl(name = "SupportedType")]
|
||||
enum DomParserSupportedType {
|
||||
@@ -193,7 +204,7 @@ pub(super) fn parse_detached_document_from_string<'s>(
|
||||
build_detached_document_with_content_type(
|
||||
scope,
|
||||
parsed,
|
||||
DetachedDocumentKind::Xml,
|
||||
DetachedDocumentKind::Document,
|
||||
false,
|
||||
Some(mime),
|
||||
)
|
||||
@@ -447,13 +458,9 @@ fn build_detached_document_with_content_type<'s>(
|
||||
content_type: Option<&str>,
|
||||
) -> Option<v8::Local<'s, v8::Object>> {
|
||||
let _ = expose_declarative_shadow_roots;
|
||||
let kind = match kind {
|
||||
DetachedDocumentKind::Html => "html",
|
||||
DetachedDocumentKind::Xml => "xml",
|
||||
};
|
||||
build_detached_document_object_from_dom_host_with_content_type(
|
||||
scope,
|
||||
kind,
|
||||
kind.bridge_kind(),
|
||||
DomHost::from_dom(parsed),
|
||||
content_type,
|
||||
None,
|
||||
@@ -467,11 +474,7 @@ fn build_detached_document_from_dom_host<'s>(
|
||||
expose_declarative_shadow_roots: bool,
|
||||
) -> Option<v8::Local<'s, v8::Object>> {
|
||||
let _ = expose_declarative_shadow_roots;
|
||||
let kind = match kind {
|
||||
DetachedDocumentKind::Html => "html",
|
||||
DetachedDocumentKind::Xml => "xml",
|
||||
};
|
||||
build_detached_document_object_from_dom_host(scope, kind, parsed)
|
||||
build_detached_document_object_from_dom_host(scope, kind.bridge_kind(), parsed)
|
||||
}
|
||||
|
||||
fn build_detached_document_from_dom_host_with_content_type<'s>(
|
||||
@@ -483,13 +486,9 @@ fn build_detached_document_from_dom_host_with_content_type<'s>(
|
||||
character_set: Option<&str>,
|
||||
) -> Option<v8::Local<'s, v8::Object>> {
|
||||
let _ = expose_declarative_shadow_roots;
|
||||
let kind = match kind {
|
||||
DetachedDocumentKind::Html => "html",
|
||||
DetachedDocumentKind::Xml => "xml",
|
||||
};
|
||||
build_detached_document_object_from_dom_host_with_content_type(
|
||||
scope,
|
||||
kind,
|
||||
kind.bridge_kind(),
|
||||
parsed,
|
||||
content_type,
|
||||
character_set,
|
||||
|
||||
@@ -363,7 +363,7 @@ fn offline_html_documents_parse_and_serialize_noscript_with_scripting_disabled()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domparser_xml_preserves_requested_content_type_for_success_and_error_documents() {
|
||||
fn domparser_xml_uses_document_interface_and_chromium_error_documents() {
|
||||
let mut vm = new_storage_test_vm("https://domparser-xml-content-type.test/");
|
||||
|
||||
let result = vm
|
||||
@@ -378,14 +378,24 @@ fn domparser_xml_preserves_requested_content_type_for_success_and_error_document
|
||||
"image/svg+xml"
|
||||
].map(contentType => {
|
||||
const valid = parser.parseFromString("<root/>", contentType);
|
||||
const invalid = parser.parseFromString(
|
||||
const invalid = parser.parseFromString("<foo>", contentType);
|
||||
const namespaceInvalid = parser.parseFromString(
|
||||
'<span x:test="testing">1</span>',
|
||||
contentType
|
||||
);
|
||||
const invalidError = invalid.getElementsByTagName("parsererror")[0];
|
||||
const namespaceError = namespaceInvalid.getElementsByTagName("parsererror")[0];
|
||||
return [
|
||||
valid.contentType,
|
||||
Object.getPrototypeOf(valid) === Document.prototype,
|
||||
valid instanceof XMLDocument,
|
||||
invalid.contentType,
|
||||
invalid.documentElement.localName
|
||||
Object.getPrototypeOf(invalid) === Document.prototype,
|
||||
invalid instanceof XMLDocument,
|
||||
invalid.documentElement.localName,
|
||||
invalidError.namespaceURI,
|
||||
namespaceInvalid.documentElement.localName,
|
||||
namespaceError.namespaceURI
|
||||
];
|
||||
}));
|
||||
})()
|
||||
@@ -395,7 +405,7 @@ fn domparser_xml_preserves_requested_content_type_for_success_and_error_document
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
r#"[["text/xml","text/xml","html"],["application/xml","application/xml","html"],["application/xhtml+xml","application/xhtml+xml","html"],["image/svg+xml","image/svg+xml","html"]]"#
|
||||
r#"[["text/xml",true,false,"text/xml",true,false,"foo","http://www.w3.org/1999/xhtml","html","http://www.w3.org/1999/xhtml"],["application/xml",true,false,"application/xml",true,false,"foo","http://www.w3.org/1999/xhtml","html","http://www.w3.org/1999/xhtml"],["application/xhtml+xml",true,false,"application/xhtml+xml",true,false,"foo","http://www.w3.org/1999/xhtml","html","http://www.w3.org/1999/xhtml"],["image/svg+xml",true,false,"image/svg+xml",true,false,"foo","http://www.w3.org/1999/xhtml","html","http://www.w3.org/1999/xhtml"]]"#
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8347,7 +8357,7 @@ fn detached_document_state_accessors_are_declared_on_prototypes() {
|
||||
descriptorOwner(htmlProto, "fonts") === Document.prototype,
|
||||
descriptorOwner(htmlProto, "implementation") === Document.prototype,
|
||||
htmlProto === HTMLDocument.prototype,
|
||||
xmlProto === XMLDocument.prototype
|
||||
xmlProto === Document.prototype
|
||||
].join(",");
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user