Skip to content

Commit

Permalink
Delete corresponding temp files when a script source tab is closed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ventero committed Sep 7, 2014
1 parent dccd743 commit f78a790
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions modules/remoteScript.js
Expand Up @@ -457,6 +457,14 @@ RemoteScript.prototype.showSource = function(aTabBrowser) {
var tab = aTabBrowser.loadOneTab(
ioService.newFileURI(this._scriptFile).spec,
{'inBackground': false});

// Ensure any temporary files are deleted after the tab is closed.
var cleanup = GM_util.hitch(this, function() {
tab.removeEventListener("TabClose", cleanup, false);
this.cleanup();
});
tab.addEventListener("TabClose", cleanup, false);

var notificationBox = aTabBrowser.getNotificationBox();
notificationBox.appendNotification(
stringBundleBrowser.GetStringFromName('greeting.msg'),
Expand All @@ -469,6 +477,9 @@ RemoteScript.prototype.showSource = function(aTabBrowser) {
'popup': null,
'callback': GM_util.hitch(this, function() {
GM_util.showInstallDialog(this, aTabBrowser, GM_util.getService());
// Skip the cleanup handler, as the downloaded files are used in the
// installation process.
tab.removeEventListener("TabClose", cleanup, false);
// Timeout puts this after the notification closes itself for the
// button click, avoiding an error inside that (Firefox) code.
GM_util.timeout(function() { aTabBrowser.removeTab(tab); }, 0);
Expand Down

0 comments on commit f78a790

Please sign in to comment.