@@ -61,9 +61,9 @@ export class FrameExecutionContext extends js.ExecutionContext {
61
61
}
62
62
63
63
async doEvaluateInternal ( returnByValue : boolean , waitForNavigations : boolean , pageFunction : string | Function , ...args : any [ ] ) : Promise < any > {
64
- return await this . frame . _page . _frameManager . waitForSignalsCreatedBy ( async ( ) => {
64
+ return await this . frame . _page . _frameManager . waitForSignalsCreatedBy ( null , ! waitForNavigations , async ( ) => {
65
65
return this . _delegate . evaluate ( this , returnByValue , pageFunction , ...args ) ;
66
- } , Number . MAX_SAFE_INTEGER , waitForNavigations ? undefined : { noWaitAfter : true } ) ;
66
+ } ) ;
67
67
}
68
68
69
69
createHandle ( remoteObject : js . RemoteObject ) : js . JSHandle {
@@ -241,7 +241,6 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
241
241
}
242
242
243
243
async _retryPointerAction ( progress : Progress , action : ( point : types . Point ) => Promise < void > , options : PointerActionOptions & types . PointerActionWaitOptions & types . NavigatingActionWaitOptions ) : Promise < void > {
244
- progress . log ( inputLog , progress . apiName ) ;
245
244
while ( ! progress . isCanceled ( ) ) {
246
245
const result = await this . _performPointerAction ( progress , action , options ) ;
247
246
if ( result === 'done' )
@@ -291,7 +290,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
291
290
progress . log ( inputLog , `...element does receive pointer events, continuing input action` ) ;
292
291
}
293
292
294
- await this . _page . _frameManager . waitForSignalsCreatedBy ( async ( ) => {
293
+ await this . _page . _frameManager . waitForSignalsCreatedBy ( progress , options . noWaitAfter , async ( ) => {
295
294
let restoreModifiers : input . Modifier [ ] | undefined ;
296
295
if ( options && options . modifiers )
297
296
restoreModifiers = await this . _page . keyboard . _ensureModifiers ( options . modifiers ) ;
@@ -301,7 +300,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
301
300
progress . log ( inputLog , 'waiting for scheduled navigations to finish...' ) ;
302
301
if ( restoreModifiers )
303
302
await this . _page . keyboard . _ensureModifiers ( restoreModifiers ) ;
304
- } , progress . deadline , options , true ) ;
303
+ } , 'input' ) ;
305
304
progress . log ( inputLog , '...navigations have finished' ) ;
306
305
307
306
return 'done' ;
@@ -331,9 +330,12 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
331
330
return this . _retryPointerAction ( progress , point => this . _page . mouse . dblclick ( point . x , point . y , options ) , options ) ;
332
331
}
333
332
334
- async selectOption ( values : string | ElementHandle | types . SelectOption | string [ ] | ElementHandle [ ] | types . SelectOption [ ] , options ?: types . NavigatingActionWaitOptions ) : Promise < string [ ] > {
335
- this . _page . _log ( inputLog , `elementHandle.selectOption(%s)` , values ) ;
336
- const deadline = this . _page . _timeoutSettings . computeDeadline ( options ) ;
333
+ async selectOption ( values : string | ElementHandle | types . SelectOption | string [ ] | ElementHandle [ ] | types . SelectOption [ ] , options : types . NavigatingActionWaitOptions = { } ) : Promise < string [ ] > {
334
+ return Progress . runCancelableTask ( progress => this . _selectOption ( progress , values , options ) , options , this . _page , this . _page . _timeoutSettings ) ;
335
+ }
336
+
337
+ async _selectOption ( progress : Progress , values : string | ElementHandle | types . SelectOption | string [ ] | ElementHandle [ ] | types . SelectOption [ ] , options : types . NavigatingActionWaitOptions ) : Promise < string [ ] > {
338
+ progress . log ( inputLog , progress . apiName ) ;
337
339
let vals : string [ ] | ElementHandle [ ] | types . SelectOption [ ] ;
338
340
if ( ! Array . isArray ( values ) )
339
341
vals = [ values ] as ( string [ ] | ElementHandle [ ] | types . SelectOption [ ] ) ;
@@ -350,10 +352,10 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
350
352
if ( option . index !== undefined )
351
353
assert ( helper . isNumber ( option . index ) , 'Indices must be numbers. Found index "' + option . index + '" of type "' + ( typeof option . index ) + '"' ) ;
352
354
}
353
- return await this . _page . _frameManager . waitForSignalsCreatedBy < string [ ] > ( async ( ) => {
355
+ return this . _page . _frameManager . waitForSignalsCreatedBy < string [ ] > ( progress , options . noWaitAfter , async ( ) => {
354
356
const injectedResult = await this . _evaluateInUtility ( ( { injected, node } , selectOptions ) => injected . selectOptions ( node , selectOptions ) , selectOptions ) ;
355
357
return handleInjectedResult ( injectedResult ) ;
356
- } , deadline , options ) ;
358
+ } ) ;
357
359
}
358
360
359
361
async fill ( value : string , options : types . NavigatingActionWaitOptions = { } ) : Promise < void > {
@@ -363,7 +365,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
363
365
async _fill ( progress : Progress , value : string , options : types . NavigatingActionWaitOptions ) : Promise < void > {
364
366
progress . log ( inputLog , `elementHandle.fill("${ value } ")` ) ;
365
367
assert ( helper . isString ( value ) , 'Value must be string. Found value "' + value + '" of type "' + ( typeof value ) + '"' ) ;
366
- await this . _page . _frameManager . waitForSignalsCreatedBy ( async ( ) => {
368
+ await this . _page . _frameManager . waitForSignalsCreatedBy ( progress , options . noWaitAfter , async ( ) => {
367
369
const poll = await this . _evaluateHandleInUtility ( ( { injected, node } , { value } ) => {
368
370
return injected . waitForEnabledAndFill ( node , value ) ;
369
371
} , { value } ) ;
@@ -376,7 +378,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
376
378
else
377
379
await this . _page . keyboard . press ( 'Delete' ) ;
378
380
}
379
- } , progress . deadline , options , true ) ;
381
+ } , 'input' ) ;
380
382
}
381
383
382
384
async selectText ( ) : Promise < void > {
@@ -385,9 +387,12 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
385
387
handleInjectedResult ( injectedResult ) ;
386
388
}
387
389
388
- async setInputFiles ( files : string | types . FilePayload | string [ ] | types . FilePayload [ ] , options ?: types . NavigatingActionWaitOptions ) {
389
- this . _page . _log ( inputLog , `elementHandle.setInputFiles(...)` ) ;
390
- const deadline = this . _page . _timeoutSettings . computeDeadline ( options ) ;
390
+ async setInputFiles ( files : string | types . FilePayload | string [ ] | types . FilePayload [ ] , options : types . NavigatingActionWaitOptions = { } ) {
391
+ return Progress . runCancelableTask ( async progress => this . _setInputFiles ( progress , files , options ) , options , this . _page , this . _page . _timeoutSettings ) ;
392
+ }
393
+
394
+ async _setInputFiles ( progress : Progress , files : string | types . FilePayload | string [ ] | types . FilePayload [ ] , options : types . NavigatingActionWaitOptions ) {
395
+ progress . log ( inputLog , progress . apiName ) ;
391
396
const injectedResult = await this . _evaluateInUtility ( ( { node } ) : types . InjectedScriptResult < boolean > => {
392
397
if ( node . nodeType !== Node . ELEMENT_NODE || ( node as Node as Element ) . tagName !== 'INPUT' )
393
398
return { status : 'error' , error : 'Node is not an HTMLInputElement' } ;
@@ -416,9 +421,9 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
416
421
filePayloads . push ( item ) ;
417
422
}
418
423
}
419
- await this . _page . _frameManager . waitForSignalsCreatedBy ( async ( ) => {
424
+ await this . _page . _frameManager . waitForSignalsCreatedBy ( progress , options . noWaitAfter , async ( ) => {
420
425
await this . _page . _delegate . setInputFiles ( this as any as ElementHandle < HTMLInputElement > , filePayloads ) ;
421
- } , deadline , options ) ;
426
+ } ) ;
422
427
}
423
428
424
429
async focus ( ) {
@@ -427,22 +432,28 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
427
432
handleInjectedResult ( injectedResult ) ;
428
433
}
429
434
430
- async type ( text : string , options ?: { delay ?: number } & types . NavigatingActionWaitOptions ) {
431
- this . _page . _log ( inputLog , `elementHandle.type("${ text } ")` ) ;
432
- const deadline = this . _page . _timeoutSettings . computeDeadline ( options ) ;
433
- await this . _page . _frameManager . waitForSignalsCreatedBy ( async ( ) => {
435
+ async type ( text : string , options : { delay ?: number } & types . NavigatingActionWaitOptions = { } ) {
436
+ return Progress . runCancelableTask ( progress => this . _type ( progress , text , options ) , options , this . _page , this . _page . _timeoutSettings ) ;
437
+ }
438
+
439
+ async _type ( progress : Progress , text : string , options : { delay ?: number } & types . NavigatingActionWaitOptions ) {
440
+ progress . log ( inputLog , `elementHandle.type("${ text } ")` ) ;
441
+ return this . _page . _frameManager . waitForSignalsCreatedBy ( progress , options . noWaitAfter , async ( ) => {
434
442
await this . focus ( ) ;
435
443
await this . _page . keyboard . type ( text , options ) ;
436
- } , deadline , options , true ) ;
444
+ } , 'input' ) ;
445
+ }
446
+
447
+ async press ( key : string , options : { delay ?: number } & types . NavigatingActionWaitOptions = { } ) {
448
+ return Progress . runCancelableTask ( progress => this . _press ( progress , key , options ) , options , this . _page , this . _page . _timeoutSettings ) ;
437
449
}
438
450
439
- async press ( key : string , options ?: { delay ?: number } & types . NavigatingActionWaitOptions ) {
440
- this . _page . _log ( inputLog , `elementHandle.press("${ key } ")` ) ;
441
- const deadline = this . _page . _timeoutSettings . computeDeadline ( options ) ;
442
- await this . _page . _frameManager . waitForSignalsCreatedBy ( async ( ) => {
451
+ async _press ( progress : Progress , key : string , options : { delay ?: number } & types . NavigatingActionWaitOptions ) {
452
+ progress . log ( inputLog , `elementHandle.press("${ key } ")` ) ;
453
+ return this . _page . _frameManager . waitForSignalsCreatedBy ( progress , options . noWaitAfter , async ( ) => {
443
454
await this . focus ( ) ;
444
455
await this . _page . keyboard . press ( key , options ) ;
445
- } , deadline , options , true ) ;
456
+ } , 'input' ) ;
446
457
}
447
458
448
459
async check ( options : types . PointerActionWaitOptions & types . NavigatingActionWaitOptions = { } ) {
0 commit comments