@@ -45,7 +45,7 @@ export class FrameExecutionContext extends js.ExecutionContext {
45
45
this . frame = frame ;
46
46
}
47
47
48
- async _evaluate ( returnByValue : boolean , pageFunction : string | Function , ...args : any [ ] ) : Promise < any > {
48
+ async _evaluate ( returnByValue : boolean , waitForNavigations : boolean , pageFunction : string | Function , ...args : any [ ] ) : Promise < any > {
49
49
const needsAdoption = ( value : any ) : boolean => {
50
50
return typeof value === 'object' && value instanceof ElementHandle && value . _context !== this ;
51
51
} ;
@@ -54,7 +54,7 @@ export class FrameExecutionContext extends js.ExecutionContext {
54
54
// Only go through asynchronous calls if required.
55
55
return await this . frame . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
56
56
return this . _delegate . evaluate ( this , returnByValue , pageFunction , ...args ) ;
57
- } ) ;
57
+ } , waitForNavigations ? undefined : { waitUntil : 'nowait' } ) ;
58
58
}
59
59
60
60
const toDispose : Promise < ElementHandle > [ ] = [ ] ;
@@ -69,7 +69,7 @@ export class FrameExecutionContext extends js.ExecutionContext {
69
69
try {
70
70
result = await this . frame . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
71
71
return this . _delegate . evaluate ( this , returnByValue , pageFunction , ...adopted ) ;
72
- } ) ;
72
+ } , waitForNavigations ? undefined : { waitUntil : 'nowait' } ) ;
73
73
} finally {
74
74
toDispose . map ( handlePromise => handlePromise . then ( handle => handle . dispose ( ) ) ) ;
75
75
}
@@ -97,7 +97,7 @@ export class FrameExecutionContext extends js.ExecutionContext {
97
97
${ custom . join ( ',\n' ) }
98
98
])
99
99
` ;
100
- this . _injectedPromise = this . evaluateHandle ( source ) ;
100
+ this . _injectedPromise = this . _evaluate ( false /* returnByValue */ , false /* waitForNavigations */ , source ) ;
101
101
this . _injectedGeneration = selectors . _generation ;
102
102
}
103
103
return this . _injectedPromise ;
0 commit comments