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

xhr incompatible with environments that honor object freezing #149

Open
ianwremmel opened this issue Jan 11, 2017 · 8 comments · May be fixed by #182
Open

xhr incompatible with environments that honor object freezing #149

ianwremmel opened this issue Jan 11, 2017 · 8 comments · May be fixed by #182
Assignees
Milestone

Comments

@ianwremmel
Copy link

xhr assigns values to the XMLHttpRequest instance which causes errors in environments that disallow unknown properties. One such environment is SalesForce Aura.

ianwremmel added a commit to ianwremmel/xhr that referenced this issue Jan 11, 2017
@naugtur
Copy link
Owner

naugtur commented Jan 11, 2017 via email

@ianwremmel
Copy link
Author

hmm, ok. is there a timeline for that v3? I hate running off of forks, but I guess I'll have to in this case.

@naugtur
Copy link
Owner

naugtur commented Jan 11, 2017 via email

@ianwremmel
Copy link
Author

yea, i need to get it working in the next few weeks; that said, I can point at my branch just as easily as yours and that's probably safer since you're definitely planning breaking changes in yours :)

@naugtur
Copy link
Owner

naugtur commented Jan 11, 2017

I did some more looking around and it seems that the requirement of freezing XMLHttpRequest is a bit unusual.
Can you share some more context on that? XMLHttpRequest is generally open to any modifications in all browsers I know of. How is it different in Aura?

Just removing the functionality of being able to check what the request options were is not only a breaking change, it's also blocking the possibility of asserting certain things in tests. I'll have to change the response object to contain a reference to request options probably.

@ianwremmel
Copy link
Author

I can try to explain, but I only roughly understand it: Aura and/or Locker is SalesForce's tool for running untrusted code in their UI. It works by pretty much cloning the entire window API and giving plugins a thing that looks like a Window. One of the additional constraints appears to be that they freeze all HTML-specified Objects.

@naugtur
Copy link
Owner

naugtur commented Jan 13, 2017

Makes sense.
On the other hand, I wonder if xhr should be altered functionally for such an edge case.

For now, I brought back the features you removed under a different key and fixed tests. see https://github.com/naugtur/xhr/tree/ianwremmel-fix-frozen-objects

@naugtur naugtur self-assigned this Jan 13, 2017
@naugtur naugtur added this to the v3.0 milestone Jan 13, 2017
@ianwremmel
Copy link
Author

I think that makes sense, but is request the right property name? Is there an analog in request?

And yea, I had mixed feelings about changing xhr, but I figured it would be easier than getting getting Locker/Aura rearchitected. I also kinda felt like strapping those values to the xhr instance was a bit unnecessary in that I couldn't imagine a scenario where an xhr consumer would have an instance and not have any easy way of knowing what values they created the instance with. That said, I'm clearly thinking selfishly here :)

@naugtur naugtur linked a pull request Jul 26, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants