|
|
@@ -111,24 +111,26 @@ this.frameTree = this.frameTree || (() => {
|
|
|
timeout.set(() => top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData: [{ windowId: frameWindowId, processed: true }], windowId: frameWindowId, sessionId }), "*"), TIMEOUT_INIT_REQUEST_MESSAGE);
|
|
|
});
|
|
|
top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData, windowId, sessionId }), "*");
|
|
|
- framesData = [];
|
|
|
- frameElements.forEach((frameElement, frameIndex) => {
|
|
|
- const frameWindowId = windowId + "." + frameIndex;
|
|
|
- const frameWindow = frameElement.contentWindow;
|
|
|
- const frameDoc = frameElement.contentDocument;
|
|
|
- if (frameDoc) {
|
|
|
- try {
|
|
|
- processFrames(frameDoc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"), options, frameWindowId, sessionId, frameWindow);
|
|
|
- const docData = docHelper.preProcessDoc(frameDoc, frameWindow, options);
|
|
|
- framesData.push({ windowId: frameWindowId, content: docHelper.serialize(frameDoc), baseURI: frameDoc.baseURI, title: frameDoc.title, emptyStyleRulesText: docData.emptyStyleRulesText, canvasData: docData.canvasData, processed: true });
|
|
|
- docHelper.postProcessDoc(frameDoc, frameWindow, options);
|
|
|
- } catch (error) {
|
|
|
- /* ignored */
|
|
|
+ if (frameElements.length) {
|
|
|
+ framesData = [];
|
|
|
+ frameElements.forEach((frameElement, frameIndex) => {
|
|
|
+ const frameWindowId = windowId + "." + frameIndex;
|
|
|
+ const frameWindow = frameElement.contentWindow;
|
|
|
+ const frameDoc = frameElement.contentDocument;
|
|
|
+ if (frameDoc) {
|
|
|
+ try {
|
|
|
+ processFrames(frameDoc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"), options, frameWindowId, sessionId, frameWindow);
|
|
|
+ const docData = docHelper.preProcessDoc(frameDoc, frameWindow, options);
|
|
|
+ framesData.push({ windowId: frameWindowId, content: docHelper.serialize(frameDoc), baseURI: frameDoc.baseURI, title: frameDoc.title, emptyStyleRulesText: docData.emptyStyleRulesText, canvasData: docData.canvasData, processed: true });
|
|
|
+ docHelper.postProcessDoc(frameDoc, frameWindow, options);
|
|
|
+ } catch (error) {
|
|
|
+ /* ignored */
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- });
|
|
|
- top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData, windowId, sessionId }), "*");
|
|
|
+ });
|
|
|
+ top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData, windowId, sessionId }), "*");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
})();
|