File tree 1 file changed +14
-7
lines changed
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 {
114
114
}
115
115
116
116
async renderPage ( page , options = { } ) {
117
- let { path : filepath , type } = options ;
117
+ let { path : filepath , type, waitForNavigation } = options ;
118
118
let buffer ;
119
119
120
120
if ( ! isString ( type ) ) {
121
121
type = isString ( filepath ) ? path . extname ( filepath ) . slice ( 1 ) : 'html' ;
122
122
type = type . length > 0 ? type : 'html' ;
123
123
}
124
124
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
+
125
138
switch ( type ) {
126
139
case 'html' :
127
140
buffer = await page . _chromePage . content ( ) ;
@@ -134,12 +147,6 @@ export class ChromeRenderer extends Renderer {
134
147
delete options . emulateMedia ;
135
148
}
136
149
137
- await page . _chromePage . waitForNavigation ( {
138
- waitUntil : 'networkidle' ,
139
- networkIdleInflight : 0 ,
140
- timeout : 0
141
- } ) ;
142
-
143
150
buffer = await page . _chromePage . pdf ( options ) ;
144
151
break ;
145
152
default :
You can’t perform that action at this time.
0 commit comments