Question

Working on a javascript module that pushes data to a cross domain server. I have a testsuite in qunit verifying the behavior, using sinon for intercepting requests and faking responses coming from XmlHttpRequest. This works great, except for IE8/9 which uses XDomainRequest to allow CORS calls (with a somewhat limited functionality).

My issue is that sinon allows for mocking of my use of XmlHttpRequest but not XDomainRequest. After googling I have not been able to find anyone mocking the XDomainRequest. Does anyone have any practical experience with testing around XDomainRequest and what can be done?

Était-ce utile?

La solution

Since sinon at the moment does not support mocking the XDomainRequest I've created a small pullrequest that adds simple mocking support to sinon. Note that the pullrequest is not accepted since it is pretty rough but it worked for me.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top