code review

pull/2/head
gorhill 9 years ago
parent 987acfef65
commit dd60a74e3f

@ -46,6 +46,29 @@ vAPI.chrome = true;
/******************************************************************************/ /******************************************************************************/
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) { var messagingConnector = function(response) {
if ( !response ) { if ( !response ) {
return; return;
@ -144,6 +167,15 @@ vAPI.messaging = {
} }
}; };
// 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 ) {
vAPI.shutdown.add(function() {
vAPI = null;
});
}
/******************************************************************************/ /******************************************************************************/
})(this); })(this);

Loading…
Cancel
Save