v147 · Security · Memory Safety
Compatibility Lab
Probes DOMParser with all four XML MIME types, XMLSerializer, and XMLHttpRequest document mode. Runs a live XML parse round-trip via DOMParser → XMLSerializer across well-formed, namespace-heavy, and intentionally malformed inputs to confirm the Rust-backed parser handles edge cases correctly.
API probes
XML parser backend matrix
| API / scenario | Chrome ≤146 | Chrome 147+ | Parser backend |
|---|---|---|---|
| DOMParser — application/xml | C++ (libxml2) | ✓ Rust | Non-XSLT XML parse |
| DOMParser — text/xml | C++ (libxml2) | ✓ Rust | Non-XSLT XML parse |
| DOMParser — image/svg+xml | C++ (libxml2) | ✓ Rust | SVG XML parse |
| DOMParser — text/html | C++ HTML parser | C++ HTML parser | HTML (unchanged) |
| XSLTProcessor | C++ (libxml2) | C++ (libxml2) | XSLT path unchanged |
| XMLHttpRequest responseXML | C++ (libxml2) | ✓ Rust | Response XML parse |
Non-XSLT parser surface
DOMParser.parseFromString()coversapplication/xml,text/xml,image/svg+xml, andapplication/xhtml+xmlinputs on the Rust path.XMLHttpRequest.responseXMLand fetched XML text parsed withDOMParserexercise the same non-XSLT parser surface.- DTD declarations, parameter entities, and external entity references are parser inputs; the demo checks structural outcomes instead of relying on libxml-specific error strings.
XSLTProcessorremains outside this change and is shown separately as the C++ libxml2 path.
Live XML round-trip test
DOMParser → XMLSerializer round-trip
Click "Run XML parse tests" to exercise DOMParser with various XML inputs…
Safe XML parsing pattern
/* XML parsing in Chrome 147 — same API, Rust backend */
/* The web API is unchanged — your existing code continues to work.
Chrome 147 only changes the parser implementation (C++ → Rust). */
const parser = new DOMParser();
const serializer = new XMLSerializer();
/* Parse XML — Rust-backed in Chrome 147+ */
function parseXML(xmlString, mimeType = 'application/xml') {
const doc = parser.parseFromString(xmlString, mimeType);
/* Check for parse errors */
const errNode = doc.querySelector('parsererror');
if (errNode) {
throw new Error('XML parse error: ' + errNode.textContent.trim());
}
return doc;
}
/* Roundtrip: parse then serialise */
function xmlRoundtrip(xmlString) {
const doc = parseXML(xmlString);
return serializer.serializeToString(doc);
}
/* Fetch XML — Rust parser handles response body in Chrome 147+ */
async function fetchXML(url) {
const response = await fetch(url);
const text = await response.text();
return parseXML(text);
}
/* XMLHttpRequest response document — also Rust-backed in Chrome 147+ */
function xhrXML(url, callback) {
const xhr = new XMLHttpRequest();
xhr.responseType = 'document';
xhr.open('GET', url);
xhr.onload = () => callback(xhr.responseXML);
xhr.send();
}
/* No API changes needed — memory safety improvement is transparent. */
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗