Error when requesting blob object urls through XHR
See original GitHub issueWhat is your Scenario?
Using XHR to request object urls of type blob:
will make hammerhead error out and thus, the request is not made.
I tracked down the exception to this line which expects reqOpts
to have a value in the send
wrapper, but no values where defined in the open
method wrapper because it is a local object url.
Here is where the request options are supposed to be set (xhr.open
). This only happens for http
and file
domains, not for blob
which I think makes sense.
And here in xhr.send
it tries to retrieve the request options which never fails for regular requests to http
urls, but since those never are set for blob:
urls, it fails badly.
https://github.com/DevExpress/testcafe-hammerhead/blob/a878aefb01e45c3dc58d9d92da6e618cbc494c4c/src/client/sandbox/xhr.ts#L162
What is the Current behavior?
Considering the following snippet:
const blob = new Blob(['this is a text'], { type: 'plain/text' });
const url = URL.createObjectURL(blob);
const xhr = new XMLHttpRequest();
xhr.open('get', url, false);
xhr.addEventListener('load', () => {
console.log(xhr.responseText);
});
xhr.send(); // <-- this throws an exception: "a is undefined"
Because of the exception, the request is not made.
What is the Expected behavior?
xhr.send();
correctly sends the request and the event listener prints this is a text
.
What is your public web site URL?
Your website URL (or attach your complete example):
Your complete app code (or attach your test files):
Screenshots:
Steps to Reproduce:
- Go to: …
- Execute this command: …
- See the error: …
Your Environment details:
- node.js version:
- browser name and version:
- platform and version:
- other:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top GitHub Comments
Hi @acostajohn
Thank you for the shared information. I’ve reproduced the issue.
For team Steps to reproduce:
in
health-monitor
and press ‘Send blob via xhr’ button.No updates yet. Once we get any results, we will post them in this thread.