Skip to content

Commit 8402398

Browse files
committed
Fix removeUnintentionalBlank option (#36, #38, #43)
1 parent 0fa793c commit 8402398

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

chrome/content/tabutils.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,40 @@ tabutils._tabOpeningOptions = function() {
586586
&& aStatus == 0
587587
&& TU_getPref("extensions.tabutils.removeUnintentionalBlank", true)) {
588588
let win = aWebProgress.DOMWindow;
589-
win._closeTimer = win.setTimeout(function(self) {
590-
self.mTabBrowser.isBlankTab(self.mTab) && self.mTabBrowser.removeTab(self.mTab);
591-
}, 250, this);
589+
win._closeTimer = win.setTimeout(function() {
590+
this.mTabBrowser.isBlankTab(this.mTab) && this.mTabBrowser.removeTab(this.mTab);
591+
}.bind(this), 750);
592592
}
593593
});
594594

595+
let tmp = {};
596+
Cu.import("resource://gre/modules/DownloadLastDir.jsm", tmp);
597+
598+
if (tmp.DownloadLastDir && // Bug 722995 [Fx19]
599+
tmp.DownloadLastDir.prototype.getFileAsync && // Bug 854299 [Fx23]
600+
tmp.DownloadLastDir.prototype.getFileAsync.name != "TU_getFileAsync")
601+
tmp.DownloadLastDir.prototype.getFileAsync = (function() {
602+
let getFileAsync = tmp.DownloadLastDir.prototype.getFileAsync;
603+
return function TU_getFileAsync(aURI, aCallback) {
604+
let win = this.window;
605+
if (win._closeTimer) {
606+
win.clearTimeout(win._closeTimer);
607+
win._closeTimer = null;
608+
609+
aCallback = (function() {
610+
let lastDirCallback = aCallback;
611+
return function TU_LastDirCallback(lastDir) {
612+
lastDirCallback(lastDir);
613+
if (!win.closed) {
614+
win.setTimeout(win.close, 250);
615+
}
616+
};
617+
})();
618+
}
619+
getFileAsync.apply(this, arguments);
620+
};
621+
})();
622+
595623
//在当前标签页的右侧打开新标签页
596624
//连续打开后台标签时保持原有顺序
597625
TU_hookCode("gBrowser.addTab",

chrome/content/unknownContentType.xul

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
if (win && win._closeTimer) {
77
win.clearTimeout(win._closeTimer);
88
window.addEventListener("unload", function() {
9-
win && win.setTimeout(function() {this.close();}, 250);
9+
if (win._closeTimer && !win.closed)
10+
win._closeTimer = win.setTimeout(win.close, 250);
1011
}, false);
1112
}
1213
]]>

0 commit comments

Comments
 (0)