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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top