Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(domparser): use the Document interface for parsed XML
ldm0f846fcb7f21c
diff --git a/moli-renderer-v8/src/dom_parser.rs b/moli-renderer-v8/src/dom_parser.rsindex f1703887c..02ec8c727 100644--- a/moli-renderer-v8/src/dom_parser.rs+++ b/moli-renderer-v8/src/dom_parser.rs@@ -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,diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/detached.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/detached.rsindex 249996477..33b2106b2 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_elements/detached.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/detached.rs@@ -8034,7 +8034,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 [@@ -8867,7 +8867,7 @@ fn detached_document_content_type_controls_element_creation_after_root_mutations}#[test]-fn domparser_xml_preserves_requested_content_type_for_success_and_error_documents() {+fn domparser_xml_preserves_content_type_and_document_interface_for_success_and_errors() {let mut vm = new_storage_test_vm("https://domparser-xml-content-type.test/");let result = vm@@ -8886,7 +8886,11 @@ fn domparser_xml_preserves_requested_content_type_for_success_and_error_documentreturn [valid.contentType,invalid.contentType,- invalid.documentElement.localName+ invalid.documentElement.localName,+ Object.getPrototypeOf(valid) === Document.prototype,+ valid instanceof XMLDocument,+ Object.getPrototypeOf(invalid) === Document.prototype,+ invalid instanceof XMLDocument];}));})()@@ -8896,7 +8900,7 @@ fn domparser_xml_preserves_requested_content_type_for_success_and_error_documentassert_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","text/xml","html",true,false,true,false],["application/xml","application/xml","html",true,false,true,false],["application/xhtml+xml","application/xhtml+xml","html",true,false,true,false],["image/svg+xml","image/svg+xml","html",true,false,true,false]]"#);}