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

Reference global.XMLHttpRequest directly so XMLHttpRequest can be mocked #35

Closed
wants to merge 1 commit into from
Closed

Reference global.XMLHttpRequest directly so XMLHttpRequest can be mocked #35

wants to merge 1 commit into from

Conversation

cacieprins
Copy link

  • check for the existence of global.XMLHttpRequest directly
  • reference global.XMLHttpRequest constructor instead of the constructor
    that was dereferenced when the library was first parsed
  • reference global.XMLHttpRequest status properties directly instead of
    the properties of the prototype of the constructor that was dereferenced
    when the library was first parsed

This will allow mocking libraries that rely on being able to replace
the reference to global.XMLHttpRequest with a mock XMLHttpRequest object
that can be programmatically manipulated.

Such libraries include the jasmine-ajax plugin. I'm sure there are
others.

It's a little more typing, but it fixes a big bug.

- check for global.XMLHttpRequest directly instead of what
global.XMLHttRequest referenced when the library was first parsed
- reference global.XMLHttpRequest constructor instead of the constructor
that was dereferenced when the library was first parsed
- reference global.XMLHttpRequest status properties directly instead of
the properties of the prototype of the constructor that was dereferenced
when the library was first parsed

This will allow mocking libraries that rely on being able to replace
the reference to global.XMLHttpRequest with a mock XMLHttpRequest object
that can be programmatically manipulated.

Such libraries include the jasmine-ajax plugin. I'm sure there are
others.

It's a little more typing, but it fixes a big bug.
@rwaldin
Copy link

rwaldin commented Mar 25, 2015

+1

This pull request was closed.
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.

None yet

2 participants