14
14
* limitations under the License.
15
15
*/
16
16
17
+ import * as debug from 'debug' ;
17
18
import * as fs from 'fs' ;
18
19
import * as mime from 'mime' ;
19
20
import * as path from 'path' ;
@@ -36,6 +37,8 @@ export type ClickOptions = PointerActionOptions & input.MouseClickOptions;
36
37
37
38
export type MultiClickOptions = PointerActionOptions & input . MouseMultiClickOptions ;
38
39
40
+ const debugInput = debug ( 'pw:input' ) ;
41
+
39
42
export class FrameExecutionContext extends js . ExecutionContext {
40
43
readonly frame : frames . Frame ;
41
44
private _injectedPromise ?: Promise < js . JSHandle > ;
@@ -112,7 +115,9 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
112
115
}
113
116
114
117
async _scrollRectIntoViewIfNeeded ( rect ?: types . Rect ) : Promise < void > {
118
+ debugInput ( 'scrolling into veiw if needed...' ) ;
115
119
await this . _page . _delegate . scrollRectIntoViewIfNeeded ( this , rect ) ;
120
+ debugInput ( '...done' ) ;
116
121
}
117
122
118
123
async scrollIntoViewIfNeeded ( ) {
@@ -186,11 +191,16 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
186
191
if ( ! force )
187
192
await this . _waitForHitTargetAt ( point , options ) ;
188
193
194
+ point . x = ( point . x * 100 | 0 ) / 100 ;
195
+ point . y = ( point . y * 100 | 0 ) / 100 ;
196
+
189
197
await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
190
198
let restoreModifiers : input . Modifier [ ] | undefined ;
191
199
if ( options && options . modifiers )
192
200
restoreModifiers = await this . _page . keyboard . _ensureModifiers ( options . modifiers ) ;
201
+ debugInput ( 'performing input action...' ) ;
193
202
await action ( point ) ;
203
+ debugInput ( '...done' ) ;
194
204
if ( restoreModifiers )
195
205
await this . _page . keyboard . _ensureModifiers ( restoreModifiers ) ;
196
206
} , options , true ) ;
@@ -356,13 +366,16 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
356
366
}
357
367
358
368
async _waitForDisplayedAtStablePosition ( options : types . TimeoutOptions = { } ) : Promise < void > {
369
+ debugInput ( 'waiting for element to be displayed and not moving...' ) ;
359
370
const stablePromise = this . _evaluateInUtility ( ( { injected, node } , timeout ) => {
360
371
return injected . waitForDisplayedAtStablePosition ( node , timeout ) ;
361
372
} , options . timeout || 0 ) ;
362
373
await helper . waitWithTimeout ( stablePromise , 'element to be displayed and not moving' , options . timeout || 0 ) ;
374
+ debugInput ( '...done' ) ;
363
375
}
364
376
365
377
async _waitForHitTargetAt ( point : types . Point , options : types . TimeoutOptions = { } ) : Promise < void > {
378
+ debugInput ( `waiting for element to receive pointer events at (${ point . x } ,${ point . y } ) ...` ) ;
366
379
const frame = await this . ownerFrame ( ) ;
367
380
if ( frame && frame . parentFrame ( ) ) {
368
381
const element = await frame . frameElement ( ) ;
@@ -375,7 +388,8 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
375
388
const hitTargetPromise = this . _evaluateInUtility ( ( { injected, node } , { timeout, point } ) => {
376
389
return injected . waitForHitTargetAt ( node , timeout , point ) ;
377
390
} , { 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' ) ;
379
393
}
380
394
}
381
395
0 commit comments