aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeathamns <deathamns@gmail.com>2015-03-18 12:47:07 +0100
committerDeathamns <deathamns@gmail.com>2015-03-18 12:47:07 +0100
commit51532fc74e1a6c2a3914b0e4adfa1235dbe3cee6 (patch)
treefeee2d36dca639ab03ec9108b3de86e991723af2
parentd2a6a38db2e7f379b997fa6af01c9e2d0061bf9c (diff)
downloaduBlock-51532fc74e1a6c2a3914b0e4adfa1235dbe3cee6.zip
uBlock-51532fc74e1a6c2a3914b0e4adfa1235dbe3cee6.tar.gz
uBlock-51532fc74e1a6c2a3914b0e4adfa1235dbe3cee6.tar.bz2
Firefox: register unload event sooner
-rw-r--r--platform/firefox/vapi-background.js46
1 files changed, 26 insertions, 20 deletions
diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js
index 870ad7f..6bba489 100644
--- a/platform/firefox/vapi-background.js
+++ b/platform/firefox/vapi-background.js
@@ -64,6 +64,29 @@ vAPI.app.restart = function() {
var cleanupTasks = [];
+// This must be updated manually, every time a new task is added/removed
+var expectedNumberOfCleanups = 7;
+
+window.addEventListener('unload', function() {
+ for ( var cleanup of cleanupTasks ) {
+ cleanup();
+ }
+
+ if ( cleanupTasks.length < expectedNumberOfCleanups ) {
+ console.error(
+ 'uBlock> Cleanup tasks performed: %s (out of %s)',
+ cleanupTasks.length,
+ expectedNumberOfCleanups
+ );
+ }
+
+ // frameModule needs to be cleared too
+ var frameModule = {};
+ Cu.import(vAPI.getURL('frameModule.js'), frameModule);
+ frameModule.contentObserver.unregister();
+ Cu.unload(vAPI.getURL('frameModule.js'));
+});
+
/******************************************************************************/
var SQLite = {
@@ -495,8 +518,7 @@ vAPI.tabs.getTabsForIds = function(tabIds) {
tabIds = [tabIds];
}
for ( var tab of this.getAll() ) {
- var browser = getBrowserForTab(tab);
- var tabId = this.stack.get(browser);
+ var tabId = this.stack.get(getBrowserForTab(tab));
if ( !tabId ) {
continue;
}
@@ -846,7 +868,7 @@ vAPI.messaging.onMessage = function({target, data}) {
return;
}
- console.error('µBlock> messaging > unknown request: %o', data);
+ console.error('uBlock> messaging > unknown request: %o', data);
// Unhandled:
// Need to callback anyways in case caller expected an answer, or
@@ -1021,7 +1043,7 @@ var httpObserver = {
try {
this.componentRegistrar.unregisterFactory(this.classID, Components.manager.getClassObject(this.classID, Ci.nsIFactory));
} catch (ex) {
- console.error('µBlock> httpObserver > unable to unregister stale instance: ', ex);
+ console.error('uBlock> httpObserver > unable to unregister stale instance: ', ex);
}
}
@@ -1911,22 +1933,6 @@ vAPI.punycodeURL = function(url) {
/******************************************************************************/
-// clean up when the extension is disabled
-
-window.addEventListener('unload', function() {
- for ( var cleanup of cleanupTasks ) {
- cleanup();
- }
-
- // frameModule needs to be cleared too
- var frameModule = {};
- Cu.import(vAPI.getURL('frameModule.js'), frameModule);
- frameModule.contentObserver.unregister();
- Cu.unload(vAPI.getURL('frameModule.js'));
-});
-
-/******************************************************************************/
-
})();
/******************************************************************************/