Skip to content

Commit fbfeef3

Browse files
author
mika
committed
Fix taking snapshot of local iframes
contentDocument of some local iframes can be null, in this case, we should ignore these iframes.
1 parent 1941cee commit fbfeef3

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/js/snapshot/snapshot.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)