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

FormData wrapper breaks XMLHttpRequest#send(FormData) in Firefox #725

Closed
kegluneq opened this issue Aug 26, 2014 · 4 comments · Fixed by googlearchive/ShadowDOM#507
Closed
Assignees
Labels

Comments

@kegluneq
Copy link

XMLHttpRequest does not unwrap the FormData object when sending, causing the following error in Firefox:

NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED: JavaScript component does not have a method named: "available"'JavaScript component does not have a method named: "available"' when calling method: [nsIInputStream::available]
request.send(formData);

Screenshot

Example:

<script src="platform.js"></script>
<script>
  function doIt() {
    var request = new XMLHttpRequest();
    request.open('POST', '//localhost:8000/handle');
    request.send(new FormData());
  }
</script>
<a href="javascript:doIt();">Click</a>

Removing the platform.js script tag or executing the following code fixes the issue:

var oldSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function(arg) { oldSend.call(this, unwrap(arg)); };

Browser: Firefox 31.0, Mozilla Firefox for Ubuntu canonical - 1.0
Platform: 0.3.5
ShadowDOM: c4da63735ba6c00a7d6af5c1b118f84bd6a2e114

@jmesserly jmesserly self-assigned this Aug 27, 2014
@jmesserly jmesserly added the p1 label Aug 27, 2014
@jmesserly
Copy link
Contributor

Sounds like we can just wrap XHR.send ... taking a look

@kevinc
Copy link

kevinc commented Sep 9, 2014

any updates on this? just ran into this as well

@arv
Copy link
Contributor

arv commented Sep 9, 2014

Wrapping XMLHttpRequest.prototype.send to do unwrapIfNeeded should be sufficient.

@jmesserly
Copy link
Contributor

doh, got distracted by other stuff. looks like I have a half finished branch with the code change but not a test yet... adding that now

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

Successfully merging a pull request may close this issue.

4 participants