1
0
Эх сурвалжийг харах

send init rerquest to all frames

Gildas 7 жил өмнө
parent
commit
0f3b93831c

+ 13 - 21
lib/single-file/frame-tree.js

@@ -133,31 +133,23 @@ this.frameTree = this.frameTree || (() => {
 			const windowId = parentWindowId + WINDOW_ID_SEPARATOR + frameIndex;
 			frameElement.setAttribute(docHelper.windowIdAttributeName(options.sessionId), windowId);
 			framesData.push({ windowId });
-			let contentDocument;
 			try {
-				contentDocument = frameElement.contentDocument;
+				sendMessage(frameElement.contentWindow, { method: INIT_REQUEST_MESSAGE, windowId, sessionId, options });
 			} catch (error) {
-				// ignored
+				/* ignored */
 			}
-			if (!contentDocument) {
-				try {
-					sendMessage(frameElement.contentWindow, { method: INIT_REQUEST_MESSAGE, windowId, sessionId, options });
-				} catch (error) {
-					/* ignored */
+			timeout.set(async () => {
+				let frameDoc;
+				if (frameElement.src && frameElement.src.match(PREFIX_VALID_FRAME_URL)) {
+					frameDoc = await getFrameDoc(frameElement.src, parentWindowId, options);
 				}
-				timeout.set(async () => {
-					let frameDoc;
-					if (frameElement.src && frameElement.src.match(PREFIX_VALID_FRAME_URL)) {
-						frameDoc = await getFrameDoc(frameElement.src, parentWindowId, options);
-					}
-					if (frameDoc) {
-						sendInitResponse({ framesData: [getFrameData(frameDoc, null, windowId, options)] });
-						timeout.set(() => sendInitResponse({ framesData: [{ windowId, processed: true, timeout: true }], sessionId }));
-					} else {
-						sendInitResponse({ framesData: [{ windowId, processed: true, timeout: true }], sessionId });
-					}
-				}, TIMEOUT_INIT_REQUEST_MESSAGE);
-			}
+				if (frameDoc) {
+					sendInitResponse({ framesData: [getFrameData(frameDoc, null, windowId, options)] });
+					timeout.set(() => sendInitResponse({ framesData: [{ windowId, processed: true, timeout: true }], sessionId }));
+				} else {
+					sendInitResponse({ framesData: [{ windowId, processed: true, timeout: true }], sessionId });
+				}
+			}, TIMEOUT_INIT_REQUEST_MESSAGE);
 		});
 		sendInitResponse({ framesData, sessionId });
 	}