Преглед изворни кода

call window.set/clearTimeout in the lib part of SingleFile

Gildas пре 5 година
родитељ
комит
4e6235fa11

+ 2 - 2
lib/single-file/index.js

@@ -21,7 +21,7 @@
  *   Source.
  */
 
-/* global window, setTimeout */
+/* global window */
 
 this.singlefile = this.singlefile || {
 	lib: {
@@ -48,7 +48,7 @@ this.singlefile = this.singlefile || {
 					if (!options.removeFrames && frames && window.frames && window.frames.length) {
 						let frameTreePromise;
 						if (options.loadDeferredImages) {
-							frameTreePromise = new Promise(resolve => setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesMaxIdleTime - frames.TIMEOUT_INIT_REQUEST_MESSAGE));
+							frameTreePromise = new Promise(resolve => window.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesMaxIdleTime - frames.TIMEOUT_INIT_REQUEST_MESSAGE));
 						} else {
 							frameTreePromise = frames.getAsync(options);
 						}

+ 2 - 2
lib/single-file/modules/css-fonts-alt-minifier.js

@@ -21,7 +21,7 @@
  *   Source.
  */
 
-/* global window, setTimeout */
+/* global window */
 
 this.singlefile.lib.modules.fontsAltMinifier = this.singlefile.lib.modules.fontsAltMinifier || (() => {
 
@@ -230,7 +230,7 @@ this.singlefile.lib.modules.fontsAltMinifier = this.singlefile.lib.modules.fonts
 										await Promise.race(
 											[
 												fontFace.load().then(() => fontFace.loaded).then(() => source.valid = true),
-												new Promise(resolve => setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
+												new Promise(resolve => window.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
 											]);
 									} catch (error) {
 										// ignored

+ 4 - 4
lib/single-file/processors/frame-tree/content/content-frame-tree.js

@@ -21,7 +21,7 @@
  *   Source.
  */
 
-/* global window, setTimeout, clearTimeout */
+/* global window */
 
 this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.processors.frameTree.content.frames || (() => {
 
@@ -233,7 +233,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
 			} catch (error) {
 				// ignored
 			}
-			requestTimeouts[windowId] = setTimeout(() => sendInitResponse({ frames: [{ windowId, processed: true }], sessionId }), TIMEOUT_INIT_REQUEST_MESSAGE);
+			requestTimeouts[windowId] = window.setTimeout(() => sendInitResponse({ frames: [{ windowId, processed: true }], sessionId }), TIMEOUT_INIT_REQUEST_MESSAGE);
 		});
 		delete doc.documentElement.dataset.requestedFrameId;
 	}
@@ -269,7 +269,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
 		if (session && session[type]) {
 			const timeout = session[type][windowId];
 			if (timeout) {
-				clearTimeout(timeout);
+				window.clearTimeout(timeout);
 				delete session[type][windowId];
 			}
 		}
@@ -278,7 +278,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
 	function createFrameResponseTimeout(sessionId, windowId) {
 		const session = sessions.get(sessionId);
 		if (session && session.responseTimeouts) {
-			session.responseTimeouts[windowId] = setTimeout(() => sendInitResponse({ frames: [{ windowId: windowId, processed: true }], sessionId: sessionId }), TIMEOUT_INIT_RESPONSE_MESSAGE);
+			session.responseTimeouts[windowId] = window.setTimeout(() => sendInitResponse({ frames: [{ windowId: windowId, processed: true }], sessionId: sessionId }), TIMEOUT_INIT_RESPONSE_MESSAGE);
 		}
 	}
 

+ 3 - 3
lib/single-file/processors/lazy/content/content-lazy-loader.js

@@ -21,7 +21,7 @@
  *   Source.
  */
 
-/* global window, setTimeout, clearTimeout */
+/* global window */
 
 this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.processors.lazy.content.loader || (() => {
 
@@ -161,7 +161,7 @@ this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.process
 			browser.runtime.onMessage.addListener(timeoutCallback);
 			return timeoutId;
 		} else {
-			return setTimeout(callback, delay);
+			return window.setTimeout(callback, delay);
 		}
 	}
 
@@ -169,7 +169,7 @@ this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.process
 		if (browser && browser.runtime && browser.runtime.sendMessage) {
 			await browser.runtime.sendMessage({ method: "singlefile.lazyTimeout.clearTimeout", id: timeoutId });
 		} else {
-			return clearTimeout(timeoutId);
+			return window.clearTimeout(timeoutId);
 		}
 	}