@@ -364,14 +364,24 @@ async function takeSnapshotOfCurrNode_HTML(node, params) {
364364 // There still has a posibility that it's content
365365 // was generated by JS rather than just blank.
366366
367- const children = [ node . contentDocument ] ;
368- const newDomParams = Object . assign (
369- { } , domParams ,
370- ( params . domParams_localFrame || { } ) ,
371- { frameInfo : newFrameInfo }
372- ) ;
373- const childParams = Object . assign ( { } , params , { domParams : newDomParams } ) ;
374- return { snapshot, children, childParams} ;
367+ if ( node . contentDocument ) {
368+ const children = [ node . contentDocument ] ;
369+ const newDomParams = Object . assign (
370+ { } , domParams ,
371+ ( params . domParams_localFrame || { } ) ,
372+ { frameInfo : newFrameInfo }
373+ ) ;
374+ const childParams = Object . assign ( { } , params , { domParams : newDomParams } ) ;
375+ return { snapshot, children, childParams} ;
376+ } else {
377+ // Some local frames are used to run scripts only (something called iframe jax),
378+ // these scripts may cause the contentDocument become null,
379+ // for instance: (changing the URL of the document)
380+ snapshot . childNodes = [ ] ;
381+ snapshot . errorMessage = 'can not access contentDocument of iframe' ;
382+ snapshot . render = 'ignore' ;
383+ return { snapshot} ;
384+ }
375385 }
376386
377387
0 commit comments