1414 * limitations under the License.
1515 */
1616
17+ import * as debug from 'debug' ;
1718import * as fs from 'fs' ;
1819import * as mime from 'mime' ;
1920import * as path from 'path' ;
@@ -36,6 +37,8 @@ export type ClickOptions = PointerActionOptions & input.MouseClickOptions;
3637
3738export type MultiClickOptions = PointerActionOptions & input . MouseMultiClickOptions ;
3839
40+ const debugInput = debug ( 'pw:input' ) ;
41+
3942export class FrameExecutionContext extends js . ExecutionContext {
4043 readonly frame : frames . Frame ;
4144 private _injectedPromise ?: Promise < js . JSHandle > ;
@@ -112,7 +115,9 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
112115 }
113116
114117 async _scrollRectIntoViewIfNeeded ( rect ?: types . Rect ) : Promise < void > {
118+ debugInput ( 'scrolling into veiw if needed...' ) ;
115119 await this . _page . _delegate . scrollRectIntoViewIfNeeded ( this , rect ) ;
120+ debugInput ( '...done' ) ;
116121 }
117122
118123 async scrollIntoViewIfNeeded ( ) {
@@ -186,11 +191,16 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
186191 if ( ! force )
187192 await this . _waitForHitTargetAt ( point , options ) ;
188193
194+ point . x = ( point . x * 100 | 0 ) / 100 ;
195+ point . y = ( point . y * 100 | 0 ) / 100 ;
196+
189197 await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
190198 let restoreModifiers : input . Modifier [ ] | undefined ;
191199 if ( options && options . modifiers )
192200 restoreModifiers = await this . _page . keyboard . _ensureModifiers ( options . modifiers ) ;
201+ debugInput ( 'performing input action...' ) ;
193202 await action ( point ) ;
203+ debugInput ( '...done' ) ;
194204 if ( restoreModifiers )
195205 await this . _page . keyboard . _ensureModifiers ( restoreModifiers ) ;
196206 } , options , true ) ;
@@ -356,13 +366,16 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
356366 }
357367
358368 async _waitForDisplayedAtStablePosition ( options : types . TimeoutOptions = { } ) : Promise < void > {
369+ debugInput ( 'waiting for element to be displayed and not moving...' ) ;
359370 const stablePromise = this . _evaluateInUtility ( ( { injected, node } , timeout ) => {
360371 return injected . waitForDisplayedAtStablePosition ( node , timeout ) ;
361372 } , options . timeout || 0 ) ;
362373 await helper . waitWithTimeout ( stablePromise , 'element to be displayed and not moving' , options . timeout || 0 ) ;
374+ debugInput ( '...done' ) ;
363375 }
364376
365377 async _waitForHitTargetAt ( point : types . Point , options : types . TimeoutOptions = { } ) : Promise < void > {
378+ debugInput ( `waiting for element to receive pointer events at (${ point . x } ,${ point . y } ) ...` ) ;
366379 const frame = await this . ownerFrame ( ) ;
367380 if ( frame && frame . parentFrame ( ) ) {
368381 const element = await frame . frameElement ( ) ;
@@ -375,7 +388,8 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
375388 const hitTargetPromise = this . _evaluateInUtility ( ( { injected, node } , { timeout, point } ) => {
376389 return injected . waitForHitTargetAt ( node , timeout , point ) ;
377390 } , { timeout : options . timeout || 0 , point } ) ;
378- await helper . waitWithTimeout ( hitTargetPromise , 'element to receive mouse events' , options . timeout || 0 ) ;
391+ await helper . waitWithTimeout ( hitTargetPromise , 'element to receive pointer events' , options . timeout || 0 ) ;
392+ debugInput ( '...done' ) ;
379393 }
380394}
381395
0 commit comments