From b7e5a7bd448d3364118d8a1e02241179db971b7b Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 3 May 2015 09:06:35 -0400 Subject: [PATCH] fixed content script's clean shutdown --- src/js/contentscript-end.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 7166e2c..013a3fd 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -259,7 +259,7 @@ var collapser = (function() { } process(); }; - var iframeSourceObserver = new MutationObserver(iframeSourceModified); + var iframeSourceObserver = null; var iframeSourceObserverOptions = { attributes: true, attributeFilter: [ 'src' ] @@ -269,6 +269,9 @@ var collapser = (function() { // https://github.com/gorhill/uBlock/issues/162 // Be prepared to deal with possible change of src attribute. if ( dontObserve !== true ) { + if ( iframeSourceObserver === null ) { + iframeSourceObserver = new MutationObserver(iframeSourceModified); + } iframeSourceObserver.observe(iframe, iframeSourceObserverOptions); } // https://github.com/chrisaljoudi/uBlock/issues/174 @@ -343,6 +346,10 @@ var collapser = (function() { clearTimeout(timer); timer = null; } + if ( iframeSourceObserver !== null ) { + iframeSourceObserver.disconnect(); + iframeSourceObserver = null; + } document.removeEventListener('error', onResourceFailed, true); newRequests = []; pendingRequests = {};