File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -114,14 +114,27 @@ export class ChromeRenderer extends Renderer {
114114 }
115115
116116 async renderPage ( page , options = { } ) {
117- let { path : filepath , type } = options ;
117+ let { path : filepath , type, waitForNavigation } = options ;
118118 let buffer ;
119119
120120 if ( ! isString ( type ) ) {
121121 type = isString ( filepath ) ? path . extname ( filepath ) . slice ( 1 ) : 'html' ;
122122 type = type . length > 0 ? type : 'html' ;
123123 }
124124
125+ if ( waitForNavigation !== false ) {
126+ if ( waitForNavigation === Object ( waitForNavigation ) ) {
127+ await page . _chromePage . waitForNavigation ( waitForNavigation ) ;
128+ } else {
129+ await page . _chromePage . waitForNavigation ( {
130+ waitUntil : 'networkidle' ,
131+ networkIdleInflight : 0 ,
132+ timeout : 0
133+ } ) ;
134+ }
135+ delete options . waitForNavigation ;
136+ }
137+
125138 switch ( type ) {
126139 case 'html' :
127140 buffer = await page . _chromePage . content ( ) ;
@@ -134,12 +147,6 @@ export class ChromeRenderer extends Renderer {
134147 delete options . emulateMedia ;
135148 }
136149
137- await page . _chromePage . waitForNavigation ( {
138- waitUntil : 'networkidle' ,
139- networkIdleInflight : 0 ,
140- timeout : 0
141- } ) ;
142-
143150 buffer = await page . _chromePage . pdf ( options ) ;
144151 break ;
145152 default :
You can’t perform that action at this time.
0 commit comments