Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLHttpRequest.responseXML should return null when a network error occurs #24285

Closed
jdm opened this issue Sep 25, 2019 · 7 comments
Closed

XMLHttpRequest.responseXML should return null when a network error occurs #24285

jdm opened this issue Sep 25, 2019 · 7 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Sep 25, 2019

Spec: https://xhr.spec.whatwg.org/#document-response step 1
Code: components/script/dom/xmlhttprequest.rs
Test:

  • ./mach test-wpt tests/wpt/web-platform-tests/xhr/xmlhttprequest-network-error.htm
  • ./mach test-wpt tests/wpt/web-platform-tests/xhr/xmlhttprequest-network-error-sync.htm

We fail the assert_equals(client.responseXML, null, "responseXML") check, because we don't check if self.response_status is an Err value in the document_response method before creating a document response to return.

@highfive
Copy link

@highfive highfive commented Sep 25, 2019

Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in IRC.

If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

@petosorus
Copy link
Contributor

@petosorus petosorus commented Sep 26, 2019

Hi!
I'm pretty new to rust and would like to check I'm getting it.

  1. Should the check of response_status be done between the response.is_some() block and the mime_type block?
  2. If the response_status matches Err, should the return be something like
self.response_xml.set(null);
return self.response_xml.get();

Thanks for putting up these tasks marked as Easy :)

@jdm
Copy link
Member Author

@jdm jdm commented Sep 26, 2019

  1. Yes
  2. There should not be any need to set self.response_xml, since it will be empty already. Returning None directly will be most readable.
@CYBAI
Copy link
Collaborator

@CYBAI CYBAI commented Sep 26, 2019

Hi @petosorus , thanks for looking into this!

1. Should the check of response_status be done between the `response.is_some()` block and the `mime_type` block?

I think it might be worth mentioning that, with reading the commit of if response.is_some() { (347f3c1), it's for caching.

So, as @jdm answered, yes, the check of response_status should be done between response.is_some() and mime_type block.

Maybe it's worth updating the comment of response.is_some() checking and say Step 1 above response_status checking instead? (@jdm what do you think?)

Ex.

- // Step 1
+ // Caching: if we have existing response xml, redirect it directly
let response = self.response_xml.get();
...

+ // Step 1.
<!-- the response_status check -->
@jdm
Copy link
Member Author

@jdm jdm commented Sep 26, 2019

Yes, that would be an improvement!

@petosorus
Copy link
Contributor

@petosorus petosorus commented Sep 26, 2019

Ok, that's cool with me! I'll start tonight then.

@highfive: assign me

@highfive highfive added the C-assigned label Sep 26, 2019
@highfive
Copy link

@highfive highfive commented Sep 26, 2019

Hey @petosorus! Thanks for your interest in working on this issue. It's now assigned to you!

bors-servo added a commit that referenced this issue Oct 1, 2019
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 -->
bors-servo added a commit that referenced this issue Oct 2, 2019
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 -->
bors-servo added a commit that referenced this issue Oct 2, 2019
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 -->
bors-servo added a commit that referenced this issue Oct 2, 2019
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 -->
@bors-servo bors-servo closed this in d1b16af Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.