|
@@ -125,7 +125,7 @@ this.FrameTree = this.FrameTree || (() => {
|
|
|
FrameTree.index = message.index;
|
|
FrameTree.index = message.index;
|
|
|
const frameElements = document.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]");
|
|
const frameElements = document.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]");
|
|
|
if (frameElements.length) {
|
|
if (frameElements.length) {
|
|
|
- setFramesWinId(MESSAGE_PREFIX, frameElements, FrameTree.index, FrameTree.windowId, window);
|
|
|
|
|
|
|
+ setFramesWinId(MESSAGE_PREFIX, frameElements, message.options, FrameTree.index, FrameTree.windowId, window);
|
|
|
} else {
|
|
} else {
|
|
|
top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData: [], windowId: FrameTree.windowId, index: FrameTree.index }), "*");
|
|
top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData: [], windowId: FrameTree.windowId, index: FrameTree.index }), "*");
|
|
|
}
|
|
}
|
|
@@ -152,7 +152,7 @@ this.FrameTree = this.FrameTree || (() => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function setFramesWinId(MESSAGE_PREFIX, frameElements, index, windowId, win) {
|
|
|
|
|
|
|
+ function setFramesWinId(MESSAGE_PREFIX, frameElements, options, index, windowId, win) {
|
|
|
const framesData = [];
|
|
const framesData = [];
|
|
|
if (win != top) {
|
|
if (win != top) {
|
|
|
win.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", windowId, index }), "*");
|
|
win.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", windowId, index }), "*");
|
|
@@ -172,6 +172,7 @@ this.FrameTree = this.FrameTree || (() => {
|
|
|
const frameWinId = windowId + "." + index;
|
|
const frameWinId = windowId + "." + index;
|
|
|
frameElement.setAttribute(docHelper.WIN_ID_ATTRIBUTE_NAME, frameWinId);
|
|
frameElement.setAttribute(docHelper.WIN_ID_ATTRIBUTE_NAME, frameWinId);
|
|
|
let frameDoc, frameWindow, topWindow;
|
|
let frameDoc, frameWindow, topWindow;
|
|
|
|
|
+ let content, emptyStyleRulesText, canvasData;
|
|
|
try {
|
|
try {
|
|
|
frameDoc = frameElement.contentDocument;
|
|
frameDoc = frameElement.contentDocument;
|
|
|
frameWindow = frameElement.contentWindow;
|
|
frameWindow = frameElement.contentWindow;
|
|
@@ -180,10 +181,15 @@ this.FrameTree = this.FrameTree || (() => {
|
|
|
/* ignored */
|
|
/* ignored */
|
|
|
}
|
|
}
|
|
|
if (frameWindow && frameDoc && topWindow) {
|
|
if (frameWindow && frameDoc && topWindow) {
|
|
|
- setFramesWinId(MESSAGE_PREFIX, frameDoc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"), index, frameWinId, frameWindow);
|
|
|
|
|
|
|
+ setFramesWinId(MESSAGE_PREFIX, frameDoc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"), options, index, frameWinId, frameWindow);
|
|
|
topWindow.addEventListener("message", onMessage, false);
|
|
topWindow.addEventListener("message", onMessage, false);
|
|
|
|
|
+ docHelper.preProcessDoc(frameDoc, frameWindow, options);
|
|
|
|
|
+ content = docHelper.getDoctype(frameDoc) + frameDoc.documentElement.outerHTML;
|
|
|
|
|
+ emptyStyleRulesText = docHelper.getEmptyStyleRulesText(frameDoc);
|
|
|
|
|
+ canvasData = docHelper.getCanvasData(frameDoc);
|
|
|
|
|
+ docHelper.postProcessDoc(frameDoc, options);
|
|
|
} else if (frameWindow) {
|
|
} else if (frameWindow) {
|
|
|
- frameWindow.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initRequest", windowId: frameWinId, index }), "*");
|
|
|
|
|
|
|
+ frameWindow.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initRequest", windowId: frameWinId, index, options }), "*");
|
|
|
timeout.set(() => top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData: [], windowId: frameWinId, index }), "*"), TIMEOUT_INIT_REQUEST_MESSAGE);
|
|
timeout.set(() => top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData: [], windowId: frameWinId, index }), "*"), TIMEOUT_INIT_REQUEST_MESSAGE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -192,16 +198,7 @@ this.FrameTree = this.FrameTree || (() => {
|
|
|
const message = JSON.parse(event.data.substring(MESSAGE_PREFIX.length + 2));
|
|
const message = JSON.parse(event.data.substring(MESSAGE_PREFIX.length + 2));
|
|
|
if (message.method == "getDataRequest" && message.windowId == frameWinId) {
|
|
if (message.method == "getDataRequest" && message.windowId == frameWinId) {
|
|
|
topWindow.removeEventListener("message", onMessage, false);
|
|
topWindow.removeEventListener("message", onMessage, false);
|
|
|
- try {
|
|
|
|
|
- docHelper.preProcessDoc(frameDoc, frameWindow, message.options);
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- /* ignored */
|
|
|
|
|
- }
|
|
|
|
|
- const content = docHelper.getDoctype(frameDoc) + frameDoc.documentElement.outerHTML;
|
|
|
|
|
- const emptyStyleRulesText = docHelper.getEmptyStyleRulesText(frameDoc);
|
|
|
|
|
- const canvasData = docHelper.getCanvasData(frameDoc);
|
|
|
|
|
top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "getDataResponse", windowId: message.windowId, content, baseURI: frameDoc.baseURI, title: document.title, emptyStyleRulesText, canvasData }), "*");
|
|
top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "getDataResponse", windowId: message.windowId, content, baseURI: frameDoc.baseURI, title: document.title, emptyStyleRulesText, canvasData }), "*");
|
|
|
- docHelper.postProcessDoc(frameDoc, message.options);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|