1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-09-28 23:31:09 +12:00

fixed content script's clean shutdown

This commit is contained in:
gorhill 2015-05-03 09:06:35 -04:00
parent 818a3db9e4
commit b7e5a7bd44

View file

@ -259,7 +259,7 @@ var collapser = (function() {
} }
process(); process();
}; };
var iframeSourceObserver = new MutationObserver(iframeSourceModified); var iframeSourceObserver = null;
var iframeSourceObserverOptions = { var iframeSourceObserverOptions = {
attributes: true, attributes: true,
attributeFilter: [ 'src' ] attributeFilter: [ 'src' ]
@ -269,6 +269,9 @@ var collapser = (function() {
// https://github.com/gorhill/uBlock/issues/162 // https://github.com/gorhill/uBlock/issues/162
// Be prepared to deal with possible change of src attribute. // Be prepared to deal with possible change of src attribute.
if ( dontObserve !== true ) { if ( dontObserve !== true ) {
if ( iframeSourceObserver === null ) {
iframeSourceObserver = new MutationObserver(iframeSourceModified);
}
iframeSourceObserver.observe(iframe, iframeSourceObserverOptions); iframeSourceObserver.observe(iframe, iframeSourceObserverOptions);
} }
// https://github.com/chrisaljoudi/uBlock/issues/174 // https://github.com/chrisaljoudi/uBlock/issues/174
@ -343,6 +346,10 @@ var collapser = (function() {
clearTimeout(timer); clearTimeout(timer);
timer = null; timer = null;
} }
if ( iframeSourceObserver !== null ) {
iframeSourceObserver.disconnect();
iframeSourceObserver = null;
}
document.removeEventListener('error', onResourceFailed, true); document.removeEventListener('error', onResourceFailed, true);
newRequests = []; newRequests = [];
pendingRequests = {}; pendingRequests = {};