XMLHttpRequest.responseXML returns null when a network error occurs

This commit is contained in:
petosorus 2019-10-01 23:28:35 +02:00
parent 75c201f78e
commit f089d166bc

View file

@ -1292,12 +1292,17 @@ impl XMLHttpRequest {
// https://xhr.spec.whatwg.org/#document-response
fn document_response(&self) -> Option<DomRoot<Document>> {
// Step 1
// Caching: if we have existing response xml, redirect it directly
let response = self.response_xml.get();
if response.is_some() {
return self.response_xml.get();
}
// Step 1
if self.response_status.get().is_err() {
return None;
}
let mime_type = self.final_mime_type();
// TODO: prescan the response to determine encoding if final charset is null
let charset = self.final_charset().unwrap_or(UTF_8);