From 2fbca2cc0973a63bdc96a47a5a894e35a790dd16 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 8 Apr 2015 06:15:10 -0400 Subject: [PATCH] forgot to add shutdown to other platforms (re. https://github.com/gorhill/uMatrix/issues/144) --- platform/firefox/vapi-client.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/platform/firefox/vapi-client.js b/platform/firefox/vapi-client.js index 2d35b2e..5f37ce2 100644 --- a/platform/firefox/vapi-client.js +++ b/platform/firefox/vapi-client.js @@ -38,6 +38,29 @@ vAPI.sessionId = String.fromCharCode(Date.now() % 25 + 97) + /******************************************************************************/ +vAPI.shutdown = (function() { + var jobs = []; + + var add = function(job) { + jobs.push(job); + }; + + var exec = function() { + //console.debug('Shutting down...'); + var job; + while ( job = jobs.pop() ) { + job(); + } + }; + + return { + add: add, + exec: exec + }; +})(); + +/******************************************************************************/ + var messagingConnector = function(response) { if ( !response ) { return; @@ -168,6 +191,15 @@ window.addEventListener('pageshow', vAPI.messaging.toggleListener, true); /******************************************************************************/ +// No need to have vAPI client linger around after shutdown if +// we are not a top window (because element picker can still +// be injected in top window). +if ( window !== window.top ) { + // Can anything be done? +} + +/******************************************************************************/ + })(this); /******************************************************************************/