|
|
@@ -60,7 +60,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
initResponse(message);
|
|
|
return Promise.resolve({});
|
|
|
} else if (message.method == ACK_INIT_REQUEST_MESSAGE) {
|
|
|
- clearFrameTimeout(message.sessionId, message.windowId);
|
|
|
+ clearFrameTimeout("requestTimeouts", message.sessionId, message.windowId);
|
|
|
createFrameResponseTimeout(message.sessionId, message.windowId);
|
|
|
return Promise.resolve({});
|
|
|
}
|
|
|
@@ -82,7 +82,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
await initRequestAsync(message);
|
|
|
}
|
|
|
} else if (message.method == ACK_INIT_REQUEST_MESSAGE) {
|
|
|
- clearFrameTimeout(message.sessionId, message.windowId);
|
|
|
+ clearFrameTimeout("requestTimeouts", message.sessionId, message.windowId);
|
|
|
createFrameResponseTimeout(message.sessionId, message.windowId);
|
|
|
} else if (message.method == CLEANUP_REQUEST_MESSAGE) {
|
|
|
cleanupRequest(message);
|
|
|
@@ -97,14 +97,14 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
const sessionId = options.sessionId || 0;
|
|
|
options = JSON.parse(JSON.stringify(options));
|
|
|
return new Promise(async resolve => {
|
|
|
- sessions.set(sessionId, { frames: [], timeouts: {}, resolve });
|
|
|
+ sessions.set(sessionId, { frames: [], requestTimeouts: {}, responseTimeouts: {}, resolve });
|
|
|
await initRequestAsync({ windowId, sessionId, options });
|
|
|
});
|
|
|
},
|
|
|
getSync: options => {
|
|
|
const sessionId = options.sessionId || 0;
|
|
|
options = JSON.parse(JSON.stringify(options));
|
|
|
- sessions.set(sessionId, { frames: [], timeouts: {} });
|
|
|
+ sessions.set(sessionId, { frames: [], requestTimeouts: {}, responseTimeouts: {} });
|
|
|
initRequestSync({ windowId, sessionId, options });
|
|
|
return sessions.get(sessionId).frames;
|
|
|
},
|
|
|
@@ -160,7 +160,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
}
|
|
|
|
|
|
function initResponse(message) {
|
|
|
- message.frames.forEach(frameData => clearFrameTimeout(message.sessionId, frameData.windowId));
|
|
|
+ message.frames.forEach(frameData => clearFrameTimeout("responseTimeouts", message.sessionId, frameData.windowId));
|
|
|
const windowData = sessions.get(message.sessionId);
|
|
|
if (windowData) {
|
|
|
if (message.requestedFrameId) {
|
|
|
@@ -213,12 +213,12 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
|
|
|
function processFramesAsync(doc, frameElements, options, parentWindowId, sessionId) {
|
|
|
const frames = [];
|
|
|
- let timeouts;
|
|
|
+ let requestTimeouts;
|
|
|
if (sessions.get(sessionId)) {
|
|
|
- timeouts = sessions.get(sessionId).timeouts;
|
|
|
+ requestTimeouts = sessions.get(sessionId).requestTimeouts;
|
|
|
} else {
|
|
|
- timeouts = {};
|
|
|
- sessions.set(sessionId, { timeouts });
|
|
|
+ requestTimeouts = {};
|
|
|
+ sessions.set(sessionId, { requestTimeouts });
|
|
|
}
|
|
|
frameElements.forEach((frameElement, frameIndex) => {
|
|
|
const windowId = parentWindowId + WINDOW_ID_SEPARATOR + frameIndex;
|
|
|
@@ -233,7 +233,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
} catch (error) {
|
|
|
// ignored
|
|
|
}
|
|
|
- timeouts[windowId] = setTimeout.call(window, () => sendInitResponse({ frames: [{ windowId, processed: true }], sessionId }), TIMEOUT_INIT_REQUEST_MESSAGE);
|
|
|
+ requestTimeouts[windowId] = setTimeout.call(window, () => sendInitResponse({ frames: [{ windowId, processed: true }], sessionId }), TIMEOUT_INIT_REQUEST_MESSAGE);
|
|
|
});
|
|
|
delete doc.documentElement.dataset.requestedFrameId;
|
|
|
}
|
|
|
@@ -252,7 +252,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
try {
|
|
|
const frameWindow = frameElement.contentWindow;
|
|
|
frameWindow.stop();
|
|
|
- clearFrameTimeout(sessionId, windowId);
|
|
|
+ clearFrameTimeout("requestTimeouts", sessionId, windowId);
|
|
|
processFrames(frameDoc, options, windowId, sessionId);
|
|
|
frames.push(getFrameData(frameDoc, frameWindow, windowId, options));
|
|
|
} catch (error) {
|
|
|
@@ -264,21 +264,21 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
|
|
|
delete doc.documentElement.dataset.requestedFrameId;
|
|
|
}
|
|
|
|
|
|
- function clearFrameTimeout(sessionId, windowId) {
|
|
|
+ function clearFrameTimeout(type, sessionId, windowId) {
|
|
|
const session = sessions.get(sessionId);
|
|
|
- if (session && session.timeouts) {
|
|
|
- const timeout = session.timeouts[windowId];
|
|
|
+ if (session && session[type]) {
|
|
|
+ const timeout = session[type][windowId];
|
|
|
if (timeout) {
|
|
|
clearTimeout.call(window, timeout);
|
|
|
- delete session.timeouts[windowId];
|
|
|
+ delete session[type][windowId];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function createFrameResponseTimeout(sessionId, windowId) {
|
|
|
const session = sessions.get(sessionId);
|
|
|
- if (session && session.timeouts) {
|
|
|
- session.timeouts[windowId] = setTimeout.call(window, () => sendInitResponse({ frames: [{ windowId: windowId, processed: true }], sessionId: sessionId }), TIMEOUT_INIT_RESPONSE_MESSAGE);
|
|
|
+ if (session && session.responseTimeouts) {
|
|
|
+ session.responseTimeouts[windowId] = setTimeout.call(window, () => sendInitResponse({ frames: [{ windowId: windowId, processed: true }], sessionId: sessionId }), TIMEOUT_INIT_RESPONSE_MESSAGE);
|
|
|
}
|
|
|
}
|
|
|
|