@@ -1092,7 +1092,7 @@ export class Frame extends SdkObject {
10921092 } , this . _page . _timeoutSettings . timeout ( options ) ) ;
10931093 }
10941094
1095- async _waitForFunctionExpression < R > ( metadata : CallMetadata , expression : string , isFunction : boolean | undefined , arg : any , options : types . WaitForFunctionOptions = { } ) : Promise < js . SmartHandle < R > > {
1095+ async _waitForFunctionExpression < R > ( metadata : CallMetadata , expression : string , isFunction : boolean | undefined , arg : any , options : types . WaitForFunctionOptions , world : types . World = 'main' ) : Promise < js . SmartHandle < R > > {
10961096 const controller = new ProgressController ( metadata , this ) ;
10971097 if ( typeof options . pollingInterval === 'number' )
10981098 assert ( options . pollingInterval > 0 , 'Cannot poll with non-positive interval: ' + options . pollingInterval ) ;
@@ -1116,19 +1116,18 @@ export class Frame extends SdkObject {
11161116 return injectedScript . pollInterval ( polling , ( progress , continuePolling ) => predicate ( arg ) || continuePolling ) ;
11171117 } , { expression, isFunction, polling : options . pollingInterval , arg } ) ;
11181118 return controller . run (
1119- progress => this . _scheduleRerunnableHandleTask ( progress , 'main' , task ) ,
1119+ progress => this . _scheduleRerunnableHandleTask ( progress , world , task ) ,
11201120 this . _page . _timeoutSettings . timeout ( options ) ) ;
11211121 }
11221122
1123- async waitForFunctionValue < R > ( progress : Progress , pageFunction : js . Func1 < any , R > ) {
1123+ async waitForFunctionValueInUtility < R > ( progress : Progress , pageFunction : js . Func1 < any , R > ) {
11241124 const expression = `() => {
11251125 const result = (${ pageFunction } )();
11261126 if (!result)
11271127 return result;
11281128 return JSON.stringify(result);
1129-
11301129 }` ;
1131- const handle = await this . _page . mainFrame ( ) . _waitForFunctionExpression ( internalCallMetadata ( ) , expression , true , undefined , { timeout : progress . timeUntilDeadline ( ) } ) ;
1130+ const handle = await this . _waitForFunctionExpression ( internalCallMetadata ( ) , expression , true , undefined , { timeout : progress . timeUntilDeadline ( ) } , 'utility' ) ;
11321131 return JSON . parse ( handle . rawValue ( ) ) as R ;
11331132 }
11341133
0 commit comments