@@ -6,46 +6,47 @@ var request = Promise.promisify(require('request'), {multiArgs: true});
66
77module . exports = function ( done ) {
88
9- var that = this ;
9+ var ctx = this ;
1010
1111 return Promise . try ( function setOriginalResolution ( ) {
1212 /**
1313 * if screenwidth was set, get back to old resolution
1414 */
15- if ( ! that . self . defaultScreenDimension ) return ;
15+ if ( ! ctx . self . defaultScreenDimension ) return ;
1616
17- return that . instance . windowHandleSize ( {
18- width : that . self . defaultScreenDimension . width ,
19- height : that . self . defaultScreenDimension . height
17+ return ctx . instance . windowHandleSize ( {
18+ width : ctx . self . defaultScreenDimension . width ,
19+ height : ctx . self . defaultScreenDimension . height
2020 } ) ;
2121 } )
2222 /**
2323 * If we have an applitools session open, close it
2424 */
2525 . then ( function closeApplitools ( ) {
26- if ( ! that . self . usesApplitools ) return ;
26+ if ( ! ctx . self . usesApplitools ) return ;
2727
2828 // Whether or not we should automatically save this test as baseline.
29- var updateBaseline = ( that . self . isNew && that . applitools . saveNewTests ) ||
30- ( ! that . self . isNew && that . applitools . saveFailedTests ) ;
29+ var updateBaseline = ( ctx . self . isNew && ctx . applitools . saveNewTests ) ||
30+ ( ! ctx . self . isNew && ctx . applitools . saveFailedTests ) ;
3131
3232 return request ( {
33- qs : { apiKey : that . applitools . apiKey , updateBaseline : updateBaseline } ,
34- url : that . self . host + '/api/sessions/running/' + that . self . sessionId ,
33+ qs : { apiKey : ctx . applitools . apiKey , updateBaseline : updateBaseline } ,
34+ url : ctx . self . host + '/api/sessions/running/' + ctx . self . sessionId ,
3535 method : 'DELETE' ,
36- headers : that . self . headers ,
37- timeout : that . self . reqTimeout
36+ headers : ctx . self . headers ,
37+ timeout : ctx . self . reqTimeout
38+ } )
39+ . spread ( function clearAndStore ( res , body ) {
40+ if ( ! body ) return ;
41+
42+ ctx . self . resultObject [ ctx . currentArgs . name ] = merge ( {
43+ id : ctx . self . sessionId ,
44+ url : ctx . self . url
45+ } , JSON . parse ( body ) ) ;
46+ ctx . self . url = undefined ;
47+ ctx . self . sessionId = undefined ;
48+ ctx . self . isNew = undefined ;
3849 } ) ;
3950 } )
40- . spread ( function clearAndStore ( res , body ) {
41- if ( ! body ) return ;
42-
43- that . self . resultObject [ that . currentArgs . name ] = merge ( {
44- id : that . self . sessionId ,
45- url : that . self . url
46- } , JSON . parse ( body ) ) ;
47- that . self . url = undefined ;
48- that . self . sessionId = undefined ;
49- that . self . isNew = undefined ;
50- } ) . nodeify ( done ) ;
51+ . nodeify ( done ) ;
5152} ;
0 commit comments