@@ -145,7 +145,9 @@ export class CRPage implements PageDelegate {
145145 if ( options . ignoreHTTPSErrors )
146146 promises . push ( this . _client . send ( 'Security.setIgnoreCertificateErrors' , { ignore : true } ) ) ;
147147 if ( options . viewport )
148- promises . push ( this . _updateViewport ( true /* updateTouch */ ) ) ;
148+ promises . push ( this . _updateViewport ( ) ) ;
149+ if ( options . hasTouch )
150+ promises . push ( this . _client . send ( 'Emulation.setTouchEmulationEnabled' , { enabled : true } ) ) ;
149151 if ( options . javaScriptEnabled === false )
150152 promises . push ( this . _client . send ( 'Emulation.setScriptExecutionDisabled' , { value : true } ) ) ;
151153 if ( options . userAgent || options . locale )
@@ -378,10 +380,10 @@ export class CRPage implements PageDelegate {
378380
379381 async setViewportSize ( viewportSize : types . Size ) : Promise < void > {
380382 assert ( this . _page . _state . viewportSize === viewportSize ) ;
381- await this . _updateViewport ( false /* updateTouch */ ) ;
383+ await this . _updateViewport ( ) ;
382384 }
383385
384- async _updateViewport ( updateTouch : boolean ) : Promise < void > {
386+ async _updateViewport ( ) : Promise < void > {
385387 const options = this . _browserContext . _options ;
386388 let viewport = options . viewport || { width : 0 , height : 0 } ;
387389 const viewportSize = this . _page . _state . viewportSize ;
@@ -399,8 +401,6 @@ export class CRPage implements PageDelegate {
399401 screenOrientation : isLandscape ? { angle : 90 , type : 'landscapePrimary' } : { angle : 0 , type : 'portraitPrimary' } ,
400402 } ) ,
401403 ] ;
402- if ( updateTouch )
403- promises . push ( this . _client . send ( 'Emulation.setTouchEmulationEnabled' , { enabled : ! ! options . hasTouch } ) ) ;
404404 await Promise . all ( promises ) ;
405405 }
406406
0 commit comments