Auto merge of #24342 - petosorus:null_responseXml, r=jdm

XMLHttpRequest.responseXML returns null when a network error occurs

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #24285 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because tests ___

<!-- 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. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24342)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-10-02 17:38:46 -04:00 committed by GitHub
commit d1b16afe04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 38 deletions

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);