11define ( [
2- 'dojo/aspect' ,
3- 'dojo/topic' ,
4- 'dojo/request' ,
5- 'dojo/Promise' ,
62 '../util' ,
7- '../sendData' ,
3+ // Conditional load sendData for testability
4+ 'dojo/has!host-browser?../sendData' ,
85 'require'
9- ] , function ( aspect , topic , request , Promise , util , sendData , require ) {
10- function scroll ( ) {
11- window . scrollTo ( 0 , document . documentElement . scrollHeight || document . body . scrollHeight ) ;
12- }
13-
6+ ] , function (
7+ util ,
8+ sendData ,
9+ require
10+ ) {
1411 function WebDriver ( config ) {
1512 config = config || { } ;
1613
@@ -33,7 +30,7 @@ define([
3330 $others : function ( name ) {
3431 // never send coverage events; coverage is handled explicitly by Proxy
3532 if ( name !== 'coverage' && name !== 'run' ) {
36- return this . _send ( Array . prototype . slice . call ( arguments , 0 ) ) ;
33+ return this . _sendEvent ( name , Array . prototype . slice . call ( arguments , 1 ) ) ;
3734 }
3835 } ,
3936
@@ -72,7 +69,7 @@ define([
7269 oldSuiteNode . appendChild ( outerSuiteNode ) ;
7370 }
7471
75- scroll ( ) ;
72+ this . _scroll ( ) ;
7673 }
7774
7875 return this . _sendEvent ( 'suiteStart' , arguments ) ;
@@ -86,7 +83,7 @@ define([
8683 var errorNode = document . createElement ( 'pre' ) ;
8784 errorNode . appendChild ( document . createTextNode ( util . getErrorMessage ( error ) ) ) ;
8885 this . suiteNode . appendChild ( errorNode ) ;
89- scroll ( ) ;
86+ this . _scroll ( ) ;
9087 }
9188
9289 return this . _sendEvent ( 'suiteError' , arguments ) ;
@@ -97,7 +94,7 @@ define([
9794 this . testNode = document . createElement ( 'li' ) ;
9895 this . testNode . appendChild ( document . createTextNode ( test . name ) ) ;
9996 this . suiteNode . appendChild ( this . testNode ) ;
100- scroll ( ) ;
97+ this . _scroll ( ) ;
10198 }
10299
103100 return this . _sendEvent ( 'testStart' , arguments ) ;
@@ -107,7 +104,7 @@ define([
107104 if ( this . writeHtml ) {
108105 this . testNode . appendChild ( document . createTextNode ( ' passed (' + test . timeElapsed + 'ms)' ) ) ;
109106 this . testNode . style . color = 'green' ;
110- scroll ( ) ;
107+ this . _scroll ( ) ;
111108 }
112109
113110 return this . _sendEvent ( 'testPass' , arguments ) ;
@@ -120,7 +117,7 @@ define([
120117 ( test . skipped ? ' (' + test . skipped + ')' : '' ) ) ) ;
121118 testNode . style . color = 'gray' ;
122119 this . suiteNode . appendChild ( testNode ) ;
123- scroll ( ) ;
120+ this . _scroll ( ) ;
124121 }
125122
126123 return this . _sendEvent ( 'testSkip' , arguments ) ;
@@ -134,7 +131,7 @@ define([
134131 var errorNode = document . createElement ( 'pre' ) ;
135132 errorNode . appendChild ( document . createTextNode ( util . getErrorMessage ( test . error ) ) ) ;
136133 this . testNode . appendChild ( errorNode ) ;
137- scroll ( ) ;
134+ this . _scroll ( ) ;
138135 }
139136
140137 return this . _sendEvent ( 'testFail' , arguments ) ;
@@ -148,6 +145,10 @@ define([
148145 if ( shouldWait ) {
149146 return promise ;
150147 }
148+ } ,
149+
150+ _scroll : function ( ) {
151+ window . scrollTo ( 0 , document . documentElement . scrollHeight || document . body . scrollHeight ) ;
151152 }
152153 } ;
153154
0 commit comments