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

Pass responseType for defaked XHR #45

Merged
merged 1 commit into from
Jun 1, 2018
Merged

Pass responseType for defaked XHR #45

merged 1 commit into from
Jun 1, 2018

Conversation

mad-gooze
Copy link
Contributor

Now responseType is not passed to original XHR object after calling defake. This causes unexpected type of xhr.response when sending defaked requests with responseType = "arraybuffer" (response is a string instead of ArrayBuffer).

@@ -190,9 +194,15 @@ FakeXMLHttpRequest.defake = function defake(fakeXhr, xhrArgs) {
copyAttrs(["status", "statusText"]);
}
if (xhr.readyState >= FakeXMLHttpRequest.LOADING) {
copyAttrs(["responseText", "response"]);
copyAttrs(["response"]);
if (xhr.responseType === "" || xhr.responseType === "text") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responseText can be accessed only for text responses

if (xhr.readyState === FakeXMLHttpRequest.DONE) {
if (
xhr.readyState === FakeXMLHttpRequest.DONE &&
(xhr.responseType === "" || xhr.responseType === "document")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responseXML can be accessed only for XML responses

@mad-gooze
Copy link
Contributor Author

mad-gooze commented Apr 23, 2018

@mroderick could you have a look please?

@fatso83
Copy link
Contributor

fatso83 commented Jun 1, 2018

Thank you! Sorry for having this lingering so long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants