busterjs/buster — Issue #123: IE8 compatibility: make sinon's fakeTimers and fakeXHR work
Author: meisl
Created: 2012-03-06 19:47:57+00:00
State: open

**Setup:**
- WinXP Pro SP3 32bit, node 0.6.11 via .msi installer, npm is 1.1.1 (came with the .msi)
- buster 0.4.5 beta2 installed via npm with a few hacks by hand to get it going:
- alongside buster/: [pre-built contextify](https://github.com/downloads/Benvie/contextify/contextify-0.1.1-node0.6-win32.zip) (ATTENTION: needs some more, not to be used as-is)
- watch-tree installed via npm into buster/node_modules (used by buster-autotest, missing from deps) - yet this is *defunct on Win*
-simple browser tests (html-scaffold only) use the 0.4.5 [buster-test.js](http://busterjs.org/releases/0.4.5/buster-test.js) and [buster-test.css](http://busterjs.org/releases/0.4.5/buster-test.css) from [busterjs.org](http://busterjs.org/download/)

**Problem:**
sinon's fakeTimers (clock.tick(..) etc) and fake XHR (try to) replace the global Date, setTimeout(..), setInterval(..), etc and XMLHttpRequest(..) which IE8 (don't know about other IE versions) simply ignores.

**Workaround:**
There is [sinon-ie-1.3.1.js](http://sinonjs.org/releases/sinon-ie-1.3.1.js) which addresses the issue but it assumes a sinon object in the global namespace which we don't have with buster.
So the hack that I did is first exposing sinon as a property of the global buster object like so:
```javascript
...
}(typeof global != "undefined" ? global : this));
buster.sinon = sinon; // need access to sinon so we can apply IE 8 fixes re fakeTimers
;return buster; }());
```
(the line I inserted is the last but one, in buster-test.js)
then in turn setting the global var sinon to this and finally have [sinon-ie-1.3.1.js](http://sinonjs.org/releases/sinon-ie-1.3.1.js) do its job.
Messy, isn't it? Sure you guys know a better place to apply the "IE-cheating".

**Note:**
sinon is actually a [project of its own](https://github.com/cjohansen/Sinon.JS) but spies, fake timers etc are
available when using buster, as properties of "this" in the tests. Since [sinon-ie-1.3.1.js](http://sinonjs.org/releases/sinon-ie-1.3.1.js) fixes the issue
for stand-alone sinon, it's rather a matter of integration with buster. So that's why I file it here.

p.s.: I'm fully aware that Windows support is a thing for the future - just trying to help a little with it.