/*! DexterJS - v0.5.4 - * https://github.com/leobalter/DexterJS * Copyright (c) 2014 Leonardo Balter; Licensed MIT, GPL */ !function(){function setDexterObjs(a,b,c){a._oldCall=b[c],a._seenObj=b,a._seenMethod=c}function DexterObj(a,b,c,d){var e=this;if(this.called=0,this.isActive=!0,"string"!=typeof c)throw"Dexter should receive method name as a String";if(!b||"function"!=typeof b[c])throw'Dexter should receive a valid object and method combination in arguments. Ex.: window & "alert".';"function"==typeof d&&(this.callback=d),setDexterObjs(this,b,c),b[c]=function(){var b=[].slice.apply(arguments);return e.called=e.called+1,actions[a].call(this,e,b)}}function createDexterObj(a){return function(b,c,d){var e=new DexterObj(a,b,c,d);return Dexter.stored.push(e),e}}function restoreAll(){for(;Dexter.stored.length;)Dexter.stored.pop().restore();return 0===Dexter.stored.length}function Timer(){return this instanceof Timer?(setTimeout=fakeSetTimeout,setInterval=fakeSetInterval,clearTimeout=fakeClearTimer,clearInterval=fakeClearTimer,void 0):new Timer}function fakeSetTimeout(a,b){return timerArray.push({cb:a,time:b,type:"timeout"}),timerArray.length}function fakeSetInterval(a,b){return timerArray.push({cb:a,time:b,type:"interval",originalTime:b}),timerArray.length}function fakeClearTimer(a){timerArray.splice(a-1,1)}var Dexter={stored:[]},timerArray=[],restore,actions,originalTimeout=setTimeout,originalInterval=setInterval,originalClearTimeout=clearTimeout,originalClearInterval=clearInterval;restore=function(){this._seenObj[this._seenMethod]=this._oldCall,this.isActive=!1},actions={spy:function(a,b){var c=a._oldCall.apply(this,b);return"function"==typeof a.callback&&a.callback.apply(this,b),c},fake:function(a,b){return"function"==typeof a.callback?a.callback.apply(this,b):void 0}},DexterObj.prototype={restore:restore},Timer.prototype={tick:function(a){for(var b,c=0;cthis.UNSENT&&this.sendFlag?this.DONE:this.UNSENT)},getResponseHeader:function(a){var b,c=this.responseHeaders;if(this.readyState=0||/^(Sec-|Proxy-)/.test(a))throw new Error('Refused to set unsafe header "'+a+'"');this.requestHeaders[a]?this.requestHeaders[a]+=","+c:this.requestHeaders[a]=c},getAllResponseHeaders:function(){var a,b="";if(this.readyState