-
Notifications
You must be signed in to change notification settings - Fork 47
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
Conversation
@@ -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") { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
@mroderick could you have a look please? |
Thank you! Sorry for having this lingering so long. |
Now
responseType
is not passed to original XHR object after callingdefake
. This causes unexpected type ofxhr.response
when sending defaked requests withresponseType = "arraybuffer"
(response is a string instead of ArrayBuffer).