소스 검색

renamed frameWindowId variable

Gildas 7 년 전
부모
커밋
1ed4e0e888
1개의 변경된 파일22개의 추가작업 그리고 29개의 파일을 삭제
  1. 22 29
      lib/single-file/frame-tree.js

+ 22 - 29
lib/single-file/frame-tree.js

@@ -72,17 +72,16 @@ this.frameTree = this.frameTree || (() => {
 			const docData = docHelper.preProcessDoc(document, window, message.options);
 			const content = docHelper.serialize(document);
 			docHelper.postProcessDoc(document, window, message.options);
-			sendInitResponse({
-				framesData: [{
-					windowId,
-					content,
-					baseURI: document.baseURI.split("#")[0],
-					title: document.title,
-					emptyStyleRulesText: docData.emptyStyleRulesText,
-					canvasData: docData.canvasData,
-					processed: true,
-				}], sessionId
-			});
+			const framesData = [{
+				windowId,
+				content,
+				baseURI: document.baseURI.split("#")[0],
+				title: document.title,
+				emptyStyleRulesText: docData.emptyStyleRulesText,
+				canvasData: docData.canvasData,
+				processed: true,
+			}];
+			sendInitResponse({ framesData, sessionId });
 		}
 		processFrames(frameElements, message.options, windowId, sessionId);
 	}
@@ -115,37 +114,34 @@ this.frameTree = this.frameTree || (() => {
 		}
 	}
 
-	function processFrames(frameElements, options, windowId, sessionId) {
+	function processFrames(frameElements, options, parentWindowId, sessionId) {
 		let framesData = [];
 		frameElements.forEach((frameElement, frameIndex) => {
-			const frameWindowId = windowId + "." + frameIndex;
-			frameElement.setAttribute(docHelper.windowIdAttributeName(options.sessionId), frameWindowId);
-			framesData.push({ windowId: frameWindowId });
+			const windowId = parentWindowId + "." + frameIndex;
+			frameElement.setAttribute(docHelper.windowIdAttributeName(options.sessionId), windowId);
+			framesData.push({ windowId });
 			if (!frameElement.contentDocument) {
 				try {
-					frameElement.contentWindow.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: INIT_REQUEST_MESSAGE, windowId: frameWindowId, sessionId, options }), "*");
+					frameElement.contentWindow.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: INIT_REQUEST_MESSAGE, windowId, sessionId, options }), "*");
 				} catch (error) {
 					/* ignored */
 				}
 			}
-			timeout.set(() => sendInitResponse({
-				framesData: [{ windowId: frameWindowId, processed: true, timeout: true }],
-				windowId: frameWindowId, sessionId
-			}, "*"), TIMEOUT_INIT_REQUEST_MESSAGE);
+			timeout.set(() => sendInitResponse({ framesData: [{ windowId, processed: true, timeout: true }], windowId, sessionId }, "*"), TIMEOUT_INIT_REQUEST_MESSAGE);
 		});
-		sendInitResponse({ framesData, windowId, sessionId });
+		sendInitResponse({ framesData, parentWindowId, sessionId });
 		if (frameElements.length) {
 			framesData = [];
 			frameElements.forEach((frameElement, frameIndex) => {
-				const frameWindowId = windowId + "." + frameIndex;
+				const windowId = parentWindowId + "." + frameIndex;
 				const frameWindow = frameElement.contentWindow;
 				const frameDoc = frameElement.contentDocument;
 				if (frameDoc) {
 					try {
-						processFrames(frameDoc.querySelectorAll(FRAMES_CSS_SELECTOR), options, frameWindowId, sessionId);
+						processFrames(frameDoc.querySelectorAll(FRAMES_CSS_SELECTOR), options, windowId, sessionId);
 						const docData = docHelper.preProcessDoc(frameDoc, frameWindow, options);
 						framesData.push({
-							windowId: frameWindowId,
+							windowId,
 							content: docHelper.serialize(frameDoc),
 							baseURI: frameDoc.baseURI.split("#")[0],
 							title: frameDoc.title,
@@ -155,14 +151,11 @@ this.frameTree = this.frameTree || (() => {
 						});
 						docHelper.postProcessDoc(frameDoc, frameWindow, options);
 					} catch (error) {
-						framesData.push({
-							windowId: frameWindowId,
-							processed: true
-						});
+						framesData.push({ windowId, processed: true });
 					}
 				}
 			});
-			sendInitResponse({ framesData, windowId, sessionId });
+			sendInitResponse({ framesData, parentWindowId, sessionId });
 		}
 	}