|
@@ -27,7 +27,7 @@ this.frameTree = this.frameTree || (() => {
|
|
|
const INIT_REQUEST_MESSAGE = "initRequest";
|
|
const INIT_REQUEST_MESSAGE = "initRequest";
|
|
|
const INIT_RESPONSE_MESSAGE = "initResponse";
|
|
const INIT_RESPONSE_MESSAGE = "initResponse";
|
|
|
const TIMEOUT_INIT_REQUEST_MESSAGE = 500;
|
|
const TIMEOUT_INIT_REQUEST_MESSAGE = 500;
|
|
|
- const TOP_WINDOW = window == top;
|
|
|
|
|
|
|
+ const TOP_WINDOW = isTopWindow(window);
|
|
|
|
|
|
|
|
let sessionId, sessions, windowId;
|
|
let sessionId, sessions, windowId;
|
|
|
|
|
|
|
@@ -62,7 +62,7 @@ this.frameTree = this.frameTree || (() => {
|
|
|
const sessionId = message.sessionId;
|
|
const sessionId = message.sessionId;
|
|
|
windowId = message.windowId;
|
|
windowId = message.windowId;
|
|
|
const frameElements = document.querySelectorAll(FRAMES_CSS_SELECTOR);
|
|
const frameElements = document.querySelectorAll(FRAMES_CSS_SELECTOR);
|
|
|
- if (window != top) {
|
|
|
|
|
|
|
+ if (!TOP_WINDOW) {
|
|
|
const docData = docHelper.preProcessDoc(document, window, message.options);
|
|
const docData = docHelper.preProcessDoc(document, window, message.options);
|
|
|
const content = docHelper.serialize(document);
|
|
const content = docHelper.serialize(document);
|
|
|
docHelper.postProcessDoc(document, window, message.options);
|
|
docHelper.postProcessDoc(document, window, message.options);
|
|
@@ -109,9 +109,9 @@ this.frameTree = this.frameTree || (() => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function processFrames(frameElements, options, windowId, sessionId, win) {
|
|
|
|
|
- if (win != top) {
|
|
|
|
|
- win.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: INIT_RESPONSE_MESSAGE, windowId, sessionId }), "*");
|
|
|
|
|
|
|
+ function processFrames(frameElements, options, windowId, sessionId, window) {
|
|
|
|
|
+ if (!isTopWindow(window)) {
|
|
|
|
|
+ window.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: INIT_RESPONSE_MESSAGE, windowId, sessionId }), "*");
|
|
|
}
|
|
}
|
|
|
let framesData = [];
|
|
let framesData = [];
|
|
|
frameElements.forEach((frameElement, frameIndex) => {
|
|
frameElements.forEach((frameElement, frameIndex) => {
|
|
@@ -162,4 +162,8 @@ this.frameTree = this.frameTree || (() => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function isTopWindow(win) {
|
|
|
|
|
+ return win == top;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
})();
|
|
})();
|