//>>built define("doh/robot",["doh/_browserRunner","require","dojo/aspect","dojo/Deferred","dojo/dom-class","dojo/dom-construct","dojo/dom-geometry","dojo/_base/lang","dojo/ready","dojo/_base/unload","dojo/when","dojo/_base/window","dojo/sniff","dojo/has","dojo/has!android?doh/plugins/android-webdriver-robot"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f){ var _10=null; var _11=(function(){ var key=Math.random(); return function(fcn){ return key; }; })(); var _12=function(_13,_14,alt,_15,_16,_17,_18,_19){ _10.typeKey(_11(),Number(_13),Number(_14),Boolean(alt),Boolean(_15),Boolean(_16),Boolean(_17),Number(_18||0),Boolean(_19||false)); }; var _1a; _3.before(_1,"_runFixture",function(){ var _1b=_1a; setTimeout(function(){ if(_1b&&!_1b.isFulfilled()){ _1b.cancel(new Error("new test starting, cancelling pending & in-progress queued events from previous test")); } },0); _1a=new _4(); _1a.resolve(true); }); var _1c={x:5,y:5}; var _1d=_1.robot={_robotLoaded:true,_robotInitialized:false,_spaceReceived:false,_primePump:false,_killApplet:function(){ },killRobot:function(){ if(_1d._robotLoaded){ _1d._robotLoaded=false; _5.remove(document.documentElement,"dohRobot"); _1d._killApplet(); } },_runsemaphore:{lock:["lock"],unlock:function(){ try{ return this.lock.shift(); } catch(e){ return null; } }},startRobot:function(){ if(!this._robotInitialized){ this._robotInitialized=true; if(_1d._appletDead){ _1d._onKeyboard(); }else{ _10._callLoaded(_11()); } } return this._started; },_loaded:new _1.Deferred(),_initRobot:function(r){ if(_1._initRobotCalled){ return; } _1._initRobotCalled=true; _5.add(document.documentElement,"dohRobot"); window.scrollTo(0,0); _10=r; _10._setKey(_11()); this._loaded.resolve(true); },_started:new _1.Deferred(),_run:function(_1e){ _1e.style.visibility="hidden"; this._started.resolve(true); },_initKeyboard:function(){ _10._initKeyboard(_11()); },_onKeyboard:function(){ this._run({style:{visibility:""}}); },_initWheel:function(){ _10._initWheel(_11()); },_setDocumentBounds:function(_1f,_20){ var _21=document.getElementById("dohrobotview"); _10.setDocumentBounds(_11(),Number(_1f),Number(_20),Number(_21.offsetLeft),Number(_21.offsetTop)); },_notified:function(_22){ _10._notified(_11(),_22); },_appletDead:false,_assertRobot:function(){ if(_1d._appletDead){ throw new Error("robot not available; skipping test."); } },_mouseMove:function(x,y,_23,_24){ if(_23){ var _25={y:(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),x:(window.pageXOffset||_7.fixIeBiDiScrollLeft(document.documentElement.scrollLeft)||document.body.scrollLeft||0)}; y-=_25.y; x-=_25.x; } _10.moveMouse(_11(),Number(x),Number(y),Number(0),Number(_24||100)); },sequence:function(f,_26,_27){ function _28(ms){ return function(){ var _29,d; d=new _4(function(){ clearTimeout(_29); }); _29=setTimeout(function(){ d.resolve(true); },ms); return d; }; }; if(_26){ _1a=_1a.then(_28(_26)); } _1a=_1a.then(f); if(_27){ _1a=_1a.then(_28(_27)); } },typeKeys:function(_2a,_2b,_2c){ this._assertRobot(); var _2d=typeof (_2a)==Number; _2c=_2c||(_2d?50:_2a.length*50); if(_2d){ this.sequence(_8.partial(_12,_2a,_2a,false,false,false,false,0,0),_2b,_2c); }else{ for(var i=0;i<_2a.length;i++){ this.sequence(_8.partial(_12,_2a.charCodeAt(i),0,false,false,false,false,0,0),i==0?_2b:0,Math.max(Math.ceil(_2c/_2a.length),0)); } } },keyPress:function(_2e,_2f,_30,_31){ this._assertRobot(); if(!_30){ _30={alt:false,ctrl:false,shift:false,meta:false}; }else{ var _32=["alt","ctrl","shift","meta"]; for(var i=0;i<_32.length;i++){ if(!_30[_32[i]]){ _30[_32[i]]=false; } } } var _33=typeof (_2e)=="string"; if(_31){ _12(_33?_2e.charCodeAt(0):0,_33?0:_2e,_30.alt,_30.ctrl,_30.shift,_30.meta,_2f,true); return; } this.sequence(function(){ _12(_33?_2e.charCodeAt(0):0,_33?0:_2e,_30.alt,_30.ctrl,_30.shift,_30.meta,0); },_2f); },keyDown:function(_34,_35){ this._assertRobot(); this.sequence(function(){ var _36=typeof (_34)=="string"; _10.downKey(_11(),_36?_34:0,_36?0:_34,0); },_35); },keyUp:function(_37,_38){ this._assertRobot(); this.sequence(function(){ var _39=typeof (_37)=="string"; _10.upKey(_11(),_39?_37:0,_39?0:_37,0); },_38); },mouseClick:function(_3a,_3b){ this._assertRobot(); _1d.mousePress(_3a,_3b); _1d.mouseRelease(_3a,1); },mousePress:function(_3c,_3d){ this._assertRobot(); if(!_3c){ return; } this.sequence(function(){ var _3e=["left","middle","right"]; for(var i=0;i<_3e.length;i++){ if(!_3c[_3e[i]]){ _3c[_3e[i]]=false; } } _10.pressMouse(_11(),Boolean(_3c.left),Boolean(_3c.middle),Boolean(_3c.right),Number(0)); },_3d); },mouseMoveTo:function(_3f,_40,_41,_42){ this._assertRobot(); _41=_41||100; var _43=_41<=1?1:(_41/15)|1; var _44=Math.floor(_41/_43); var _45,end; this.sequence(function(){ _45=_1c; if(_42){ var _46={y:(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),x:(window.pageXOffset||_7.fixIeBiDiScrollLeft(document.documentElement.scrollLeft)||document.body.scrollLeft||0)}; end={y:_3f.y-_46.y,x:_3f.x-_46.x}; }else{ end=_3f; } },_40||0); function _47(idx){ function _48(t,b,c,d){ t/=d/2; if(t<1){ return Math.round(c/2*t*t+b); } t--; return Math.round(-c/2*(t*(t-2)-1)+b); }; var x=idx==_43?end.x:_48(idx,_45.x,end.x-_45.x,_43),y=idx==_43?end.y:_48(idx,_45.y,end.y-_45.y,_43); if(x==_1c.x&&y==_1c.y){ return true; } _10.moveMouse(_11(),Number(x),Number(y),Number(0),Number(1)); _1c={x:x,y:y}; }; for(var t=1;t<=_43;t++){ this.sequence(_8.partial(_47,t),0,_44); } },mouseMove:function(x,y,_49,_4a,_4b){ this.mouseMoveTo({x:x,y:y},_49,_4a,_4b); },mouseRelease:function(_4c,_4d){ this._assertRobot(); if(!_4c){ return; } this.sequence(function(){ var _4e=["left","middle","right"]; for(var i=0;i<_4e.length;i++){ if(!_4c[_4e[i]]){ _4c[_4e[i]]=false; } } _10.releaseMouse(_11(),Boolean(_4c.left),Boolean(_4c.middle),Boolean(_4c.right),Number(0)); },_4d); },mouseWheelSize:1,mouseWheel:function(_4f,_50,_51){ this._assertRobot(); if(!_4f){ return; } this.sequence(function(){ _10.wheelMouse(_11(),Number(_4f),Number(0),Number(_51||0)); },_50,_51); },setClipboard:function(_52,_53){ if(_53==="text/html"){ _10.setClipboardHtml(_11(),_52); }else{ _10.setClipboardText(_11(),_52); } }}; _9(function(){ var _54; var _55=document.getElementsByTagName("script"); for(var x=0;x<_55.length;x++){ var s=_55[x].getAttribute("src"); if(s&&(s.substr(s.length-9)=="runner.js")){ _54=s.substr(0,s.length-9)+"Robot.html"; break; } } if(!_54){ _54=_2.toUrl("./Robot.html")+"?domain="+escape(document.domain); } _6.place("
",_c.body()); if(!_e("doh-custom-robot")){ _6.place("",_c.body()); }else{ _10=_f; for(var i in _10){ if(_1d[i]&&_10[i]){ _1d[i]=_10[i]; } } _1d._initRobot(_10); } }); _1.registerGroup("initialize robot",[{name:"load robot",timeout:120000,runTest:function(){ return _1d._loaded; }},{name:"start robot",timeout:20000,runTest:function(){ return _1d.startRobot(); }}]); var _56=_1.run; _1.run=function(){ _1.registerGroup("kill robot",{name:"killRobot",timeout:10000,runTest:function(){ _1d.killRobot(); }}); _1.run=_56; _1.run(); }; return _1d; });