Bläddra i källkod

removed obsolete code

Gildas 7 år sedan
förälder
incheckning
d45b4f11af

+ 1 - 1
lib/single-file/frame-tree/bg/frame-tree.js

@@ -47,7 +47,7 @@ this.FrameTree = (() => {
 				} else {
 					tabsData[tabId] = [resolve];
 				}
-				browser.tabs.sendMessage(tabId, { method: "FrameTree.initRequest", windowId: "0", index: 0, options });
+				browser.tabs.sendMessage(tabId, { method: "FrameTree.initRequest", windowId: "0", options });
 			});
 		}
 	};

+ 12 - 14
lib/single-file/frame-tree/content/frame-tree.js

@@ -99,12 +99,11 @@ this.FrameTree = this.FrameTree || (() => {
 
 	function initRequest(message) {
 		FrameTree.windowId = message.windowId;
-		FrameTree.index = message.index;
 		const frameElements = document.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]");
 		if (frameElements.length) {
-			setFramesWinId(MESSAGE_PREFIX, frameElements, message.options, FrameTree.index, FrameTree.windowId, window);
+			setFramesWinId(MESSAGE_PREFIX, frameElements, message.options, FrameTree.windowId, window);
 		} 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 }), "*");
 		}
 	}
 
@@ -125,16 +124,15 @@ this.FrameTree = this.FrameTree || (() => {
 			}
 		} else {
 			FrameTree.windowId = message.windowId;
-			FrameTree.index = message.index;
 		}
 	}
 
-	function setFramesWinId(MESSAGE_PREFIX, frameElements, options, index, windowId, win) {
+	function setFramesWinId(MESSAGE_PREFIX, frameElements, options, windowId, win) {
 		const framesData = [];
 		if (win != top) {
-			win.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", windowId, index }), "*");
+			win.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", windowId }), "*");
 		}
-		frameElements.forEach((frameElement, index) => {
+		frameElements.forEach((frameElement, frameIndex) => {
 			let src, sameDomain;
 			try {
 				sameDomain = Boolean(frameElement.contentDocument && frameElement.contentWindow && top.addEventListener && top);
@@ -142,11 +140,11 @@ this.FrameTree = this.FrameTree || (() => {
 			} catch (error) {
 				/* ignored */
 			}
-			framesData.push({ sameDomain, src, index, windowId: windowId + "." + index });
+			framesData.push({ sameDomain, src, windowId: windowId + "." + frameIndex });
 		});
-		top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData, windowId, index }), "*");
-		frameElements.forEach((frameElement, index) => {
-			const frameWinId = windowId + "." + index;
+		top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData, windowId }), "*");
+		frameElements.forEach((frameElement, frameIndex) => {
+			const frameWinId = windowId + "." + frameIndex;
 			frameElement.setAttribute(docHelper.WIN_ID_ATTRIBUTE_NAME, frameWinId);
 			let frameDoc, frameWindow, topWindow;
 			let content, emptyStyleRulesText, canvasData;
@@ -158,7 +156,7 @@ this.FrameTree = this.FrameTree || (() => {
 				/* ignored */
 			}
 			if (frameWindow && frameDoc && topWindow) {
-				setFramesWinId(MESSAGE_PREFIX, frameDoc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"), options, index, frameWinId, frameWindow);
+				setFramesWinId(MESSAGE_PREFIX, frameDoc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"), options, frameWinId, frameWindow);
 				topWindow.addEventListener("message", onMessage, false);
 				const docData = docHelper.preProcessDoc(frameDoc, frameWindow, options);
 				content = docHelper.serialize(frameDoc);
@@ -166,8 +164,8 @@ this.FrameTree = this.FrameTree || (() => {
 				canvasData = docData.canvasData;
 				docHelper.postProcessDoc(frameDoc, options);
 			} else if (frameWindow) {
-				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);
+				frameWindow.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initRequest", windowId: frameWinId, frameIndex, options }), "*");
+				timeout.set(() => top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "initResponse", framesData: [], windowId: frameWinId, frameIndex }), "*"), TIMEOUT_INIT_REQUEST_MESSAGE);
 			}
 
 			function onMessage(event) {